[llvm] [SimplifyCFG] Replace unreachable switch lookup table holes with poison (PR #94990)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 17:00:44 PDT 2024


================
@@ -6281,8 +6282,15 @@ SwitchLookupTable::SwitchLookupTable(
     uint64_t Idx = (CaseVal->getValue() - Offset->getValue()).getLimitedValue();
     TableContents[Idx] = CaseRes;
 
-    if (CaseRes != SingleValue)
-      SingleValue = nullptr;
+    if (CaseRes != SingleValue) {
+      if (SingleValue && isa<PoisonValue>(SingleValue)) {
+        // All of the switch cases until now have returned poison; ignore them
+        // and use this value as the single constant value.
+        SingleValue = CaseRes;
+      } else if (!isa<PoisonValue>(CaseRes)) {
----------------
DianQK wrote:

Even though we're passing a poison value now, it just needs to be an undefined value here.
We can write the comment to treat `undef` as the same value.

https://github.com/llvm/llvm-project/pull/94990


More information about the llvm-commits mailing list