[llvm] r363318 - Add a clarifying comment about branching on poison

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 12:27:56 PDT 2019


Author: reames
Date: Thu Jun 13 12:27:56 2019
New Revision: 363318

URL: http://llvm.org/viewvc/llvm-project?rev=363318&view=rev
Log:
Add a clarifying comment about branching on poison

I recently got this wrong (again), and I'm sure I'm not the only one.  Put a comment in the logical place someone would look to "fix" the obvious "missed optimization" which arrises based on the common misunderstanding.  Hopefully, this will save others time.  :)


Modified:
    llvm/trunk/lib/Analysis/ValueTracking.cpp

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=363318&r1=363317&r2=363318&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Thu Jun 13 12:27:56 2019
@@ -4388,6 +4388,10 @@ const Value *llvm::getGuaranteedNonFullP
       return I->getOperand(1);
 
     default:
+      // Note: It's really tempting to think that a conditional branch or
+      // switch should be listed here, but that's incorrect.  It's not
+      // branching off of poison which is UB, it is executing a side effecting
+      // instruction which follows the branch.  
       return nullptr;
   }
 }




More information about the llvm-commits mailing list