Mercurial > hg > CbC > CbC_llvm
diff lib/Target/TargetLoweringObjectFile.cpp @ 121:803732b1fca8
LLVM 5.0
author | kono |
---|---|
date | Fri, 27 Oct 2017 17:07:41 +0900 |
parents | 1172e4bd9c6f |
children | 3a76565eade5 |
line wrap: on
line diff
--- a/lib/Target/TargetLoweringObjectFile.cpp Fri Nov 25 19:14:25 2016 +0900 +++ b/lib/Target/TargetLoweringObjectFile.cpp Fri Oct 27 17:07:41 2017 +0900 @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/BinaryFormat/Dwarf.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" @@ -24,7 +25,6 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" -#include "llvm/Support/Dwarf.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetLowering.h" @@ -44,10 +44,10 @@ const TargetMachine &TM) { Ctx = &ctx; // `Initialize` can be called more than once. - if (Mang != nullptr) delete Mang; + delete Mang; Mang = new Mangler(); - InitMCObjectFileInfo(TM.getTargetTriple(), TM.isPositionIndependent(), - TM.getCodeModel(), *Ctx); + InitMCObjectFileInfo(TM.getTargetTriple(), TM.isPositionIndependent(), *Ctx, + TM.getCodeModel() == CodeModel::Large); } TargetLoweringObjectFile::~TargetLoweringObjectFile() { @@ -240,6 +240,20 @@ if (GO->hasSection()) return getExplicitSectionGlobal(GO, Kind, TM); + if (auto *GVar = dyn_cast<GlobalVariable>(GO)) { + auto Attrs = GVar->getAttributes(); + if ((Attrs.hasAttribute("bss-section") && Kind.isBSS()) || + (Attrs.hasAttribute("data-section") && Kind.isData()) || + (Attrs.hasAttribute("rodata-section") && Kind.isReadOnly())) { + return getExplicitSectionGlobal(GO, Kind, TM); + } + } + + if (auto *F = dyn_cast<Function>(GO)) { + if (F->hasFnAttribute("implicit-section-name")) + return getExplicitSectionGlobal(GO, Kind, TM); + } + // Use default section depending on the 'type' of global return SelectSectionForGlobal(GO, Kind, TM); } @@ -264,10 +278,7 @@ // in discardable section // FIXME: this isn't the right predicate, should be based on the MCSection // for the function. - if (F.isWeakForLinker()) - return true; - - return false; + return F.isWeakForLinker(); } /// Given a mergable constant with the specified size and relocation