[llvm-branch-commits] [llvm-branch] r195605 - Merging r195492:

Bill Wendling isanbard at gmail.com
Sun Nov 24 21:22:53 PST 2013


Author: void
Date: Sun Nov 24 23:22:53 2013
New Revision: 195605

URL: http://llvm.org/viewvc/llvm-project?rev=195605&view=rev
Log:
Merging r195492:
------------------------------------------------------------------------
r195492 | arsenm | 2013-11-22 11:24:37 -0800 (Fri, 22 Nov 2013) | 1 line

StructurizeCFG: Fix inverting a branch on an argument
------------------------------------------------------------------------

Added:
    llvm/branches/release_34/test/Transforms/StructurizeCFG/branch-on-argument.ll
      - copied unchanged from r195492, llvm/trunk/test/Transforms/StructurizeCFG/branch-on-argument.ll
Modified:
    llvm/branches/release_34/   (props changed)
    llvm/branches/release_34/lib/Transforms/Scalar/StructurizeCFG.cpp

Propchange: llvm/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 24 23:22:53 2013
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,195092-195094,195100,195102-195103,195118,195129,195138,195152,195156-195157,195161-195162,195193,195272,195317-195318,195333,195339,195355,195397-195399,195421,195423,195432,195439,195476-195477,195491,195567,195599
+/llvm/trunk:155241,195092-195094,195100,195102-195103,195118,195129,195138,195152,195156-195157,195161-195162,195193,195272,195317-195318,195333,195339,195355,195397-195399,195421,195423,195432,195439,195476-195477,195491-195492,195567,195599

Modified: llvm/branches/release_34/lib/Transforms/Scalar/StructurizeCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/Transforms/Scalar/StructurizeCFG.cpp?rev=195605&r1=195604&r2=195605&view=diff
==============================================================================
--- llvm/branches/release_34/lib/Transforms/Scalar/StructurizeCFG.cpp (original)
+++ llvm/branches/release_34/lib/Transforms/Scalar/StructurizeCFG.cpp Sun Nov 24 23:22:53 2013
@@ -323,21 +323,32 @@ Value *StructurizeCFG::invert(Value *Con
   if (match(Condition, m_Not(m_Value(Condition))))
     return Condition;
 
-  // Third: Check all the users for an invert
-  BasicBlock *Parent = cast<Instruction>(Condition)->getParent();
-  for (Value::use_iterator I = Condition->use_begin(),
-       E = Condition->use_end(); I != E; ++I) {
-
-    Instruction *User = dyn_cast<Instruction>(*I);
-    if (!User || User->getParent() != Parent)
-      continue;
+  if (Instruction *Inst = dyn_cast<Instruction>(Condition)) {
+    // Third: Check all the users for an invert
+    BasicBlock *Parent = Inst->getParent();
+    for (Value::use_iterator I = Condition->use_begin(),
+           E = Condition->use_end(); I != E; ++I) {
 
-    if (match(*I, m_Not(m_Specific(Condition))))
-      return *I;
+      Instruction *User = dyn_cast<Instruction>(*I);
+      if (!User || User->getParent() != Parent)
+        continue;
+
+      if (match(*I, m_Not(m_Specific(Condition))))
+        return *I;
+    }
+
+    // Last option: Create a new instruction
+    return BinaryOperator::CreateNot(Condition, "", Parent->getTerminator());
+  }
+
+  if (Argument *Arg = dyn_cast<Argument>(Condition)) {
+    BasicBlock &EntryBlock = Arg->getParent()->getEntryBlock();
+    return BinaryOperator::CreateNot(Condition,
+                                     Arg->getName() + ".inv",
+                                     EntryBlock.getTerminator());
   }
 
-  // Last option: Create a new instruction
-  return BinaryOperator::CreateNot(Condition, "", Parent->getTerminator());
+  llvm_unreachable("Unhandled condition to invert");
 }
 
 /// \brief Build the condition for one edge





More information about the llvm-branch-commits mailing list