[llvm] [PowerPC] Function descriptor symbol can be omitted for external symbol. (PR #97526)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 5 03:14:03 PDT 2024


================
@@ -2325,8 +2325,15 @@ bool AsmPrinter::doFinalization(Module &M) {
     // Emit linkage for the function entry point.
     emitLinkage(&F, FnEntryPointSym);
 
-    // Emit linkage for the function descriptor.
-    emitLinkage(&F, Name);
+    // If address is taken from an extern function, we need to emit linkage for
+    // its function descriptor symbol.
+    if (F.hasAddressTaken(/*PutOffender=*/nullptr,
+                          /*IgnoreCallbackUses=*/false,
+                          /*IgnoreAssumeLikeCalls=*/true,
+                          /*IgnoreLLVMUsed=*/true,
+                          /*IgnoreARCAttachedCall=*/false,
+                          /*IgnoreCastedDirectCall=*/true))
----------------
EsmeYi wrote:

Thank you. I keep default values for them now.
`IgnoreCastedDirectCall` was set to true because I used to suppose the external function used in a direct call but with a different signature should omit the DS symbol. But it seems we should still emit the symbol for such case according to what we have discussed offline.
In terms of `IgnoreLLVMUsed`, `llvm.compiler.used` and `llvm.used` are used in certain cases to preserve symbol which is fully inlined. The purpose of adding the option is to detect a potential indirect call to a function. And I don't think we should omit DS symbol for `llvm.used` cases.

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


More information about the llvm-commits mailing list