forked from OSchip/llvm-project
[InstCombine] Fix call guard difference with dbg
Patch by Chris Ye! Differential Revision: https://reviews.llvm.org/D68004
This commit is contained in:
parent
ae8a8c2db6
commit
c32f0ff92f
|
@ -4060,12 +4060,12 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||||
// Is this guard followed by another guard? We scan forward over a small
|
// Is this guard followed by another guard? We scan forward over a small
|
||||||
// fixed window of instructions to handle common cases with conditions
|
// fixed window of instructions to handle common cases with conditions
|
||||||
// computed between guards.
|
// computed between guards.
|
||||||
Instruction *NextInst = II->getNextNode();
|
Instruction *NextInst = II->getNextNonDebugInstruction();
|
||||||
for (unsigned i = 0; i < GuardWideningWindow; i++) {
|
for (unsigned i = 0; i < GuardWideningWindow; i++) {
|
||||||
// Note: Using context-free form to avoid compile time blow up
|
// Note: Using context-free form to avoid compile time blow up
|
||||||
if (!isSafeToSpeculativelyExecute(NextInst))
|
if (!isSafeToSpeculativelyExecute(NextInst))
|
||||||
break;
|
break;
|
||||||
NextInst = NextInst->getNextNode();
|
NextInst = NextInst->getNextNonDebugInstruction();
|
||||||
}
|
}
|
||||||
Value *NextCond = nullptr;
|
Value *NextCond = nullptr;
|
||||||
if (match(NextInst,
|
if (match(NextInst,
|
||||||
|
@ -4077,10 +4077,10 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||||
return eraseInstFromFunction(*NextInst);
|
return eraseInstFromFunction(*NextInst);
|
||||||
|
|
||||||
// Otherwise canonicalize guard(a); guard(b) -> guard(a & b).
|
// Otherwise canonicalize guard(a); guard(b) -> guard(a & b).
|
||||||
Instruction* MoveI = II->getNextNode();
|
Instruction *MoveI = II->getNextNonDebugInstruction();
|
||||||
while (MoveI != NextInst) {
|
while (MoveI != NextInst) {
|
||||||
auto *Temp = MoveI;
|
auto *Temp = MoveI;
|
||||||
MoveI = MoveI->getNextNode();
|
MoveI = MoveI->getNextNonDebugInstruction();
|
||||||
Temp->moveBefore(II);
|
Temp->moveBefore(II);
|
||||||
}
|
}
|
||||||
II->setArgOperand(0, Builder.CreateAnd(CurrCond, NextCond));
|
II->setArgOperand(0, Builder.CreateAnd(CurrCond, NextCond));
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
; RUN: opt < %s -instcombine -S | FileCheck %s
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
||||||
|
; RUN: opt < %s -instcombine -S -debugify-each | FileCheck %s
|
||||||
|
|
||||||
declare void @llvm.experimental.guard(i1, ...)
|
declare void @llvm.experimental.guard(i1, ...)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue