llvm.org GIT mirror llvm / e07cc23
Merge from mainline (reg). Don't constant propagate byval pointers, since they are not really pointers, but rather structs passed by value. This fixes PR5038. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_26@83200 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 9 years ago
3 changed file(s) with 30 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
129129 Function::arg_iterator AI = F.arg_begin();
130130 for (unsigned i = 0, e = ArgumentConstants.size(); i != e; ++i, ++AI) {
131131 // Do we have a constant argument?
132 if (ArgumentConstants[i].second || AI->use_empty())
132 if (ArgumentConstants[i].second || AI->use_empty() ||
133 (AI->hasByValAttr() && isa(AI->getType())))
133134 continue;
134135
135136 Value *V = ArgumentConstants[i].first;
12621262 for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end();
12631263 AI != E; ++AI, ++CAI) {
12641264 LatticeVal &IV = ValueState[AI];
1265 if (AI->hasByValAttr() && isa(AI->getType())) {
1266 IV.markOverdefined();
1267 continue;
1268 }
12651269 if (!IV.isOverdefined())
12661270 mergeInValue(IV, AI, getValueState(*CAI));
12671271 }
0 ; RUN: llvm-as <%s | opt -ipsccp | llvm-dis | FileCheck %s
1 ; Don't constant-propagate byval pointers, since they are not pointers!
2 ; PR5038
3 %struct.MYstr = type { i8, i32 }
4 @mystr = internal global %struct.MYstr zeroinitializer ; <%struct.MYstr*> [#uses=3]
5 define internal void @vfu1(%struct.MYstr* byval align 4 %u) nounwind {
6 entry:
7 %0 = getelementptr %struct.MYstr* %u, i32 0, i32 1 ; [#uses=1]
8 store i32 99, i32* %0, align 4
9 ; CHECK: %struct.MYstr* %u
10 %1 = getelementptr %struct.MYstr* %u, i32 0, i32 0 ; [#uses=1]
11 store i8 97, i8* %1, align 4
12 ; CHECK: %struct.MYstr* %u
13 br label %return
14
15 return: ; preds = %entry
16 ret void
17 }
18 define void @unions() nounwind {
19 entry:
20 call void @vfu1(%struct.MYstr* byval align 4 @mystr) nounwind
21 ret void
22 }
23