[llvm] 657c1e0 - [SimplifyCFG] Teach eliminateDeadSwitchCases() to preserve DomTree, part 2

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 1 14:01:55 PST 2021


Author: Roman Lebedev
Date: 2021-01-02T01:01:18+03:00
New Revision: 657c1e09da9fb5e63b963fe8eeace01e42e7d3ba

URL: https://github.com/llvm/llvm-project/commit/657c1e09da9fb5e63b963fe8eeace01e42e7d3ba
DIFF: https://github.com/llvm/llvm-project/commit/657c1e09da9fb5e63b963fe8eeace01e42e7d3ba.diff

LOG: [SimplifyCFG] Teach eliminateDeadSwitchCases() to preserve DomTree, part 2

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/test/Transforms/SimplifyCFG/switch-dead-default.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 30e3f0bc174c..37e594dbd1a4 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -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;
   }
 

diff  --git a/llvm/test/Transforms/SimplifyCFG/switch-dead-default.ll b/llvm/test/Transforms/SimplifyCFG/switch-dead-default.ll
index 2ce04ec85060..975696541799 100644
--- a/llvm/test/Transforms/SimplifyCFG/switch-dead-default.ll
+++ b/llvm/test/Transforms/SimplifyCFG/switch-dead-default.ll
@@ -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)
 


        


More information about the llvm-commits mailing list