diff options
author | Stephen Hines <srhines@google.com> | 2014-02-11 20:01:10 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-02-11 20:01:10 -0800 |
commit | ce9904c6ea8fd669978a8eefb854b330eb9828ff (patch) | |
tree | 2418ee2e96ea220977c8fb74959192036ab5b133 /lib/Linker | |
parent | c27b10b198c1d9e9b51f2303994313ec2778edd7 (diff) | |
parent | dbb832b83351cec97b025b61c26536ef50c3181c (diff) | |
download | external_llvm-ce9904c6ea8fd669978a8eefb854b330eb9828ff.zip external_llvm-ce9904c6ea8fd669978a8eefb854b330eb9828ff.tar.gz external_llvm-ce9904c6ea8fd669978a8eefb854b330eb9828ff.tar.bz2 |
Merge remote-tracking branch 'upstream/release_34' into merge-20140211
Conflicts:
lib/Linker/LinkModules.cpp
lib/Support/Unix/Signals.inc
Change-Id: Ia54f291fa5dc828052d2412736e8495c1282aa64
Diffstat (limited to 'lib/Linker')
-rw-r--r-- | lib/Linker/LinkModules.cpp | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index ce02c37..8f2200e 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -22,8 +22,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Utils/Cloning.h" - -#include <ctype.h> +#include <cctype> using namespace llvm; //===----------------------------------------------------------------------===// @@ -706,7 +705,11 @@ bool ModuleLinker::linkAppendingVarProto(GlobalVariable *DstGV, if (DstGV->getVisibility() != SrcGV->getVisibility()) return emitError( "Appending variables with different visibility need to be linked!"); - + + if (DstGV->hasUnnamedAddr() != SrcGV->hasUnnamedAddr()) + return emitError( + "Appending variables with different unnamed_addr need to be linked!"); + if (DstGV->getSection() != SrcGV->getSection()) return emitError( "Appending variables with different section name need to be linked!"); @@ -748,6 +751,7 @@ bool ModuleLinker::linkAppendingVarProto(GlobalVariable *DstGV, bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) { GlobalValue *DGV = getLinkedToGlobal(SGV); llvm::Optional<GlobalValue::VisibilityTypes> NewVisibility; + bool HasUnnamedAddr = SGV->hasUnnamedAddr(); if (DGV) { // Concatenation of appending linkage variables is magic and handled later. @@ -762,6 +766,7 @@ bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) { if (getLinkageResult(DGV, SGV, NewLinkage, NV, LinkFromSrc)) return true; NewVisibility = NV; + HasUnnamedAddr = HasUnnamedAddr && DGV->hasUnnamedAddr(); // If we're not linking from the source, then keep the definition that we // have. @@ -770,10 +775,11 @@ bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) { if (GlobalVariable *DGVar = dyn_cast<GlobalVariable>(DGV)) if (DGVar->isDeclaration() && SGV->isConstant() && !DGVar->isConstant()) DGVar->setConstant(true); - - // Set calculated linkage and visibility. + + // Set calculated linkage, visibility and unnamed_addr. DGV->setLinkage(NewLinkage); DGV->setVisibility(*NewVisibility); + DGV->setUnnamedAddr(HasUnnamedAddr); // Make sure to remember this mapping. ValueMap[SGV] = ConstantExpr::getBitCast(DGV,TypeMap.get(SGV->getType())); @@ -799,6 +805,7 @@ bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) { copyGVAttributes(NewDGV, SGV); if (NewVisibility) NewDGV->setVisibility(*NewVisibility); + NewDGV->setUnnamedAddr(HasUnnamedAddr); if (DGV) { DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDGV, DGV->getType())); @@ -815,6 +822,7 @@ bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) { bool ModuleLinker::linkFunctionProto(Function *SF) { GlobalValue *DGV = getLinkedToGlobal(SF); llvm::Optional<GlobalValue::VisibilityTypes> NewVisibility; + bool HasUnnamedAddr = SF->hasUnnamedAddr(); if (DGV) { GlobalValue::LinkageTypes NewLinkage = GlobalValue::InternalLinkage; @@ -823,11 +831,13 @@ bool ModuleLinker::linkFunctionProto(Function *SF) { if (getLinkageResult(DGV, SF, NewLinkage, NV, LinkFromSrc)) return true; NewVisibility = NV; + HasUnnamedAddr = HasUnnamedAddr && DGV->hasUnnamedAddr(); if (!LinkFromSrc) { // Set calculated linkage DGV->setLinkage(NewLinkage); DGV->setVisibility(*NewVisibility); + DGV->setUnnamedAddr(HasUnnamedAddr); // Make sure to remember this mapping. ValueMap[SF] = ConstantExpr::getBitCast(DGV, TypeMap.get(SF->getType())); @@ -855,6 +865,7 @@ bool ModuleLinker::linkFunctionProto(Function *SF) { copyGVAttributes(NewDF, SF); if (NewVisibility) NewDF->setVisibility(*NewVisibility); + NewDF->setUnnamedAddr(HasUnnamedAddr); if (DGV) { // Any uses of DF need to change to NewDF, with cast. @@ -1250,6 +1261,13 @@ bool ModuleLinker::run() { // Skip if not linking from source. if (DoNotLinkFromSource.count(SF)) continue; + Function *DF = cast<Function>(ValueMap[SF]); + if (SF->hasPrefixData()) { + // Link in the prefix data. + DF->setPrefixData(MapValue( + SF->getPrefixData(), ValueMap, RF_None, &TypeMap, &ValMaterializer)); + } + // Skip if no body (function is external) or materialize. if (SF->isDeclaration()) { if (!SF->isMaterializable()) @@ -1258,7 +1276,7 @@ bool ModuleLinker::run() { return true; } - linkFunctionBody(cast<Function>(ValueMap[SF]), SF); + linkFunctionBody(DF, SF); SF->Dematerialize(); } @@ -1286,6 +1304,14 @@ bool ModuleLinker::run() { continue; Function *DF = cast<Function>(ValueMap[SF]); + if (SF->hasPrefixData()) { + // Link in the prefix data. + DF->setPrefixData(MapValue(SF->getPrefixData(), + ValueMap, + RF_None, + &TypeMap, + &ValMaterializer)); + } // Materialize if necessary. if (SF->isDeclaration()) { @@ -1326,6 +1352,11 @@ Linker::Linker(Module *M) : Composite(M) { Linker::~Linker() { } +void Linker::deleteModule() { + delete Composite; + Composite = NULL; +} + bool Linker::linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg) { ModuleLinker TheLinker(Composite, IdentifiedStructTypes, Src, Mode); if (TheLinker.run()) { |