Skip to content

incorrect inlining of target function #6

Closed
@ZuseZ4

Description

@ZuseZ4

let result = llvm::LLVMRustOptimizeWithNewPassManager(

@bytesnake Here we break main trough inlining.
Before:

      8 ; Function Attrs: nonlazybind uwtable
      9 define internal void @_ZN3ref4main17hd7a078464f06f560E() unnamed_addr #2 {
     10   %1 = alloca float, align 4
     11   %2 = alloca float, align 4
     12   %3 = bitcast float* %2 to i8*                                                                                                                                                           13   call void @llvm.lifetime.start.p0i8(i64 4, i8* %3)
     14   store float 0x40091EB860000000, float* %2, align 4
     15   %4 = bitcast float* %1 to i8*
     16   call void @llvm.lifetime.start.p0i8(i64 4, i8* %4)
     17   store float 0.000000e+00, float* %1, align 4
     18   call void @_ZN3ref7cos_ref17h6719ec9878d14346E(float* noalias noundef readonly align 4 dereferenceable(4) %2, float* noalias noundef align 4 dereferenceable(4) %1, float 1.000000e        +00)
     19   br label %5 
     20  
     21 5:                                                ; preds = %0
     22   %6 = load float, float* %1, align 4
     23   %7 = load float, float* %2, align 4
     24   %8 = call float @"_ZN3std3f3221_$LT$impl$u20$f32$GT$3cos17h814fb01877381cc3E"(float %7)
     25   br label %9
     26 
     27 9:                                                ; preds = %5
     28   %10 = fcmp oeq float %6, %8
     29   %11 = xor i1 %10, true
     30   br i1 %11, label %15, label %12
     31 
     32 12:                                               ; preds = %9
     33   %13 = bitcast float* %1 to i8*
     34   call void @llvm.lifetime.end.p0i8(i64 4, i8* %13)
     35   %14 = bitcast float* %2 to i8*
     36   call void @llvm.lifetime.end.p0i8(i64 4, i8* %14)
     37   ret void
     38 
     39 15:                                               ; preds = %9
     40   call void @_ZN4core9panicking5panic17h53e5711e5a6f3ca2E([0 x i8]* noalias noundef nonnull readonly align 1 bitcast (<{ [38 x i8] }>* @3 to [0 x i8]*), i64 38, %0* noalias noundef         readonly align 8 dereferenceable(24) bitcast (<{ i8*, [16 x i8] }>* @4 to %0*)) #7
     41   unreachable
     42 }

After:

      2 ; Function Attrs: nonlazybind uwtable
      3 define internal void @_ZN3ref4main17hd7a078464f06f560E() unnamed_addr #2 {
      4   %1 = alloca float, align 4
      5   %2 = bitcast float* %1 to i8*
      6   call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %2)  
      7   store float 0x40091EB860000000, float* %1, align 4
      8   call void @_ZN3ref7cos_ref17h6719ec9878d14346E(float* noalias noundef nonnull readonly align 4 dereferenceable(4) %1, float* noalias align 4 undef, float undef)
      9   unreachable
     10 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions