1 ; RUN: opt < %s -basicaa -tailcallelim -inline -instcombine -dse -S | FileCheck %s 2 ; RUN: opt < %s -aa-pipeline=basic-aa -passes='function(tailcallelim),cgscc(inline,function(instcombine,dse))' -S | FileCheck %s 3 ; PR7272 4 5 ; Calls that capture byval parameters cannot be marked as tail calls. Other 6 ; tails that don't capture byval parameters can still be tail calls. 7 8 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" 9 target triple = "i386-pc-linux-gnu" 10 11 declare void @ext(i32*) 12 13 define void @bar(i32* byval %x) { 14 call void @ext(i32* %x) 15 ret void 16 } 17 18 define void @foo(i32* %x) { 19 ; CHECK-LABEL: define void @foo( 20 ; CHECK: llvm.lifetime.start 21 ; CHECK: store i32 %2, i32* %x 22 call void @bar(i32* byval %x) 23 ret void 24 } 25 26 define internal void @qux(i32* byval %x) { 27 call void @ext(i32* %x) 28 tail call void @ext(i32* null) 29 ret void 30 } 31 32 define void @frob(i32* %x) { 33 ; CHECK-LABEL: define void @frob( 34 ; CHECK: %[[POS:.*]] = alloca i32 35 ; CHECK: %[[VAL:.*]] = load i32, i32* %x 36 ; CHECK: store i32 %[[VAL]], i32* %[[POS]] 37 ; CHECK: {{^ *}}call void @ext(i32* nonnull %[[POS]] 38 ; CHECK: tail call void @ext(i32* null) 39 ; CHECK: ret void 40 tail call void @qux(i32* byval %x) 41 ret void 42 } 43