Skip to content

Function body is translated more than once #7349

Closed
@dotdash

Description

@dotdash

The closures in std::os::with_env_lock are translated multiple times, probably once for each monomorphic version of that function. Since the closure isn't actually generic, we end up with a single function that has its body repeated multiple times:

define void @_ZN2os13with_env_lock18rust_take_env_lock16_df5982df3c0192c6_07preE({ i64, %tydesc*, i8*, i8*, i8 }*) #9 {
static_allocas:
br label %1

return: ; preds = %1
ret void

; <label>:1 ; preds = %static_allocas
call void @rust_take_env_lock()
br label %return

static_allocas1: ; No predecessors!
br label %2

return2: ; preds = %2
ret void

; <label>:2 ; preds = %static_allocas1
call void @rust_take_env_lock()
br label %return2

static_allocas3: ; No predecessors!
br label %3

return4: ; preds = %3
ret void

; <label>:3 ; preds = %static_allocas3
call void @rust_take_env_lock()
br label %return4

static_allocas5: ; No predecessors!
br label %4

return6: ; preds = %4
ret void

; <label>:4 ; preds = %static_allocas5
call void @rust_take_env_lock()
br label %return6
}

This is not limited to closures, the same happens for rustc::middle::typeck::astconv::ast_ty_to_ty::check_path_args, which contains its body 6 times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationI-slowIssue: Problems and improvements with respect to performance of generated code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions