[llvm] 03fde97 - [NFC] Refactor loop metadata movement

Nathan Sidwell via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 15:45:58 PDT 2023


Author: Nathan Sidwell
Date: 2023-05-09T18:43:59-04:00
New Revision: 03fde97d4933dac1c9481b9728420dbfe8b443d4

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

LOG: [NFC] Refactor loop metadata movement

* Use 'if (T v = expr)' idiom
* llvm.loop is a fixed metadata ID

Differential Revision: https://reviews.llvm.org/D150109

Reviewed By: kazu

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/Local.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 0f5d2ce841f19..5f89c0607aba5 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1223,12 +1223,10 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
 
   // If the unconditional branch we replaced contains llvm.loop metadata, we
   // add the metadata to the branch instructions in the predecessors.
-  unsigned LoopMDKind = BB->getContext().getMDKindID("llvm.loop");
-  Instruction *TI = BB->getTerminator();
-  if (TI)
-    if (MDNode *LoopMD = TI->getMetadata(LoopMDKind))
+  if (Instruction *TI = BB->getTerminator())
+    if (MDNode *LoopMD = TI->getMetadata(LLVMContext::MD_loop))
       for (BasicBlock *Pred : predecessors(BB))
-        Pred->getTerminator()->setMetadata(LoopMDKind, LoopMD);
+        Pred->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopMD);
 
   // Everything that jumped to BB now goes to Succ.
   BB->replaceAllUsesWith(Succ);


        


More information about the llvm-commits mailing list