forked from OSchip/llvm-project
[InferAddressSpaces] Fix crash on select of non-ptr operands
Check the operands of a select are pointers, to determine if it is an address expression or not. https://reviews.llvm.org/D58226 llvm-svn: 354576
This commit is contained in:
parent
e6b338cbef
commit
92af1360f3
|
@ -217,13 +217,16 @@ static bool isAddressExpression(const Value &V) {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -168,6 +168,15 @@ exit: ; preds = %loop
|
|||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue