-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AIX] Support per global code model. #79202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bd9621a
f9be21b
8207b6a
eca388d
8e712ec
eb09fd5
980ae19
39c7802
a77ce54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,14 +186,63 @@ bool PPCSubtarget::enableSubRegLiveness() const { | |
} | ||
|
||
bool PPCSubtarget::isGVIndirectSymbol(const GlobalValue *GV) const { | ||
if (isAIXABI()) { | ||
if (const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV)) | ||
// On AIX the only symbols that aren't indirect are toc-data. | ||
return !GVar->hasAttribute("toc-data"); | ||
|
||
return true; | ||
} | ||
|
||
// Large code model always uses the TOC even for local symbols. | ||
if (TM.getCodeModel() == CodeModel::Large) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if the TM.getCodeModel is large, but the specific GV is set to small? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a really good question. I think originally I added this because it was triggering an assertion in the PPCAsmPrinter when we would emit the large code model nodes when the module code model was small. In reality both small and large code model use an indirect. That is true for both XCOFF and ELF - ELF has medium code model where we accessing things toc-relative instead of got indirect. I changed the AIX code to check for the toc-data attribute, since that is the only time a symbol would not be indirected on AIX. The existing code is slightly wrong in that we should be returning true for both small and large code model, but because of where (and how) this function is used that change will be untestable. We can update it in a separate NFC patch to make it correct at least, and when we add support for per global code model for ELF then it would be come testable. |
||
return true; | ||
|
||
mandlebug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (TM.shouldAssumeDSOLocal(GV)) | ||
return false; | ||
return true; | ||
} | ||
|
||
CodeModel::Model PPCSubtarget::getCodeModel(const TargetMachine &TM, | ||
chenzheng1030 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const GlobalValue *GV) const { | ||
// If there isn't an attribute to override the module code model | ||
// this will be the effective code model. | ||
CodeModel::Model ModuleModel = TM.getCodeModel(); | ||
|
||
// Initially support per global code model for AIX only. | ||
if (!isAIXABI()) | ||
return ModuleModel; | ||
|
||
// Only GlobalVariables carry an attribute which can override the module code | ||
// model. | ||
assert(GV && "Unexpected NULL GlobalValue"); | ||
const GlobalVariable *GlobalVar = | ||
[](const GlobalValue *GV) -> const GlobalVariable * { | ||
const GlobalVariable *Var = dyn_cast<GlobalVariable>(GV); | ||
if (Var) | ||
return Var; | ||
|
||
const GlobalAlias *Alias = dyn_cast<GlobalAlias>(GV); | ||
if (Alias) | ||
return dyn_cast<GlobalVariable>(Alias->getAliaseeObject()); | ||
|
||
return nullptr; | ||
}(GV); | ||
|
||
if (!GlobalVar) | ||
return ModuleModel; | ||
|
||
std::optional<CodeModel::Model> MaybeCodeModel = GlobalVar->getCodeModel(); | ||
if (MaybeCodeModel) { | ||
CodeModel::Model CM = *MaybeCodeModel; | ||
assert((CM == CodeModel::Small || CM == CodeModel::Large) && | ||
"invalid code model for AIX"); | ||
return CM; | ||
} | ||
|
||
return ModuleModel; | ||
} | ||
|
||
bool PPCSubtarget::isELFv2ABI() const { return TM.isELFv2ABI(); } | ||
bool PPCSubtarget::isPPC64() const { return TM.isPPC64(); } | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.