[llvm] [llvm][IR] Add per-global code model attribute (PR #72077)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 14 19:27:26 PST 2023
================
@@ -124,6 +126,24 @@ class GlobalObject : public GlobalValue {
/// appropriate default object file section.
void setSection(StringRef S);
+ /// Check if this global has a custom code model.
+ ///
+ bool hasCodeModel() const {
+ return getGlobalValueSubClassData() & (1 << HasCodeModelHashEntryBit);
+ }
+
+ /// Get the custom code model of this global if it has one.
+ ///
+ /// If this global does not have a custom code model, the default small code
+ /// model will be used.
+ CodeModel::Model getCodeModel() const {
+ return hasCodeModel() ? getCodeModelImpl() : CodeModel::Small;
----------------
aeubanks wrote:
we shouldn't assume a default code model, this should return a std::optional
https://github.com/llvm/llvm-project/pull/72077
More information about the llvm-commits
mailing list