llvm.org GIT mirror llvm / c338499
Constant propagating byval pointer is safe if function is readonly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82700 91177308-0d34-0410-b5e6-96231b3b80d8 Torok Edwin 10 years ago
3 changed file(s) with 21 addition(s) and 5 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() ||
133 (AI->hasByValAttr() && isa(AI->getType())))
132 if (ArgumentConstants[i].second || AI->use_empty() ||
133 (AI->hasByValAttr() && !F.onlyReadsMemory()))
134134 continue;
135135
136136 Value *V = ArgumentConstants[i].first;
12661266 for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end();
12671267 AI != E; ++AI, ++CAI) {
12681268 LatticeVal &IV = ValueState[AI];
1269 if (AI->hasByValAttr() && isa(AI->getType())) {
1269 if (AI->hasByValAttr() && !F->onlyReadsMemory()) {
12701270 IV.markOverdefined();
12711271 continue;
12721272 }
1515 return: ; preds = %entry
1616 ret void
1717 }
18 define void @unions() nounwind {
18
19 define internal i32 @vfu2(%struct.MYstr* byval align 4 %u) nounwind readonly {
20 entry:
21 %0 = getelementptr %struct.MYstr* %u, i32 0, i32 1 ; [#uses=1]
22 %1 = load i32* %0
23 ; CHECK: load i32* getelementptr inbounds (%struct.MYstr* @mystr, i32 0, i32 1) ; [#uses=1]
24 %2 = getelementptr %struct.MYstr* %u, i32 0, i32 0 ; [#uses=1]
25 %3 = load i8* %2
26 ; CHECK: load i8* getelementptr inbounds (%struct.MYstr* @mystr, i32 0, i32 0) ; [#uses=1]
27 %4 = zext i8 %3 to i32
28 %5 = add i32 %4, %1
29 ret i32 %5
30 }
31
32 define i32 @unions() nounwind {
1933 entry:
2034 call void @vfu1(%struct.MYstr* byval align 4 @mystr) nounwind
21 ret void
35 %result = call i32 @vfu2(%struct.MYstr* byval align 4 @mystr) nounwind
36
37 ret i32 %result
2238 }
2339