[llvm] AArch64: Use AsmPrinter's MachineFunction in lowerSymbolOperandELF (PR #219475)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 28 06:39:13 PDT 2026


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/219475

lowerSymbolOperandELF walked MO.getParent()->getParent()->getParent() to reach
the MachineFunction. The AsmPrinter already holds the function currently being
lowered, so use Printer.MF directly and drop the dependence on
MachineOperand::getParent().

Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>

>From 712af3084ad21894ddd6e4bc80d6892504da82e1 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 28 Aug 2026 05:23:28 +0200
Subject: [PATCH] AArch64: Use AsmPrinter's MachineFunction in
 lowerSymbolOperandELF

lowerSymbolOperandELF walked MO.getParent()->getParent()->getParent() to reach
the MachineFunction. The AsmPrinter already holds the function currently being
lowered, so use Printer.MF directly and drop the dependence on
MachineOperand::getParent().

Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
---
 llvm/lib/Target/AArch64/AArch64MCInstLower.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
index d3a38624488e8..8a263b266e6ee 100644
--- a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
+++ b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
@@ -184,14 +184,14 @@ MCOperand AArch64MCInstLower::lowerSymbolOperandELF(const MachineOperand &MO,
   uint32_t RefFlags = 0;
 
   if (MO.getTargetFlags() & AArch64II::MO_GOT) {
-    const MachineFunction *MF = MO.getParent()->getParent()->getParent();
+    const MachineFunction *MF = Printer.MF;
     RefFlags |= (MF->getInfo<AArch64FunctionInfo>()->hasELFSignedGOT()
                      ? AArch64::S_GOT_AUTH
                      : AArch64::S_GOT);
   } else if (MO.getTargetFlags() & AArch64II::MO_TLS) {
     TLSModel::Model Model;
     if (MO.isGlobal()) {
-      const MachineFunction *MF = MO.getParent()->getParent()->getParent();
+      const MachineFunction *MF = Printer.MF;
       if (MF->getInfo<AArch64FunctionInfo>()->hasELFSignedGOT()) {
         Model = TLSModel::GeneralDynamic;
       } else {
@@ -224,7 +224,7 @@ MCOperand AArch64MCInstLower::lowerSymbolOperandELF(const MachineOperand &MO,
       // running hasELFSignedGOT() every time, but existing flags already
       // cover all 12 bits of SubReg_TargetFlags field in MachineOperand, and
       // making the field wider breaks static assertions.
-      const MachineFunction *MF = MO.getParent()->getParent()->getParent();
+      const MachineFunction *MF = Printer.MF;
       RefFlags |= MF->getInfo<AArch64FunctionInfo>()->hasELFSignedGOT()
                       ? AArch64::S_TLSDESC_AUTH
                       : AArch64::S_TLSDESC;



More information about the llvm-commits mailing list