[llvm] [clang] [AIX][TOC] Add -mtocdata/-mno-tocdata options on AIX (PR #67999)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 3 09:06:10 PDT 2023
================
@@ -622,6 +622,28 @@ static bool checkAliasedGlobal(
return true;
}
+// Emit a warning if toc-data attribute is requested for global variables that
+// have aliases and remove the toc-data attribute.
+static void checkAliasForTocData(llvm::GlobalVariable *GVar,
+ const CodeGenOptions &CodeGenOpts,
+ DiagnosticsEngine &Diags,
+ SourceLocation Location) {
+ if (GVar->hasAttribute("toc-data")) {
+ auto GVId = GVar->getGlobalIdentifier();
----------------
diggerlin wrote:
I have the same concern about it. The difference between `GVar->getGlobalIdentifier()` and `GVar->getName()` is as follows:
`GlobalValue::getGlobalIdentifier()` returns `getParent()->getSourceFileName()` + `GV->getName()` when the `GlobalValue` has local linkage.
Currently, we do not support local linkage, so `GlobalValue::getGlobalIdentifier()` has the same value as `GV->getName()`.
If we were to support local linkage someday, for the `GlobalValue` with local linkage, we would use `getGlobalIdentifier()` (with the source file name) to search CodeGenOpts.TocDataVarsUserSpecified.
However, in the function `AIXTargetCodeGenInfo::setTargetAttributes()`, it uses `auto GVId = M.getMangledName(dyn_cast<NamedDecl>(D))`; (without the source file name) to search `CodeGenOpts.TocDataVarsUserSpecified`.
The question now is which value should be specified in the clang compile option `-mtocdata=`? (`getGlobalIdentifier()` or `getMangledName()`).
It's clear that you cannot make both of the above two searches successful at the same time, regardless of which value you specify.
https://github.com/llvm/llvm-project/pull/67999
More information about the cfe-commits
mailing list