diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-03-16 16:51:38 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-03-16 16:51:38 +0000 |
commit | 0f448b841684305c051796982f300c9bff959307 (patch) | |
tree | 458dd25677a43aef6390ecadb4423817f00e08b0 /tools/lto/LTOCodeGenerator.cpp | |
parent | 9e2446b38c94db61b2416c28fee415c03663c11c (diff) | |
download | FreeBSD-src-0f448b841684305c051796982f300c9bff959307.zip FreeBSD-src-0f448b841684305c051796982f300c9bff959307.tar.gz |
Update LLVM to r98631.
Diffstat (limited to 'tools/lto/LTOCodeGenerator.cpp')
-rw-r--r-- | tools/lto/LTOCodeGenerator.cpp | 86 |
1 files changed, 44 insertions, 42 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp index 0a58aa7..15753d3 100644 --- a/tools/lto/LTOCodeGenerator.cpp +++ b/tools/lto/LTOCodeGenerator.cpp @@ -27,24 +27,25 @@ #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/FormattedStream.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/StandardPasses.h" -#include "llvm/Support/SystemUtils.h" -#include "llvm/System/Host.h" -#include "llvm/System/Program.h" -#include "llvm/System/Signals.h" +#include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCContext.h" #include "llvm/Target/Mangler.h" #include "llvm/Target/SubtargetFeature.h" #include "llvm/Target/TargetOptions.h" -#include "llvm/MC/MCAsmInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetSelect.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FormattedStream.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/StandardPasses.h" +#include "llvm/Support/SystemUtils.h" +#include "llvm/System/Host.h" +#include "llvm/System/Program.h" +#include "llvm/System/Signals.h" #include "llvm/Config/config.h" #include <cstdlib> #include <unistd.h> @@ -252,7 +253,8 @@ bool LTOCodeGenerator::assemble(const std::string& asmPath, args.push_back(arch); } // add -static to assembler command line when code model requires - if ( (_assemblerPath != NULL) && (_codeModel == LTO_CODEGEN_PIC_MODEL_STATIC) ) + if ( (_assemblerPath != NULL) && + (_codeModel == LTO_CODEGEN_PIC_MODEL_STATIC) ) args.push_back("-static"); } if ( needsCompilerOptions ) { @@ -303,44 +305,44 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg) // construct LTModule, hand over ownership of module and target const std::string FeatureStr = - SubtargetFeatures::getDefaultSubtargetFeatures(llvm::Triple(Triple)); + SubtargetFeatures::getDefaultSubtargetFeatures(llvm::Triple(Triple)); _target = march->createTargetMachine(Triple, FeatureStr); } return false; } -void LTOCodeGenerator::applyScopeRestrictions() -{ - if ( !_scopeRestrictionsDone ) { - Module* mergedModule = _linker.getModule(); - - // Start off with a verification pass. - PassManager passes; - passes.add(createVerifierPass()); - - // mark which symbols can not be internalized - if ( !_mustPreserveSymbols.empty() ) { - Mangler mangler(*_target->getMCAsmInfo()); - std::vector<const char*> mustPreserveList; - for (Module::iterator f = mergedModule->begin(), - e = mergedModule->end(); f != e; ++f) { - if ( !f->isDeclaration() - && _mustPreserveSymbols.count(mangler.getNameWithPrefix(f)) ) - mustPreserveList.push_back(::strdup(f->getNameStr().c_str())); - } - for (Module::global_iterator v = mergedModule->global_begin(), - e = mergedModule->global_end(); v != e; ++v) { - if ( !v->isDeclaration() - && _mustPreserveSymbols.count(mangler.getNameWithPrefix(v)) ) - mustPreserveList.push_back(::strdup(v->getNameStr().c_str())); - } - passes.add(createInternalizePass(mustPreserveList)); - } - // apply scope restrictions - passes.run(*mergedModule); - - _scopeRestrictionsDone = true; +void LTOCodeGenerator::applyScopeRestrictions() { + if (_scopeRestrictionsDone) return; + Module *mergedModule = _linker.getModule(); + + // Start off with a verification pass. + PassManager passes; + passes.add(createVerifierPass()); + + // mark which symbols can not be internalized + if (!_mustPreserveSymbols.empty()) { + MCContext Context(*_target->getMCAsmInfo()); + Mangler mangler(Context, *_target->getTargetData()); + std::vector<const char*> mustPreserveList; + for (Module::iterator f = mergedModule->begin(), + e = mergedModule->end(); f != e; ++f) { + if (!f->isDeclaration() && + _mustPreserveSymbols.count(mangler.getNameWithPrefix(f))) + mustPreserveList.push_back(::strdup(f->getNameStr().c_str())); + } + for (Module::global_iterator v = mergedModule->global_begin(), + e = mergedModule->global_end(); v != e; ++v) { + if (v->isDeclaration() && + _mustPreserveSymbols.count(mangler.getNameWithPrefix(v))) + mustPreserveList.push_back(::strdup(v->getNameStr().c_str())); } + passes.add(createInternalizePass(mustPreserveList)); + } + + // apply scope restrictions + passes.run(*mergedModule); + + _scopeRestrictionsDone = true; } /// Optimize merged modules using various IPO passes |