[llvm] [SimpleLoopUnswitch] Record loops from unswitching non-trivial conditions (PR #141121)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Fri May 23 08:23:09 PDT 2025


================
@@ -2142,34 +2142,33 @@ void visitDomSubTree(DominatorTree &DT, BasicBlock *BB, CallableT Callable) {
 void postUnswitch(Loop &L, LPMUpdater &U, StringRef LoopName,
                   bool CurrentLoopValid, bool PartiallyInvariant,
                   bool InjectedCondition, ArrayRef<Loop *> NewLoops) {
-  // If we did a non-trivial unswitch, we have added new (cloned) loops.
-  if (!NewLoops.empty())
+  auto RecordLoopAsUnswitched = [&](Loop *TargetLoop, StringRef Tag) {
+    auto &Ctx = TargetLoop->getHeader()->getContext();
+    const auto &DisableMDName = (Twine(Tag) + ".disable").str();
----------------
antoniofrighetto wrote:

Yeah, the temporary `std::string`, being bound to a `const std::string&` (which extends its lifetime), was a tradeoff in favour of reducing verbosity. Switched to passing `StringRef` as parameter.

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


More information about the llvm-commits mailing list