[NFC] Use new canCreatePoison to make code intent more clear in PoisonChecking
authorPhilip Reames <listmail@philipreames.com>
Wed, 15 Apr 2020 19:34:48 +0000 (12:34 -0700)
committerPhilip Reames <listmail@philipreames.com>
Wed, 15 Apr 2020 21:48:53 +0000 (14:48 -0700)
llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp

index f25b057..a86d57a 100644 (file)
@@ -192,6 +192,8 @@ static Value* generatePoisonChecks(Instruction &I) {
   // Handle non-binops seperately
   switch (I.getOpcode()) {
   default:
+    // Note there are a couple of missing cases here, once implemented, this
+    // should become an llvm_unreachable.
     break;
   case Instruction::ExtractElement: {
     Value *Vec = I.getOperand(0);
@@ -296,8 +298,9 @@ static bool rewrite(Function &F) {
         for (Value *V : I.operands())
           Checks.push_back(getPoisonFor(ValToPoison, V));
 
-      if (auto *Check = generatePoisonChecks(I))
-        Checks.push_back(Check);
+      if (canCreatePoison(&I))
+        if (auto *Check = generatePoisonChecks(I))
+          Checks.push_back(Check);
       ValToPoison[&I] = buildOrChain(B, Checks);
     }