[llvm] [BuildLibCalls] Apply ABI attributes to call-sites as well (PR #222675)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 03:16:03 PDT 2026


================
@@ -1503,6 +1503,21 @@ void llvm::markRegisterParameterAttributes(Function *F) {
   }
 }
 
+static void inheritABIAttributesFromCallee(CallBase *CB) {
+  Function *F = CB->getCalledFunction();
+  assert(F && "Cannot be indirect call");
----------------
nikic wrote:

I think it's pretty important that this is an assert. Doing this only makes sense in contexts like libcall emission, where you definitely know what the callee is. For indirect calls, it's critical that ABI attributes get emitted directly on the call-site.

The other usage I have in mind for now is https://github.com/llvm/llvm-project/blob/37fe7024f2944f71d58b8608d209bda3254fa43a/clang/lib/CodeGen/CodeGenModule.cpp#L5973-L5977 (or else resolve that FIXME -- I haven't investigated how much work that would be). For that I'd export the helper from BuildLibCalls, similar to the markRegisterParameterAttributes() function itself.

I think I wouldn't want to export this from CallBase at this point -- this is not really something people should directly call under most circumstances, and instead go through appropriate APIs that do it (like emitLibCall).

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


More information about the llvm-commits mailing list