[llvm] r252343 - [InstCombine] Don't RAUW tokens with undef

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 6 13:26:32 PST 2015


Author: majnemer
Date: Fri Nov  6 15:26:32 2015
New Revision: 252343

URL: http://llvm.org/viewvc/llvm-project?rev=252343&view=rev
Log:
[InstCombine] Don't RAUW tokens with undef

Let SimplifyCFG remove unreachable BBs which define token instructions.

Added:
    llvm/trunk/test/Transforms/InstCombine/token.ll
Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=252343&r1=252342&r2=252343&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Fri Nov  6 15:26:32 2015
@@ -3012,7 +3012,7 @@ static bool prepareICWorklistFromFunctio
     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 prepareICWorklistFromFunctio
         ++NumDeadInst;
         MadeIRChange = true;
       }
-      Inst->eraseFromParent();
+      if (!Inst->getType()->isTokenTy())
+        Inst->eraseFromParent();
     }
   }
 

Added: llvm/trunk/test/Transforms/InstCombine/token.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/token.ll?rev=252343&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/token.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/token.ll Fri Nov  6 15:26:32 2015
@@ -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*)




More information about the llvm-commits mailing list