aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-06-06 08:20:29 +0000
committerEd Schouten <ed@FreeBSD.org>2009-06-06 08:20:29 +0000
commitf4fe016fa15f703fe9c1b932d1e81e2c718521db (patch)
tree8a1bbd1a5b838080d31e5c93a1817006b8c62318 /tools
parent68eb509bdc5c7007520d5231cd92de28106236df (diff)
downloadsrc-f4fe016fa15f703fe9c1b932d1e81e2c718521db.tar.gz
src-f4fe016fa15f703fe9c1b932d1e81e2c718521db.zip
Import LLVM, at r72995.vendor/llvm/llvm-r72995
We should now have support for #pragma weak.
Notes
Notes: svn path=/vendor/llvm/dist/; revision=193574 svn path=/vendor/llvm/llvm-r72995/; revision=193575; tag=vendor/llvm/llvm-r72995
Diffstat (limited to 'tools')
-rw-r--r--tools/CMakeLists.txt6
-rw-r--r--tools/llc/llc.cpp17
-rw-r--r--tools/llvm-ld/Optimize.cpp2
-rw-r--r--tools/lto/LTOCodeGenerator.cpp68
-rw-r--r--tools/lto/LTOCodeGenerator.h2
-rw-r--r--tools/lto/lto.cpp8
-rw-r--r--tools/lto/lto.exports1
7 files changed, 74 insertions, 30 deletions
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 113d98743c47..5c1ee351a2a0 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -2,9 +2,9 @@
# large and three small executables. This is done to minimize memory load
# in parallel builds. Please retain this ordering.
-if( NOT MSVC )
- add_subdirectory(llvm-config)
-endif( NOT MSVC )
+if (NOT USE_EXPLICIT_DEPENDENCIES)
+ add_subdirectory(llvm-config)
+endif()
add_subdirectory(opt)
add_subdirectory(llvm-as)
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 4808f0e529cc..c630331d684c 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -100,6 +100,16 @@ cl::opt<bool> NoVerify("disable-verify", cl::Hidden,
cl::desc("Do not verify input module"));
+static cl::opt<bool>
+DisableRedZone("disable-red-zone",
+ cl::desc("Do not emit code that uses the red zone."),
+ cl::init(false));
+
+static cl::opt<bool>
+NoImplicitFloats("no-implicit-float",
+ cl::desc("Don't generate implicit floating point instructions (x86-only)"),
+ cl::init(false));
+
// GetFileNameRoot - Helper function to get the basename of a filename.
static inline std::string
GetFileNameRoot(const std::string &InputFilename) {
@@ -336,8 +346,13 @@ int main(int argc, char **argv) {
// Run our queue of passes all at once now, efficiently.
// TODO: this could lazily stream functions out of the module.
for (Module::iterator I = mod.begin(), E = mod.end(); I != E; ++I)
- if (!I->isDeclaration())
+ if (!I->isDeclaration()) {
+ if (DisableRedZone)
+ I->addFnAttr(Attribute::NoRedZone);
+ if (NoImplicitFloats)
+ I->addFnAttr(Attribute::NoImplicitFloat);
Passes.run(*I);
+ }
Passes.doFinalization();
}
diff --git a/tools/llvm-ld/Optimize.cpp b/tools/llvm-ld/Optimize.cpp
index a4ca95199a1c..e4668958dbbe 100644
--- a/tools/llvm-ld/Optimize.cpp
+++ b/tools/llvm-ld/Optimize.cpp
@@ -94,7 +94,7 @@ void Optimize(Module* M) {
if (!DisableOptimizations)
createStandardLTOPasses(&Passes, !DisableInternalize, !DisableInline,
- /*RunSecondGlobalOpt=*/true, VerifyEach);
+ VerifyEach);
// If the -s or -S command line options were specified, strip the symbols out
// of the resulting program to make it smaller. -s and -S are GNU ld options
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 03a11b687daa..0bd2abe24558 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -72,7 +72,7 @@ LTOCodeGenerator::LTOCodeGenerator()
: _linker("LinkTimeOptimizer", "ld-temp.o"), _target(NULL),
_emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
_codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
- _nativeObjectFile(NULL), _gccPath(NULL)
+ _nativeObjectFile(NULL), _gccPath(NULL), _assemblerPath(NULL)
{
}
@@ -128,6 +128,13 @@ void LTOCodeGenerator::setGccPath(const char* path)
_gccPath = new sys::Path(path);
}
+void LTOCodeGenerator::setAssemblerPath(const char* path)
+{
+ if ( _assemblerPath )
+ delete _assemblerPath;
+ _assemblerPath = new sys::Path(path);
+}
+
void LTOCodeGenerator::addMustPreserveSymbol(const char* sym)
{
_mustPreserveSymbols[sym] = 1;
@@ -220,13 +227,18 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg)
bool LTOCodeGenerator::assemble(const std::string& asmPath,
const std::string& objPath, std::string& errMsg)
{
- sys::Path gcc;
- if ( _gccPath ) {
- gcc = *_gccPath;
+ sys::Path tool;
+ bool needsCompilerOptions = true;
+ if ( _assemblerPath ) {
+ tool = *_assemblerPath;
+ needsCompilerOptions = false;
+ }
+ else if ( _gccPath ) {
+ tool = *_gccPath;
} else {
// find compiler driver
- gcc = sys::Program::FindProgramByName("gcc");
- if ( gcc.isEmpty() ) {
+ tool = sys::Program::FindProgramByName("gcc");
+ if ( tool.isEmpty() ) {
errMsg = "can't locate gcc";
return true;
}
@@ -235,8 +247,9 @@ bool LTOCodeGenerator::assemble(const std::string& asmPath,
// build argument list
std::vector<const char*> args;
std::string targetTriple = _linker.getModule()->getTargetTriple();
- args.push_back(gcc.c_str());
+ args.push_back(tool.c_str());
if ( targetTriple.find("darwin") != targetTriple.size() ) {
+ // darwin specific command line options
if (strncmp(targetTriple.c_str(), "i386-apple-", 11) == 0) {
args.push_back("-arch");
args.push_back("i386");
@@ -274,17 +287,22 @@ bool LTOCodeGenerator::assemble(const std::string& asmPath,
args.push_back("-arch");
args.push_back("armv6");
}
+ // add -static to assembler command line when code model requires
+ if ( (_assemblerPath != NULL) && (_codeModel == LTO_CODEGEN_PIC_MODEL_STATIC) )
+ args.push_back("-static");
+ }
+ if ( needsCompilerOptions ) {
+ args.push_back("-c");
+ args.push_back("-x");
+ args.push_back("assembler");
}
- args.push_back("-c");
- args.push_back("-x");
- args.push_back("assembler");
args.push_back("-o");
args.push_back(objPath.c_str());
args.push_back(asmPath.c_str());
args.push_back(0);
// invoke assembler
- if ( sys::Program::ExecuteAndWait(gcc, &args[0], 0, 0, 0, 0, &errMsg) ) {
+ if ( sys::Program::ExecuteAndWait(tool, &args[0], 0, 0, 0, 0, &errMsg) ) {
errMsg = "error in assembly";
return true;
}
@@ -304,6 +322,20 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg)
if ( march == NULL )
return true;
+ // The relocation model is actually a static member of TargetMachine
+ // and needs to be set before the TargetMachine is instantiated.
+ switch( _codeModel ) {
+ case LTO_CODEGEN_PIC_MODEL_STATIC:
+ TargetMachine::setRelocationModel(Reloc::Static);
+ break;
+ case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
+ TargetMachine::setRelocationModel(Reloc::PIC_);
+ break;
+ case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
+ TargetMachine::setRelocationModel(Reloc::DynamicNoPIC);
+ break;
+ }
+
// construct LTModule, hand over ownership of module and target
std::string FeatureStr =
getFeatureString(_linker.getModule()->getTargetTriple().c_str());
@@ -363,19 +395,6 @@ bool LTOCodeGenerator::generateAssemblyCode(raw_ostream& out,
if ( _target->getTargetAsmInfo()->doesSupportExceptionHandling() )
llvm::ExceptionHandling = true;
- // set codegen model
- switch( _codeModel ) {
- case LTO_CODEGEN_PIC_MODEL_STATIC:
- _target->setRelocationModel(Reloc::Static);
- break;
- case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
- _target->setRelocationModel(Reloc::PIC_);
- break;
- case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
- _target->setRelocationModel(Reloc::DynamicNoPIC);
- break;
- }
-
// if options were requested, set them
if ( !_codegenOptions.empty() )
cl::ParseCommandLineOptions(_codegenOptions.size(),
@@ -391,7 +410,6 @@ bool LTOCodeGenerator::generateAssemblyCode(raw_ostream& out,
passes.add(new TargetData(*_target->getTargetData()));
createStandardLTOPasses(&passes, /*Internalize=*/ false, !DisableInline,
- /*RunSecondGlobalOpt=*/ false,
/*VerifyEach=*/ false);
// Make sure everything is still good.
diff --git a/tools/lto/LTOCodeGenerator.h b/tools/lto/LTOCodeGenerator.h
index 57398b065003..e02a7ab1159f 100644
--- a/tools/lto/LTOCodeGenerator.h
+++ b/tools/lto/LTOCodeGenerator.h
@@ -37,6 +37,7 @@ public:
bool setDebugInfo(lto_debug_model, std::string& errMsg);
bool setCodePICModel(lto_codegen_model, std::string& errMsg);
void setGccPath(const char* path);
+ void setAssemblerPath(const char* path);
void addMustPreserveSymbol(const char* sym);
bool writeMergedModules(const char* path,
std::string& errMsg);
@@ -61,6 +62,7 @@ private:
llvm::MemoryBuffer* _nativeObjectFile;
std::vector<const char*> _codegenOptions;
llvm::sys::Path* _gccPath;
+ llvm::sys::Path* _assemblerPath;
};
#endif // LTO_CODE_GENERATOR_H
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp
index 5c3f90aa485d..7eb39ef21000 100644
--- a/tools/lto/lto.cpp
+++ b/tools/lto/lto.cpp
@@ -210,6 +210,14 @@ void lto_codegen_set_gcc_path(lto_code_gen_t cg, const char* path)
}
//
+// sets the path to the assembler tool
+//
+void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path)
+{
+ cg->setAssemblerPath(path);
+}
+
+//
// adds to a list of all global symbols that must exist in the final
// generated code. If a function is not listed there, it might be
// inlined into every usage and optimized away.
diff --git a/tools/lto/lto.exports b/tools/lto/lto.exports
index aff755937b5b..01f43d1c36da 100644
--- a/tools/lto/lto.exports
+++ b/tools/lto/lto.exports
@@ -20,4 +20,5 @@ _lto_codegen_set_debug_model
_lto_codegen_set_pic_model
_lto_codegen_write_merged_modules
_lto_codegen_debug_options
+_lto_codegen_set_assembler_path