llvm.org GIT mirror llvm / 9585c54
[PHITransAddr] Don't assume that instruction operands are translatable We can only PHI translate instructions. In our attempt to PHI translate a bitcast, we attempt to translate its operand; however, the operand might be an argument or a global instead of an instruction. Benignly bail out when this happens. This fixes PR24397. Differential Revision: http://reviews.llvm.org/D11879 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244418 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 4 years ago
2 changed file(s) with 22 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
373373 if (!Tmp.PHITranslateValue(CurBB, PredBB, &DT, /*MustDominate=*/true))
374374 return Tmp.getAddr();
375375
376 // If we don't have an available version of this value, it must be an
377 // instruction.
378 Instruction *Inst = cast(InVal);
376 // We don't need to PHI translate values which aren't instructions.
377 auto *Inst = dyn_cast(InVal);
378 if (!Inst)
379 return nullptr;
379380
380381 // Handle cast of PHI translatable value.
381382 if (CastInst *Cast = dyn_cast(Inst)) {
0 ; RUN: opt -basicaa -gvn -disable-output < %s
1
2 target triple = "x86_64-unknown-linux-gnu"
3
4 define i64 @foo(i64** %arrayidx) {
5 entry:
6 %p = load i64*, i64** %arrayidx, align 8
7 %cmpnull = icmp eq i64* %p, null
8 br label %BB2
9
10 entry2: ; No predecessors!
11 br label %BB2
12
13 BB2: ; preds = %entry2, %entry
14 %bc = bitcast i64** %arrayidx to i64*
15 %load = load i64, i64* %bc, align 8
16 ret i64 %load
17 }