[llvm] [MachineBlockPlacement][X86] Use max of MDAlign and TLIAlign to align Loops. (PR #71026)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 15 04:48:50 PST 2023
================
@@ -151,6 +151,54 @@ MachineLoopInfo::findLoopPreheader(MachineLoop *L, bool SpeculativePreheader,
return Preheader;
}
+MDNode *MachineLoop::getLoopID() const {
+ MDNode *LoopID = nullptr;
+ if (auto *MBB = findLoopControlBlock()) {
+ // If there is a single latch block, then the metadata
+ // node is attached to its terminating instruction.
+ const auto *BB = MBB->getBasicBlock();
+ if (!BB)
+ return nullptr;
+ if (const auto *TI = BB->getTerminator())
+ LoopID = TI->getMetadata(LLVMContext::MD_loop);
+ } else if (auto *MBB = getHeader()) {
+ // There seem to be multiple latch blocks, so we have to
+ // visit all predecessors of the loop header and check
+ // their terminating instructions for the metadata.
+ if (const auto *H = MBB->getBasicBlock()) {
+ // Walk over all blocks in the loop.
+ for (auto *MBB : this->blocks()) {
----------------
phoebewang wrote:
const?
https://github.com/llvm/llvm-project/pull/71026
More information about the llvm-commits
mailing list