Skip to content

Commit

Permalink
[InstCombine] Fix call guard difference with dbg
Browse files Browse the repository at this point in the history
Patch by Chris Ye!

Differential Revision: https://reviews.llvm.org/D68004
  • Loading branch information
Davide Italiano committed Nov 22, 2019
1 parent ae8a8c2 commit c32f0ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4060,12 +4060,12 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Is this guard followed by another guard? We scan forward over a small
// fixed window of instructions to handle common cases with conditions
// computed between guards.
Instruction *NextInst = II->getNextNode();
Instruction *NextInst = II->getNextNonDebugInstruction();
for (unsigned i = 0; i < GuardWideningWindow; i++) {
// Note: Using context-free form to avoid compile time blow up
if (!isSafeToSpeculativelyExecute(NextInst))
break;
NextInst = NextInst->getNextNode();
NextInst = NextInst->getNextNonDebugInstruction();
}
Value *NextCond = nullptr;
if (match(NextInst,
Expand All @@ -4077,10 +4077,10 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
return eraseInstFromFunction(*NextInst);

// Otherwise canonicalize guard(a); guard(b) -> guard(a & b).
Instruction* MoveI = II->getNextNode();
Instruction *MoveI = II->getNextNonDebugInstruction();
while (MoveI != NextInst) {
auto *Temp = MoveI;
MoveI = MoveI->getNextNode();
MoveI = MoveI->getNextNonDebugInstruction();
Temp->moveBefore(II);
}
II->setArgOperand(0, Builder.CreateAnd(CurrCond, NextCond));
Expand Down
1 change: 1 addition & 0 deletions llvm/test/Transforms/InstCombine/call-guard.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
; RUN: opt < %s -instcombine -S -debugify-each | FileCheck %s

declare void @llvm.experimental.guard(i1, ...)

Expand Down

0 comments on commit c32f0ff

Please sign in to comment.