diff --git a/llvm/lib/Target/AArch64/AArch64ConditionOptimizer.cpp b/llvm/lib/Target/AArch64/AArch64ConditionOptimizer.cpp --- a/llvm/lib/Target/AArch64/AArch64ConditionOptimizer.cpp +++ b/llvm/lib/Target/AArch64/AArch64ConditionOptimizer.cpp @@ -159,7 +159,7 @@ // Now find the instruction controlling the terminator. for (MachineBasicBlock::iterator B = MBB->begin(); I != B;) { - --I; + I = prev_nodbg(I, MBB->begin()); assert(!I->isTerminator() && "Spurious terminator"); // Check if there is any use of NZCV between CMP and Bcc. if (I->readsRegister(AArch64::NZCV)) @@ -179,7 +179,7 @@ LLVM_DEBUG(dbgs() << "Immediate of cmp may be out of range, " << *I << '\n'); return nullptr; - } else if (!MRI->use_empty(I->getOperand(0).getReg())) { + } else if (!MRI->use_nodbg_empty(I->getOperand(0).getReg())) { LLVM_DEBUG(dbgs() << "Destination of cmp is not dead, " << *I << '\n'); return nullptr; } diff --git a/llvm/test/CodeGen/AArch64/combine-comparisons-by-cse.ll b/llvm/test/CodeGen/AArch64/combine-comparisons-by-cse.ll --- a/llvm/test/CodeGen/AArch64/combine-comparisons-by-cse.ll +++ b/llvm/test/CodeGen/AArch64/combine-comparisons-by-cse.ll @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=aarch64-linux-gnu | FileCheck %s +; RUN: llc -debugify-and-strip-all-safe < %s -mtriple=aarch64-linux-gnu | FileCheck %s ; marked as external to prevent possible optimizations @a = external global i32