|
@@ -37,11 +37,11 @@ protected:
|
|
|
setGlobalValueSubClassData(0);
|
|
|
}
|
|
|
|
|
|
- std::string Section; // Section to emit this into, empty means default
|
|
|
Comdat *ObjComdat;
|
|
|
enum {
|
|
|
LastAlignmentBit = 4,
|
|
|
HasMetadataHashEntryBit,
|
|
|
+ HasSectionHashEntryBit,
|
|
|
|
|
|
GlobalObjectBits,
|
|
|
};
|
|
@@ -66,8 +66,26 @@ public:
|
|
|
unsigned getGlobalObjectSubClassData() const;
|
|
|
void setGlobalObjectSubClassData(unsigned Val);
|
|
|
|
|
|
- bool hasSection() const { return !getSection().empty(); }
|
|
|
- StringRef getSection() const { return Section; }
|
|
|
+ /// Check if this global has a custom object file section.
|
|
|
+ ///
|
|
|
+ /// This is more efficient than calling getSection() and checking for an empty
|
|
|
+ /// string.
|
|
|
+ bool hasSection() const {
|
|
|
+ return getGlobalValueSubClassData() & (1 << HasSectionHashEntryBit);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// Get the custom section of this global if it has one.
|
|
|
+ ///
|
|
|
+ /// If this global does not have a custom section, this will be empty and the
|
|
|
+ /// default object file section (.text, .data, etc) will be used.
|
|
|
+ StringRef getSection() const {
|
|
|
+ return hasSection() ? getSectionImpl() : StringRef();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// Change the section for this global.
|
|
|
+ ///
|
|
|
+ /// Setting the section to the empty string tells LLVM to choose an
|
|
|
+ /// appropriate default object file section.
|
|
|
void setSection(StringRef S);
|
|
|
|
|
|
bool hasComdat() const { return getComdat() != nullptr; }
|
|
@@ -134,14 +152,20 @@ public:
|
|
|
void clearMetadata();
|
|
|
|
|
|
private:
|
|
|
+ void setGlobalObjectFlag(unsigned Bit, bool Val) {
|
|
|
+ unsigned Mask = 1 << Bit;
|
|
|
+ setGlobalValueSubClassData((~Mask & getGlobalValueSubClassData()) |
|
|
|
+ (Val ? Mask : 0u));
|
|
|
+ }
|
|
|
+
|
|
|
bool hasMetadataHashEntry() const {
|
|
|
return getGlobalValueSubClassData() & (1 << HasMetadataHashEntryBit);
|
|
|
}
|
|
|
void setHasMetadataHashEntry(bool HasEntry) {
|
|
|
- unsigned Mask = 1 << HasMetadataHashEntryBit;
|
|
|
- setGlobalValueSubClassData((~Mask & getGlobalValueSubClassData()) |
|
|
|
- (HasEntry ? Mask : 0u));
|
|
|
+ setGlobalObjectFlag(HasMetadataHashEntryBit, HasEntry);
|
|
|
}
|
|
|
+
|
|
|
+ StringRef getSectionImpl() const;
|
|
|
};
|
|
|
|
|
|
} // end namespace llvm
|