brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 366e91f Raw
70 lines · plain
1; Check the optimizer doesn't crash at inlining the function top and all of its callees are inlined.2; RUN: opt < %s -O3 -S | FileCheck %s3 4define dso_local ptr @second(ptr %p) {5entry:6  %p.addr = alloca ptr, align 87  store ptr %p, ptr %p.addr, align 88  %tmp = load ptr, ptr %p.addr, align 89  %tmp1 = load ptr, ptr %tmp, align 810  ret ptr %tmp111}12 13define dso_local void @top()  {14entry:15  ; CHECK: {{.*}} = {{.*}} call {{.*}} @ext16  ; CHECK-NOT: {{.*}} = {{.*}} call {{.*}} @third17  ; CHECK-NOT: {{.*}} = {{.*}} call {{.*}} @second18  ; CHECK-NOT: {{.*}} = {{.*}} call {{.*}} @wrapper19  %q = alloca ptr, align 820  store ptr @third, ptr %q, align 821  %tmp = call ptr @second(ptr %q)22  ; The call to 'wrapper' here is to ensure that its function attributes23  ; i.e., returning its parameter and having no side effect, will be decuded24  ; before the next round of inlining happens to 'top' to expose the bug.25  %call =  call ptr @wrapper(ptr %tmp) 26  ; The indirect call here is to confuse the alias analyzer so that27  ; an incomplete graph will be built during the first round of inlining.28  ; This allows the current function to be processed before the actual 29  ; callee, i.e., the function 'run', is processed. Once it's simplified to 30  ; a direct call, it also enables an additional round of inlining with all31  ; function attributes deduced. 32  call void (...) %call()33  ret void34}35 36define dso_local ptr @gen() {37entry:38  %call = call ptr (...) @ext()39  ret ptr %call40}41 42declare dso_local ptr @ext(...) 43 44define dso_local ptr @wrapper(ptr %fn) {45entry:46  ret ptr %fn47}48 49define dso_local void @run(ptr %fn) {50entry:51  %fn.addr = alloca ptr, align 852  %f = alloca ptr, align 853  store ptr %fn, ptr %fn.addr, align 854  %tmp = load ptr, ptr %fn.addr, align 855  %call = call ptr @wrapper(ptr %tmp)56  store ptr %call, ptr %f, align 857  %tmp1 = load ptr, ptr %f, align 858  call void (...) %tmp1()59  ret void60}61 62define dso_local void @third() {63entry:64  %f = alloca ptr, align 865  %call = call ptr @gen()66  store ptr %call, ptr %f, align 867  %tmp = load ptr, ptr %f, align 868  call void @run(ptr %tmp)69  ret void70}