[llvm] 88736f5 - [BPF] Avoid repeated map lookups (NFC) (#129820)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 5 08:59:14 PST 2025
Author: Kazu Hirata
Date: 2025-03-05T08:59:10-08:00
New Revision: 88736f5944a004153e2c071fb6db68dd4d3773fd
URL: https://github.com/llvm/llvm-project/commit/88736f5944a004153e2c071fb6db68dd4d3773fd
DIFF: https://github.com/llvm/llvm-project/commit/88736f5944a004153e2c071fb6db68dd4d3773fd.diff
LOG: [BPF] Avoid repeated map lookups (NFC) (#129820)
Added:
Modified:
llvm/lib/Target/BPF/BTFDebug.cpp
Removed:
################################################################################
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<GlobalVariable>(GVal);
if (GVar) {
- // Emit "mov ri, <imm>"
- 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, <imm>"
+ 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);
More information about the llvm-commits
mailing list