[llvm] [Linker] Propagate `nobuiltin` attributes when linking known libcalls (PR #89431)
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 19 12:46:59 PDT 2024
================
@@ -1605,14 +1611,27 @@ Error IRLinker::run() {
DstM.setTargetTriple(SrcTriple.merge(DstTriple));
+ // Update the target triple's libcall information if it was changed.
+ Libcalls.updateLibcalls(Triple(DstM.getTargetTriple()));
+
// Loop over all of the linked values to compute type mappings.
computeTypeMapping();
+ bool AddsLibcalls;
std::reverse(Worklist.begin(), Worklist.end());
while (!Worklist.empty()) {
GlobalValue *GV = Worklist.back();
Worklist.pop_back();
+ // If the module already contains libcall functions we need every function
+ // linked in to have `nobuiltin` attributes. Otherwise check if this is a
+ // libcall definition.
+ if (Function *F = dyn_cast<Function>(GV); F && Libcalls.hasLibcalls())
+ F->setAttributes(F->getAttributes().addFnAttribute(F->getContext(),
+ Attribute::NoBuiltin));
----------------
jdoerfert wrote:
Don't you have to do this anyway at the end? Just have a single location to do it.
https://github.com/llvm/llvm-project/pull/89431
More information about the llvm-commits
mailing list