1; Checks for few bitcasted call evaluation errors 2 3; REQUIRES: asserts 4; RUN: opt -passes=globalopt,instcombine -S -debug-only=evaluator %s -o %t 2>&1 | FileCheck %s 5 6; CHECK: Failed to fold bitcast call expr 7; CHECK: Can not convert function argument 8 9target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 10target triple = "x86_64-apple-macosx10.12.0" 11 12%struct.S = type { i32 } 13%struct.Q = type { i32 } 14%struct.Foo = type { i32 } 15 16@_s = global %struct.S zeroinitializer, align 4 17@_q = global %struct.Q zeroinitializer, align 4 18@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_main2.cpp, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_main3.cpp, i8* null }] 19 20define internal void @__cxx_global_var_init() section "__TEXT,__StaticInit,regular,pure_instructions" { 21 call void @_ZN1SC1Ev(%struct.S* @_s) 22 ret void 23} 24 25define linkonce_odr void @_ZN1SC1Ev(%struct.S*) unnamed_addr align 2 { 26 %2 = alloca %struct.S*, align 8 27 store %struct.S* %0, %struct.S** %2, align 8 28 %3 = load %struct.S*, %struct.S** %2, align 8 29 call void @_ZN1SC2Ev(%struct.S* %3) 30 ret void 31} 32 33define internal void @__cxx_global_var_init.1() #0 section "__TEXT,__StaticInit,regular,pure_instructions" { 34 call void @_ZN1QC1Ev(%struct.Q* @_q) 35 ret void 36} 37 38define linkonce_odr void @_ZN1QC1Ev(%struct.Q*) unnamed_addr align 2 { 39 %2 = alloca %struct.Q*, align 8 40 store %struct.Q* %0, %struct.Q** %2, align 8 41 %3 = load %struct.Q*, %struct.Q** %2, align 8 42 call void @_ZN1QC2Ev(%struct.Q* %3) 43 ret void 44} 45 46define i32 @main() { 47 %1 = alloca i32, align 4 48 store i32 0, i32* %1, align 4 49 ret i32 0 50} 51 52define linkonce_odr void @_ZN1SC2Ev(%struct.S*) unnamed_addr align 2 { 53 %2 = alloca %struct.S*, align 8 54 %3 = alloca %struct.Foo, align 4 55 store %struct.S* %0, %struct.S** %2, align 8 56 %4 = load %struct.S*, %struct.S** %2, align 8 57 %5 = getelementptr inbounds %struct.S, %struct.S* %4, i32 0, i32 0 58 %6 = call i32 bitcast (%struct.Foo* ()* @_ZL3foov to i32 ()*)() 59 %7 = getelementptr inbounds %struct.Foo, %struct.Foo* %3, i32 0, i32 0 60 store i32 %6, i32* %7, align 4 61 %8 = getelementptr inbounds %struct.Foo, %struct.Foo* %3, i32 0, i32 0 62 %9 = load i32, i32* %8, align 4 63 store i32 %9, i32* %5, align 4 64 ret void 65} 66 67define internal %struct.Foo* @_ZL3foov() { 68 ret %struct.Foo* getelementptr (%struct.Foo, %struct.Foo *null, i32 1) 69} 70 71define linkonce_odr void @_ZN1QC2Ev(%struct.Q*) unnamed_addr align 2 { 72 %2 = alloca %struct.Q*, align 8 73 store %struct.Q* %0, %struct.Q** %2, align 8 74 %3 = load %struct.Q*, %struct.Q** %2, align 8 75 %4 = getelementptr inbounds %struct.Q, %struct.Q* %3, i32 0, i32 0 76 %5 = call i32 bitcast (i32 (i32)* @_ZL3baz3Foo to i32 (%struct.Foo*)*)(%struct.Foo* getelementptr (%struct.Foo, %struct.Foo *null, i32 1)) 77 store i32 %5, i32* %4, align 4 78 ret void 79} 80 81define internal i32 @_ZL3baz3Foo(i32) { 82 %2 = alloca %struct.Foo, align 4 83 %3 = getelementptr inbounds %struct.Foo, %struct.Foo* %2, i32 0, i32 0 84 store i32 %0, i32* %3, align 4 85 %4 = getelementptr inbounds %struct.Foo, %struct.Foo* %2, i32 0, i32 0 86 %5 = load i32, i32* %4, align 4 87 ret i32 %5 88} 89 90; Function Attrs: noinline ssp uwtable 91define internal void @_GLOBAL__sub_I_main2.cpp() section "__TEXT,__StaticInit,regular,pure_instructions" { 92 call void @__cxx_global_var_init() 93 ret void 94} 95 96define internal void @_GLOBAL__sub_I_main3.cpp() section "__TEXT,__StaticInit,regular,pure_instructions" { 97 call void @__cxx_global_var_init.1() 98 ret void 99} 100