X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FLTO%2FLTOModule.cpp;h=5083a59900a7dfb3d878571526a409c03821ab27;hb=0cccab7515080b5a9b3efd23ee19343e05fa4453;hp=3600baa5bbf1089c82f320b5cd3dbb60041e204b;hpb=9231148e693177e922cf98eca6a146e648e29d0b;p=oota-llvm.git diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp index 3600baa5bbf..5083a59900a 100644 --- a/lib/LTO/LTOModule.cpp +++ b/lib/LTO/LTOModule.cpp @@ -15,6 +15,7 @@ #include "llvm/LTO/LTOModule.h" #include "llvm/ADT/Triple.h" #include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/CodeGen/Analysis.h" #include "llvm/IR/Constants.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Metadata.h" @@ -39,6 +40,7 @@ #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/Target/TargetSubtargetInfo.h" #include "llvm/Transforms/Utils/GlobalStatus.h" #include using namespace llvm; @@ -145,7 +147,7 @@ LTOModule *LTOModule::makeLTOModule(std::unique_ptr Buffer, TargetMachine *target = march->createTargetMachine(TripleStr, CPU, FeatureStr, options); M->materializeAllPermanently(true); - M->setDataLayout(target->getDataLayout()); + M->setDataLayout(target->getSubtargetImpl()->getDataLayout()); std::unique_ptr IRObj( new object::IRObjectFile(std::move(Buffer), std::move(M))); @@ -163,10 +165,11 @@ LTOModule *LTOModule::makeLTOModule(std::unique_ptr Buffer, } /// Create a MemoryBuffer from a memory range with an optional name. -MemoryBuffer *LTOModule::makeBuffer(const void *mem, size_t length, - StringRef name) { +std::unique_ptr +LTOModule::makeBuffer(const void *mem, size_t length, StringRef name) { const char *startPtr = (const char*)mem; - return MemoryBuffer::getMemBuffer(StringRef(startPtr, length), name, false); + return std::unique_ptr( + MemoryBuffer::getMemBuffer(StringRef(startPtr, length), name, false)); } /// objcClassNameFromExpression - Get string that the data pointer points to. @@ -347,30 +350,6 @@ void LTOModule::addDefinedFunctionSymbol(const char *Name, const Function *F) { addDefinedSymbol(Name, F, true); } -static bool canBeHidden(const GlobalValue *GV) { - // FIXME: this is duplicated with another static function in AsmPrinter.cpp - GlobalValue::LinkageTypes L = GV->getLinkage(); - - if (L != GlobalValue::LinkOnceODRLinkage) - return false; - - if (GV->hasUnnamedAddr()) - return true; - - // If it is a non constant variable, it needs to be uniqued across shared - // objects. - if (const GlobalVariable *Var = dyn_cast(GV)) { - if (!Var->isConstant()) - return false; - } - - GlobalStatus GS; - if (GlobalStatus::analyzeGlobal(GV, GS)) - return false; - - return !GS.IsCompared; -} - void LTOModule::addDefinedSymbol(const char *Name, const GlobalValue *def, bool isFunction) { // set alignment part log2() can have rounding errors @@ -404,7 +383,7 @@ void LTOModule::addDefinedSymbol(const char *Name, const GlobalValue *def, attr |= LTO_SYMBOL_SCOPE_HIDDEN; else if (def->hasProtectedVisibility()) attr |= LTO_SYMBOL_SCOPE_PROTECTED; - else if (canBeHidden(def)) + else if (canBeOmittedFromSymbolTable(def)) attr |= LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN; else attr |= LTO_SYMBOL_SCOPE_DEFAULT; @@ -597,8 +576,10 @@ void LTOModule::parseMetadata() { MDString *MDOption = cast(MDOptions->getOperand(ii)); StringRef Op = _linkeropt_strings. GetOrCreateValue(MDOption->getString()).getKey(); - StringRef DepLibName = _target->getTargetLowering()-> - getObjFileLowering().getDepLibFromLinkerOpt(Op); + StringRef DepLibName = _target->getSubtargetImpl() + ->getTargetLowering() + ->getObjFileLowering() + .getDepLibFromLinkerOpt(Op); if (!DepLibName.empty()) _deplibs.push_back(DepLibName.data()); else if (!Op.empty())