namespace llvm {
class GlobalValue;
class GlobalVariable;
+ class Type;
struct DarwinTargetAsmInfo: public virtual TargetAsmInfo {
const Section* TextCoalSection;
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind kind) const;
const Section* MergeableConstSection(const GlobalVariable *GV) const;
+ const Section* MergeableConstSection(const Type *Ty) const;
const Section* MergeableStringSection(const GlobalVariable *GV) const;
+ const Section* SelectSectionForMachineConst(const Type *Ty) const;
protected:
const TargetMachine* DTM;
};
const Section*
DarwinTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
- const TargetData *TD = DTM->getTargetData();
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
- unsigned Size = TD->getABITypeSize(C->getType());
+ return MergeableConstSection(C->getType());
+}
+
+inline const Section*
+DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
+ const TargetData *TD = DTM->getTargetData();
+
+ unsigned Size = TD->getABITypeSize(Ty);
if (Size == 4)
return FourByteConstantSection_;
else if (Size == 8)
return getReadOnlySection_();
}
+const Section*
+DarwinTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
+ const Section* S = MergeableConstSection(Ty);
+
+ // Handle weird special case, when compiling PIC stuff.
+ if (S == getReadOnlySection_() &&
+ DTM->getRelocationModel() != Reloc::Static)
+ return ConstDataSection;
+
+ return S;
+}
+
std::string
DarwinTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind kind) const {
const Section*
ELFTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
- const Type *Ty = C->getType();
-
- return MergeableConstSection(Ty);
+ return MergeableConstSection(C->getType());
}
inline const Section*