[PATCH] D58226: [InferAddressSpaces] Prevent crash on nested ConstantExpr
Joey Gouly via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 19 07:53:17 PST 2019
joey updated this revision to Diff 187372.
joey added a comment.
Add the changes to `isAddExpression` instead.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58226/new/
https://reviews.llvm.org/D58226
Files:
lib/Transforms/Scalar/InferAddressSpaces.cpp
test/Transforms/InferAddressSpaces/AMDGPU/infer-address-space.ll
Index: test/Transforms/InferAddressSpaces/AMDGPU/infer-address-space.ll
===================================================================
--- test/Transforms/InferAddressSpaces/AMDGPU/infer-address-space.ll
+++ test/Transforms/InferAddressSpaces/AMDGPU/infer-address-space.ll
@@ -168,6 +168,15 @@
ret void
}
+; CHECK-LABEL: @select_bug(
+; CHECK: %add.ptr157 = getelementptr inbounds i64, i64* undef, i64 select (i1 icmp ne (i32* inttoptr (i64 4873 to i32*), i32* null), i64 73, i64 93)
+; CHECK: %cmp169 = icmp uge i64* undef, %add.ptr157
+define void @select_bug() #0 {
+ %add.ptr157 = getelementptr inbounds i64, i64* undef, i64 select (i1 icmp ne (i32* inttoptr (i64 4873 to i32*), i32* null), i64 73, i64 93)
+ %cmp169 = icmp uge i64* undef, %add.ptr157
+ unreachable
+}
+
declare void @llvm.amdgcn.s.barrier() #1
declare void @use(float) #0
Index: lib/Transforms/Scalar/InferAddressSpaces.cpp
===================================================================
--- lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -217,13 +217,16 @@
if (!isa<Operator>(V))
return false;
- switch (cast<Operator>(V).getOpcode()) {
+ const Operator &Op = cast<Operator>(V);
+ switch (Op.getOpcode()) {
case Instruction::PHI:
+ assert(Op.getType()->isPointerTy());
case Instruction::BitCast:
case Instruction::AddrSpaceCast:
case Instruction::GetElementPtr:
- case Instruction::Select:
return true;
+ case Instruction::Select:
+ return Op.getType()->isPointerTy();
default:
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58226.187372.patch
Type: text/x-patch
Size: 1588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190219/407940db/attachment.bin>
More information about the llvm-commits
mailing list