summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp5
-rw-r--r--llvm/test/Transforms/InstCombine/token.ll21
2 files changed, 24 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index ac535f97bb1..f024ab1795e 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -3012,7 +3012,7 @@ static bool prepareICWorklistFromFunction(Function &F, const DataLayout &DL,
while (EndInst != BB->begin()) {
// Delete the next to last instruction.
Instruction *Inst = &*--EndInst->getIterator();
- if (!Inst->use_empty())
+ if (!Inst->use_empty() && !Inst->getType()->isTokenTy())
Inst->replaceAllUsesWith(UndefValue::get(Inst->getType()));
if (Inst->isEHPad()) {
EndInst = Inst;
@@ -3022,7 +3022,8 @@ static bool prepareICWorklistFromFunction(Function &F, const DataLayout &DL,
++NumDeadInst;
MadeIRChange = true;
}
- Inst->eraseFromParent();
+ if (!Inst->getType()->isTokenTy())
+ Inst->eraseFromParent();
}
}
diff --git a/llvm/test/Transforms/InstCombine/token.ll b/llvm/test/Transforms/InstCombine/token.ll
new file mode 100644
index 00000000000..bb35d156064
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/token.ll
@@ -0,0 +1,21 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc18.0.0"
+
+declare i32 @__CxxFrameHandler3(...)
+
+define i8* @f() personality i32 (...)* @__CxxFrameHandler3 {
+bb:
+ unreachable
+
+unreachable:
+ %cl = cleanuppad []
+ cleanupret %cl unwind to caller
+}
+
+; CHECK: unreachable:
+; CHECK: %cl = cleanuppad []
+; CHECK: cleanupret %cl unwind to caller
+
+
+declare void @g(i8*)
OpenPOWER on IntegriCloud