[PATCH] D19211: Teach ValueTracking that compare-and-branch on poison is UB

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 17 23:43:40 PDT 2016


majnemer added inline comments.

================
Comment at: lib/Analysis/ValueTracking.cpp:3413-3416
@@ -3407,1 +3412,6 @@
 
+    case Instruction::Br:
+      if (cast<BranchInst>(I)->isConditional())
+        return cast<BranchInst>(I)->getCondition();
+      return nullptr;
+
----------------
Our langref states:
> An instruction control-depends on a terminator instruction if the terminator instruction has multiple successors and the instruction is always executed when control transfers to one of the successors, and may not be executed when control is transferred to another.

The code, as written, sounds like it will do the wrong thing if the branch instruction branches to the same basic block regardless of the condition operand.  Maybe this is just a bug in the langref?  Equally possible is that I misunderstand the behavior that this function is trying to suss out.


http://reviews.llvm.org/D19211





More information about the llvm-commits mailing list