llvm.org GIT mirror llvm / 54d8b1a
Merging r328748: ------------------------------------------------------------------------ r328748 | gbiv | 2018-03-28 17:54:39 -0700 (Wed, 28 Mar 2018) | 12 lines [MemorySSA] Consider callsite args for hashing and equality. We use a `DenseMap<MemoryLocOrCall, MemlocStackInfo>` to keep track of prior work when optimizing uses in MemorySSA. Because we weren't accounting for callsite arguments in either the hash code or equality tests for `MemoryLocOrCall`s, we optimized uses too aggressively in some rare cases. Fix by Daniel Berlin. Should fix PR36883. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@329663 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 2 years ago
2 changed file(s) with 58 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
152152 if (IsCall != Other.IsCall)
153153 return false;
154154
155 if (IsCall)
156 return CS.getCalledValue() == Other.CS.getCalledValue();
157 return Loc == Other.Loc;
155 if (!IsCall)
156 return Loc == Other.Loc;
157
158 if (CS.getCalledValue() != Other.CS.getCalledValue())
159 return false;
160
161 assert(CS.arg_size() == Other.CS.arg_size());
162 return std::equal(CS.arg_begin(), CS.arg_end(), Other.CS.arg_begin());
158163 }
159164
160165 private:
178183 }
179184
180185 static unsigned getHashValue(const MemoryLocOrCall &MLOC) {
181 if (MLOC.IsCall)
182 return hash_combine(MLOC.IsCall,
183 DenseMapInfo::getHashValue(
184 MLOC.getCS().getCalledValue()));
185 return hash_combine(
186 MLOC.IsCall, DenseMapInfo::getHashValue(MLOC.getLoc()));
186 if (!MLOC.IsCall)
187 return hash_combine(
188 MLOC.IsCall,
189 DenseMapInfo::getHashValue(MLOC.getLoc()));
190
191 hash_code hash =
192 hash_combine(MLOC.IsCall, DenseMapInfo::getHashValue(
193 MLOC.getCS().getCalledValue()));
194
195 for (const Value *Arg : MLOC.getCS().args())
196 hash = hash_combine(hash, DenseMapInfo::getHashValue(Arg));
197 return hash;
187198 }
188199
189200 static bool isEqual(const MemoryLocOrCall &LHS, const MemoryLocOrCall &RHS) {
0 ; RUN: opt -basicaa -memoryssa -analyze < %s 2>&1 -S | FileCheck %s
1 ; RUN: opt -aa-pipeline=basic-aa -passes='print,verify' -S < %s 2>&1 | FileCheck %s
2 ;
3 ; We weren't properly considering the args in callsites in equality or hashing.
4
5 target triple = "armv7-dcg-linux-gnueabi"
6
7 ; CHECK-LABEL: define <8 x i16> @vpx_idct32_32_neon
8 define <8 x i16> @vpx_idct32_32_neon(i8* %p, <8 x i16> %v) {
9 entry:
10 ; CHECK: MemoryUse(liveOnEntry)
11 %load1 = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0i8(i8* %p, i32 2) #4 ; load CSE replacement
12
13 ; CHECK: 1 = MemoryDef(liveOnEntry)
14 call void @llvm.arm.neon.vst1.p0i8.v8i16(i8* %p, <8 x i16> %v, i32 2) #4 ; clobber
15
16 %p_next = getelementptr inbounds i8, i8* %p, i32 16
17 ; CHECK: MemoryUse(liveOnEntry)
18 %load2 = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0i8(i8* %p_next, i32 2) #4 ; non-aliasing load needed to trigger bug
19
20 ; CHECK: MemoryUse(1)
21 %load3 = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0i8(i8* %p, i32 2) #4 ; load CSE removed
22
23 %add = add <8 x i16> %load1, %load2
24 %ret = add <8 x i16> %add, %load3
25 ret <8 x i16> %ret
26 }
27
28 ; Function Attrs: argmemonly nounwind readonly
29 declare <8 x i16> @llvm.arm.neon.vld1.v8i16.p0i8(i8*, i32) #2
30
31 ; Function Attrs: argmemonly nounwind
32 declare void @llvm.arm.neon.vst1.p0i8.v8i16(i8*, <8 x i16>, i32) #1
33
34 attributes #1 = { argmemonly nounwind }
35 attributes #2 = { argmemonly nounwind readonly }
36 attributes #3 = { nounwind readnone }
37 attributes #4 = { nounwind }