[SimplifyCFG] Teach eliminateDeadSwitchCases() to preserve DomTree, part 2
authorRoman Lebedev <lebedev.ri@gmail.com>
Fri, 1 Jan 2021 13:37:55 +0000 (16:37 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Fri, 1 Jan 2021 22:01:18 +0000 (01:01 +0300)
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/switch-dead-default.ll

index 30e3f0b..37e594d 100644 (file)
@@ -4990,7 +4990,7 @@ static bool eliminateDeadSwitchCases(SwitchInst *SI, DomTreeUpdater *DTU,
   if (HasDefault && DeadCases.empty() &&
       NumUnknownBits < 64 /* avoid overflow */ &&
       SI->getNumCases() == (1ULL << NumUnknownBits)) {
-    createUnreachableSwitchDefault(SI, /*DTU=*/nullptr);
+    createUnreachableSwitchDefault(SI, DTU);
     return true;
   }
 
index 2ce04ec..9756965 100644 (file)
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt %s -S -passes='simplify-cfg<switch-to-lookup>' | FileCheck %s
+; RUN: opt %s -S -passes='simplify-cfg<switch-to-lookup>' -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s
+
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 declare void @foo(i32)