[llvm] ac64d0d - [NFC][CodeGen] Remove redundant if clause in TargetPassConfig::addPass

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 16 07:14:44 PDT 2022


Author: Shengchen Kan
Date: 2022-03-16T22:14:23+08:00
New Revision: ac64d0d23044acee63672df8ce7f56587c1d0df0

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

LOG: [NFC][CodeGen] Remove redundant if clause in TargetPassConfig::addPass

Added: 
    

Modified: 
    llvm/lib/CodeGen/TargetPassConfig.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp
index 4ced80f496d1b..4ccb96d49e0ad 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -735,21 +735,21 @@ void TargetPassConfig::addPass(Pass *P) {
   if (StopBefore == PassID && StopBeforeCount++ == StopBeforeInstanceNum)
     Stopped = true;
   if (Started && !Stopped) {
-    if (AddingMachinePasses)
+    if (AddingMachinePasses) {
+      // Construct banner message before PM->add() as that may delete the pass.
+      std::string Banner =
+          std::string("After ") + std::string(P->getPassName());
       addMachinePrePasses();
-    std::string Banner;
-    // Construct banner message before PM->add() as that may delete the pass.
-    if (AddingMachinePasses)
-      Banner = std::string("After ") + std::string(P->getPassName());
-    PM->add(P);
-    if (AddingMachinePasses)
+      PM->add(P);
       addMachinePostPasses(Banner);
+    } else {
+      PM->add(P);
+    }
 
     // Add the passes after the pass P if there is any.
-    for (const auto &IP : Impl->InsertedPasses) {
+    for (const auto &IP : Impl->InsertedPasses)
       if (IP.TargetPassID == PassID)
         addPass(IP.getInsertedPass());
-    }
   } else {
     delete P;
   }


        


More information about the llvm-commits mailing list