Mercurial > hg > CbC > CbC_llvm
diff lib/Target/TargetLoweringObjectFile.cpp @ 83:60c9769439b8 LLVM3.7
LLVM 3.7
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 18 Feb 2015 14:55:36 +0900 |
parents | 54457678186b |
children | afa8332a0e37 |
line wrap: on
line diff
--- a/lib/Target/TargetLoweringObjectFile.cpp Mon Sep 08 22:07:30 2014 +0900 +++ b/lib/Target/TargetLoweringObjectFile.cpp Wed Feb 18 14:55:36 2015 +0900 @@ -43,7 +43,7 @@ void TargetLoweringObjectFile::Initialize(MCContext &ctx, const TargetMachine &TM) { Ctx = &ctx; - DL = TM.getSubtargetImpl()->getDataLayout(); + DL = TM.getDataLayout(); InitMCObjectFileInfo(TM.getTargetTriple(), TM.getRelocationModel(), TM.getCodeModel(), *Ctx); } @@ -200,12 +200,12 @@ // Otherwise, just drop it into a mergable constant section. If we have // a section for this size, use it, otherwise use the arbitrary sized // mergable section. - switch (TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize( - C->getType())) { + switch (TM.getDataLayout()->getTypeAllocSize(C->getType())) { case 4: return SectionKind::getMergeableConst4(); case 8: return SectionKind::getMergeableConst8(); case 16: return SectionKind::getMergeableConst16(); - default: return SectionKind::getMergeableConst(); + default: + return SectionKind::getReadOnly(); } case Constant::LocalRelocation: @@ -270,29 +270,27 @@ return SelectSectionForGlobal(GV, Kind, Mang, TM); } -bool TargetLoweringObjectFile::isSectionAtomizableBySymbols( - const MCSection &Section) const { - return false; +const MCSection *TargetLoweringObjectFile::getSectionForJumpTable( + const Function &F, Mangler &Mang, const TargetMachine &TM) const { + return getSectionForConstant(SectionKind::getReadOnly(), /*C=*/nullptr); } -// Lame default implementation. Calculate the section name for global. -const MCSection * -TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV, - SectionKind Kind, - Mangler &Mang, - const TargetMachine &TM) const{ - assert(!Kind.isThreadLocal() && "Doesn't support TLS"); +bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection( + bool UsesLabelDifference, const Function &F) const { + // In PIC mode, we need to emit the jump table to the same section as the + // function body itself, otherwise the label differences won't make sense. + // FIXME: Need a better predicate for this: what about custom entries? + if (UsesLabelDifference) + return true; - if (Kind.isText()) - return getTextSection(); + // We should also do if the section name is NULL or function is declared + // in discardable section + // FIXME: this isn't the right predicate, should be based on the MCSection + // for the function. + if (F.isWeakForLinker()) + return true; - if (Kind.isBSS() && BSSSection != nullptr) - return BSSSection; - - if (Kind.isReadOnly() && ReadOnlySection != nullptr) - return ReadOnlySection; - - return getDataSection(); + return false; } /// getSectionForConstant - Given a mergable constant with the