llvm.org GIT mirror llvm / 2a46e93
Merging r293542: ------------------------------------------------------------------------ r293542 | arsenm | 2017-01-30 11:50:17 -0800 (Mon, 30 Jan 2017) | 7 lines LSR: Don't drop address space when type doesn't match For targets with different addressing modes in each address space, if this is dropped querying isLegalAddressingMode later with this will give a nonsense result, breaking the isLegalUse assertions. This is a candidate for the 4.0 release branch. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@293819 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 2 years ago
2 changed file(s) with 61 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
157157
158158 bool operator!=(MemAccessTy Other) const { return !(*this == Other); }
159159
160 static MemAccessTy getUnknown(LLVMContext &Ctx) {
161 return MemAccessTy(Type::getVoidTy(Ctx), UnknownAddressSpace);
160 static MemAccessTy getUnknown(LLVMContext &Ctx,
161 unsigned AS = UnknownAddressSpace) {
162 return MemAccessTy(Type::getVoidTy(Ctx), AS);
162163 }
163164 };
164165
22782279 // TODO: Be less conservative when the type is similar and can use the same
22792280 // addressing modes.
22802281 if (Kind == LSRUse::Address) {
2281 if (AccessTy != LU.AccessTy)
2282 NewAccessTy = MemAccessTy::getUnknown(AccessTy.MemTy->getContext());
2282 if (AccessTy.MemTy != LU.AccessTy.MemTy) {
2283 NewAccessTy = MemAccessTy::getUnknown(AccessTy.MemTy->getContext(),
2284 AccessTy.AddrSpace);
2285 }
22832286 }
22842287
22852288 // Conservatively assume HasBaseReg is true for now.
0 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -loop-reduce %s | FileCheck %s
1
2 ; Test for assert resulting from inconsistent isLegalAddressingMode
3 ; answers when the address space was dropped from the query.
4
5 target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p24:64:64-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
6
7 %0 = type { i32, double, i32, float }
8
9 ; CHECK-LABEL: @lsr_crash_preserve_addrspace_unknown_type(
10 ; CHECK: %tmp4 = bitcast %0 addrspace(3)* %tmp to double addrspace(3)*
11 ; CHECK: %scevgep5 = getelementptr double, double addrspace(3)* %tmp4, i32 1
12 ; CHEC: load double, double addrspace(3)* %scevgep5
13
14 ; CHECK: %scevgep = getelementptr i32, i32 addrspace(3)* %tmp1, i32 4
15 ; CHECK:%tmp14 = load i32, i32 addrspace(3)* %scevgep
16 define void @lsr_crash_preserve_addrspace_unknown_type() #0 {
17 bb:
18 br label %bb1
19
20 bb1: ; preds = %bb17, %bb
21 %tmp = phi %0 addrspace(3)* [ undef, %bb ], [ %tmp18, %bb17 ]
22 %tmp2 = getelementptr inbounds %0, %0 addrspace(3)* %tmp, i64 0, i32 1
23 %tmp3 = load double, double addrspace(3)* %tmp2, align 8
24 br label %bb4
25
26 bb4: ; preds = %bb1
27 br i1 undef, label %bb8, label %bb5
28
29 bb5: ; preds = %bb4
30 unreachable
31
32 bb8: ; preds = %bb4
33 %tmp9 = getelementptr inbounds %0, %0 addrspace(3)* %tmp, i64 0, i32 0
34 %tmp10 = load i32, i32 addrspace(3)* %tmp9, align 4
35 %tmp11 = icmp eq i32 0, %tmp10
36 br i1 %tmp11, label %bb12, label %bb17
37
38 bb12: ; preds = %bb8
39 %tmp13 = getelementptr inbounds %0, %0 addrspace(3)* %tmp, i64 0, i32 2
40 %tmp14 = load i32, i32 addrspace(3)* %tmp13, align 4
41 %tmp15 = icmp eq i32 0, %tmp14
42 br i1 %tmp15, label %bb16, label %bb17
43
44 bb16: ; preds = %bb12
45 unreachable
46
47 bb17: ; preds = %bb12, %bb8
48 %tmp18 = getelementptr inbounds %0, %0 addrspace(3)* %tmp, i64 2
49 br label %bb1
50 }
51
52 attributes #0 = { nounwind }
53 attributes #1 = { nounwind readnone }