summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-06-19 23:42:17 +0000
committerVedant Kumar <vsk@apple.com>2018-06-19 23:42:17 +0000
commitf01827f2d1bdaff14cf1cf176e8a69e308d5371e (patch)
treedefc86236f3ff9e5193b677abc6606f4cc4deba9 /llvm/lib/Transforms
parent3d7f00d25bb56b13e4c39f4406e2efa8d9e7a886 (diff)
downloadbcm5719-llvm-f01827f2d1bdaff14cf1cf176e8a69e308d5371e.tar.gz
bcm5719-llvm-f01827f2d1bdaff14cf1cf176e8a69e308d5371e.zip
[IR] Introduce helpers to skip debug instructions (NFC)
This patch introduces two helpers to make it easier to ignore debug intrinsics: - Instruction::getNextNonDebugInstruction() This is just like Instruction::getNextNode(), except that it skips debug info. - skipDebugInfo(BasicBlock::iterator) A free function which advances a BasicBlock iterator past any debug info. This is a no-op when the iterator already points to a non-debug instruction. Part of: llvm.org/PR37728 Related to: https://reviews.llvm.org/D47874 Differential Revision: https://reviews.llvm.org/D48305 llvm-svn: 335083
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 9e046c9e3a6..3dde762dbcc 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3614,13 +3614,8 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// happen when variable allocas are DCE'd.
if (IntrinsicInst *SS = dyn_cast<IntrinsicInst>(II->getArgOperand(0))) {
if (SS->getIntrinsicID() == Intrinsic::stacksave) {
- // Skip over debug info instructions.
- // FIXME: This should be an utility in Instruction.h
- auto It = SS->getIterator();
- It++;
- while (isa<DbgInfoIntrinsic>(*It))
- It++;
- if (&*It == II) {
+ // Skip over debug info.
+ if (SS->getNextNonDebugInstruction() == II) {
return eraseInstFromFunction(CI);
}
}
@@ -3804,10 +3799,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Fence instruction simplification
Instruction *InstCombiner::visitFenceInst(FenceInst &FI) {
// Remove identical consecutive fences.
- Instruction *Next = FI.getNextNode();
- while (Next != nullptr && isa<DbgInfoIntrinsic>(Next))
- Next = Next->getNextNode();
-
+ Instruction *Next = FI.getNextNonDebugInstruction();
if (auto *NFI = dyn_cast<FenceInst>(Next))
if (FI.isIdenticalTo(NFI))
return eraseInstFromFunction(FI);
OpenPOWER on IntegriCloud