[llvm-commits] [llvm] r72816 - /llvm/trunk/tools/lto/LTOCodeGenerator.cpp
Nick Kledzik
kledzik at apple.com
Wed Jun 3 15:52:12 PDT 2009
Author: kledzik
Date: Wed Jun 3 17:52:12 2009
New Revision: 72816
URL: http://llvm.org/viewvc/llvm-project?rev=72816&view=rev
Log:
<rdar://problem/6941517> C++ static constructors not preserved for static executable using LTO
Move setRelocationModel() to be called before TargetMachine is instantiated.
Modified:
llvm/trunk/tools/lto/LTOCodeGenerator.cpp
Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=72816&r1=72815&r2=72816&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Wed Jun 3 17:52:12 2009
@@ -304,6 +304,20 @@
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 +377,6 @@
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(),
More information about the llvm-commits
mailing list