[llvm] bpf: Support aggregate returns (PR #190894)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 8 08:56:35 PDT 2026


================
@@ -565,12 +566,13 @@ SDValue BPFTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
     Callee = DAG.getTargetGlobalAddress(G->getGlobal(), CLI.DL, PtrVT,
                                         G->getOffset(), 0);
   } else if (ExternalSymbolSDNode *E = dyn_cast<ExternalSymbolSDNode>(Callee)) {
-    if (StringRef(E->getSymbol()) != BPF_TRAP) {
-      Callee = DAG.getTargetExternalSymbol(E->getSymbol(), PtrVT, 0);
-      fail(CLI.DL, DAG,
-           Twine("A call to built-in function '" + StringRef(E->getSymbol()) +
-                 "' is not supported."));
-    }
+    Callee = DAG.getTargetExternalSymbol(E->getSymbol(), PtrVT, 0);
+    StringRef Sym = E->getSymbol();
+    if (Sym != BPF_TRAP && Sym != "__multi3" && Sym != "__divti3" &&
+        Sym != "__modti3" && Sym != "__udivti3" && Sym != "__umodti3")
----------------
yonghong-song wrote:

> you mean the whole 'if' can be removed? No. It's necessary to allowlist these libcalls. I'm debating whether backend should expand multi3 in place or keep it as libcall, but div/mod should definitely go via libcall.

It would be great to have a selftest with one of these libcall symbols in asm code. I guess this needs kernel support and that is why I think we do not need this. But I agree that we can allow these libcalls in llvm and the kernel/jit can actually do code gen for these libcalls.

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


More information about the llvm-commits mailing list