llvm.org GIT mirror llvm / 0f7ea1a
Fix an issue where GVN would try to use an instruction before its definition when performing return slot optimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47541 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 12 years ago
3 changed file(s) with 33 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
10981098 !CS.paramHasAttr(1, ParamAttr::NoAlias | ParamAttr::StructRet))
10991099 return false;
11001100
1101 // Since we're changing the parameter to the callsite, we need to make sure
1102 // that what would be the new parameter dominates the callsite.
1103 DominatorTree& DT = getAnalysis();
1104 if (Instruction* cpyDestInst = dyn_cast(cpyDest))
1105 if (!DT.dominates(cpyDestInst, C))
1106 return false;
1107
11011108 // Check that something sneaky is not happening involving casting
11021109 // return slot types around.
11031110 if (CS.getArgument(0)->getType() != cpyDest->getType())
0 ; RUN: llvm-as < %s | opt -gvn -dse | llvm-dis | grep {call.*memcpy} | count 1
1
2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
3 target triple = "x86_64-apple-darwin8"
4 %struct.ggFrame3 = type { %struct.ggPoint3, %struct.ggONB3 }
5 %struct.ggHMatrix3 = type { [4 x [4 x double]] }
6 %struct.ggONB3 = type { %struct.ggPoint3, %struct.ggPoint3, %struct.ggPoint3 }
7 %struct.ggPoint3 = type { [3 x double] }
8 %struct.ggQuaternion = type { [4 x double], i32, %struct.ggHMatrix3 }
9
10 declare void @llvm.memcpy.i64(i8*, i8*, i64, i32) nounwind
11
12 define void @_Z10ggCRSplineRK8ggFrame3S1_S1_S1_d(%struct.ggFrame3* noalias sret %agg.result, %struct.ggFrame3* %f0, %struct.ggFrame3* %f1, %struct.ggFrame3* %f2, %struct.ggFrame3* %f3, double %t) nounwind {
13 entry:
14 %qresult = alloca %struct.ggQuaternion ; <%struct.ggQuaternion*> [#uses=1]
15 %tmp = alloca %struct.ggONB3 ; <%struct.ggONB3*> [#uses=2]
16 call void @_ZN12ggQuaternion7getONB3Ev( %struct.ggONB3* noalias sret %tmp, %struct.ggQuaternion* %qresult ) nounwind
17 %tmp1.i = getelementptr %struct.ggFrame3* %agg.result, i32 0, i32 1 ; <%struct.ggONB3*> [#uses=1]
18 %tmp13.i = bitcast %struct.ggONB3* %tmp1.i to i8* ; [#uses=1]
19 %tmp24.i = bitcast %struct.ggONB3* %tmp to i8* ; [#uses=1]
20 call void @llvm.memcpy.i64( i8* %tmp13.i, i8* %tmp24.i, i64 72, i32 8 ) nounwind
21 ret void
22 }
23
24 declare void @_ZN12ggQuaternion7getONB3Ev(%struct.ggONB3* noalias sret , %struct.ggQuaternion*) nounwind
None ; RUN: llvm-as < %s | opt -gvn -dse | llvm-dis | grep memcpy | count 2
0 ; RUN: llvm-as < %s | opt -gvn -dse | llvm-dis | grep {call.*memcpy} | count 1
11
22 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"
33 target triple = "i686-apple-darwin9"