llvm.org GIT mirror llvm / a21ce6e
[LAA] Re-check bit-width of pointers after stripping. Summary: - As the pointer stripping now tracks through `addrspacecast`, prepare to handle the bit-width difference from the result pointer. Reviewers: jdoerfert Subscribers: jvesely, nhaehnle, hiraditya, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64928 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366470 91177308-0d34-0410-b5e6-96231b3b80d8 Michael Liao a month ago
2 changed file(s) with 27 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
11881188
11891189 unsigned IdxWidth = DL.getIndexSizeInBits(ASA);
11901190 Type *Ty = cast(PtrA->getType())->getElementType();
1191 APInt Size(IdxWidth, DL.getTypeStoreSize(Ty));
11921191
11931192 APInt OffsetA(IdxWidth, 0), OffsetB(IdxWidth, 0);
11941193 PtrA = PtrA->stripAndAccumulateInBoundsConstantOffsets(DL, OffsetA);
11951194 PtrB = PtrB->stripAndAccumulateInBoundsConstantOffsets(DL, OffsetB);
1195
1196 // Retrieve the address space again as pointer stripping now tracks through
1197 // `addrspacecast`.
1198 ASA = cast(PtrA->getType())->getAddressSpace();
1199 ASB = cast(PtrB->getType())->getAddressSpace();
1200 // Check that the address spaces match and that the pointers are valid.
1201 if (ASA != ASB)
1202 return false;
1203
1204 IdxWidth = DL.getIndexSizeInBits(ASA);
1205 OffsetA = OffsetA.sextOrTrunc(IdxWidth);
1206 OffsetB = OffsetB.sextOrTrunc(IdxWidth);
1207
1208 APInt Size(IdxWidth, DL.getTypeStoreSize(Ty));
11961209
11971210 // OffsetDelta = OffsetB - OffsetA;
11981211 const SCEV *OffsetSCEVA = SE.getConstant(OffsetA);
146146 store i32 %sub1, i32* undef
147147 ret void
148148 }
149
150 ; CHECK-LABEL: slp_crash_on_addrspacecast
151 ; CHECK: ret void
152 define void @slp_crash_on_addrspacecast() {
153 entry:
154 %0 = getelementptr inbounds i64, i64 addrspace(3)* undef, i32 undef
155 %p0 = addrspacecast i64 addrspace(3)* %0 to i64*
156 store i64 undef, i64* %p0, align 8
157 %1 = getelementptr inbounds i64, i64 addrspace(3)* undef, i32 undef
158 %p1 = addrspacecast i64 addrspace(3)* %1 to i64*
159 store i64 undef, i64* %p1, align 8
160 ret void
161 }