llvm.org GIT mirror llvm / 21d31a8
Don't assume a tail call can't reference a byval argument to the outer function, this isn't correct. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49731 91177308-0d34-0410-b5e6-96231b3b80d8 Dale Johannesen 12 years ago
2 changed file(s) with 22 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
272272
273273 // If this is a tail call and P points to a stack location, we know that
274274 // the tail call cannot access or modify the local stack.
275 if (isa(Object) ||
276 (isa(Object) && cast(Object)->hasByValAttr()))
275 // We cannot exclude byval arguments here; these belong to the caller of
276 // the current function not to the current function, and a tail callee
277 // may reference them.
278 if (isa(Object))
277279 if (CallInst *CI = dyn_cast(CS.getInstruction()))
278280 if (CI->isTailCall())
279281 return NoModRef;
0 ; RUN: llvm-as < %s | opt -std-compile-opts | llvm-dis | grep store
1 ; ModuleID = 'small2.c'
2 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:128:128"
3 target triple = "i386-apple-darwin8"
4 %struct.x = type { [4 x i32] }
5
6 define void @foo(%struct.x* byval align 4 %X) nounwind {
7 entry:
8 %tmp = getelementptr %struct.x* %X, i32 0, i32 0 ; <[4 x i32]*> [#uses=1]
9 %tmp1 = getelementptr [4 x i32]* %tmp, i32 0, i32 3 ; [#uses=1]
10 store i32 2, i32* %tmp1, align 4
11 %tmp2 = call i32 (...)* @bar( %struct.x* byval align 4 %X ) nounwind ; [#uses=0]
12 br label %return
13 return: ; preds = %entry
14 ret void
15 }
16
17 declare i32 @bar(...)