From 58b8aca452b9665cfea6f6f6d5e18b7b494cc536 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 4 Mar 2025 07:35:45 -0800 Subject: [PATCH] [BPF] Avoid repeated map lookups (NFC) --- llvm/lib/Target/BPF/BTFDebug.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp index 1a9ee3128e20d..c58b61f628881 100644 --- a/llvm/lib/Target/BPF/BTFDebug.cpp +++ b/llvm/lib/Target/BPF/BTFDebug.cpp @@ -1542,17 +1542,12 @@ bool BTFDebug::InstLower(const MachineInstr *MI, MCInst &OutMI) { const GlobalValue *GVal = MO.getGlobal(); auto *GVar = dyn_cast(GVal); if (GVar) { - // Emit "mov ri, " - int64_t Imm; - uint32_t Reloc; - if (GVar->hasAttribute(BPFCoreSharedInfo::AmaAttr) || - GVar->hasAttribute(BPFCoreSharedInfo::TypeIdAttr)) { - Imm = PatchImms[GVar].first; - Reloc = PatchImms[GVar].second; - } else { + if (!GVar->hasAttribute(BPFCoreSharedInfo::AmaAttr) && + !GVar->hasAttribute(BPFCoreSharedInfo::TypeIdAttr)) return false; - } + // Emit "mov ri, " + auto [Imm, Reloc] = PatchImms[GVar]; if (Reloc == BTF::ENUM_VALUE_EXISTENCE || Reloc == BTF::ENUM_VALUE || Reloc == BTF::BTF_TYPE_ID_LOCAL || Reloc == BTF::BTF_TYPE_ID_REMOTE) OutMI.setOpcode(BPF::LD_imm64);