[llvm] 53fef0b - [NFCI][SimplifyCFG] simplifyUnreachable(): Use poison constant to represent the result of unreachable instrs

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 2 12:12:02 PDT 2021


Author: Roman Lebedev
Date: 2021-07-02T22:11:52+03:00
New Revision: 53fef0b2933a120b2ee876127c574002f8eb8c14

URL: https://github.com/llvm/llvm-project/commit/53fef0b2933a120b2ee876127c574002f8eb8c14
DIFF: https://github.com/llvm/llvm-project/commit/53fef0b2933a120b2ee876127c574002f8eb8c14.diff

LOG: [NFCI][SimplifyCFG] simplifyUnreachable(): Use poison constant to represent the result of unreachable instrs

Mimics similar change for InstCombine:
  ce192ced2b901be67444c481ab5ca0d731e6d982 / D104602

All these uses are in blocks that aren't reachable from function's entry,
and said blocks are removed by SimplifyCFG itself,
so we can't really test this change.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 8294a79a1c0a..b8f6bf930fc9 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4700,8 +4700,7 @@ bool SimplifyCFGOpt::simplifyUnreachable(UnreachableInst *UI) {
     }
 
     // Delete this instruction (any uses are guaranteed to be dead)
-    if (!BBI->use_empty())
-      BBI->replaceAllUsesWith(UndefValue::get(BBI->getType()));
+    BBI->replaceAllUsesWith(PoisonValue::get(BBI->getType()));
     BBI->eraseFromParent();
     Changed = true;
   }


        


More information about the llvm-commits mailing list