[llvm] [BPF] Support Jump Table (PR #149715)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 07:52:31 PDT 2025


================
@@ -827,7 +850,15 @@ SDValue BPFTargetLowering::LowerGlobalAddress(SDValue Op,
   if (N->getOffset() != 0)
     report_fatal_error("invalid offset for global address: " +
                        Twine(N->getOffset()));
-  return getAddr(N, DAG);
+
+  const GlobalValue *GVal = N->getGlobal();
+  SDLoc DL(Op);
+
+  // Wrap it in a TargetGlobalAddress
+  SDValue Addr = DAG.getTargetGlobalAddress(GVal, DL, MVT::i64);
+
+  // Emit pseudo instruction
+  return SDValue(DAG.getMachineNode(BPF::LDIMM64, DL, MVT::i64, Addr), 0);
----------------
yonghong-song wrote:

We could do this (removing BPFISD::Wrapper and put all global address with DAG.getMachineNode()). This will add more cases in CustomInserter. I still prefer to have LowerJumpTable and LowerConstantPool in current implementation as they are easier to understand at DAG level with similar patterns in other architectures.

https://github.com/llvm/llvm-project/pull/149715


More information about the llvm-commits mailing list