1
Fork 0

trans: Clean up handling the LLVM data layout

Turns out for OSX our data layout was subtly wrong and the LLVM update must have
exposed this. Instead of fixing this I've removed all data layouts from the
compiler to just use the defaults that LLVM provides for all targets. All data
layouts (and a number of dead modules) are removed from the compiler here.
Custom target specifications can still provide a custom data layout, but it is
now an optional key as the default will be used if one isn't specified.
This commit is contained in:
Alex Crichton 2015-07-16 15:48:16 -07:00
parent 74e198126b
commit 958d563825
45 changed files with 89 additions and 535 deletions

View file

@ -21,6 +21,8 @@
#else
#include "llvm/Target/TargetLibraryInfo.h"
#endif
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetSubtargetInfo.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
@ -327,3 +329,28 @@ LLVMRustMarkAllFunctionsNounwind(LLVMModuleRef M) {
}
}
}
extern "C" void
LLVMRustSetDataLayoutFromTargetMachine(LLVMModuleRef Module,
LLVMTargetMachineRef TMR) {
TargetMachine *Target = unwrap(TMR);
#if LLVM_VERSION_MINOR >= 7
if (const DataLayout *DL = Target->getDataLayout())
unwrap(Module)->setDataLayout(*DL);
#elif LLVM_VERSION_MINOR >= 6
if (const DataLayout *DL = Target->getSubtargetImpl()->getDataLayout())
unwrap(Module)->setDataLayout(DL);
#else
if (const DataLayout *DL = Target->getDataLayout())
unwrap(Module)->setDataLayout(DL);
#endif
}
extern "C" LLVMTargetDataRef
LLVMRustGetModuleDataLayout(LLVMModuleRef M) {
#if LLVM_VERSION_MINOR >= 7
return wrap(&unwrap(M)->getDataLayout());
#else
return wrap(unwrap(M)->getDataLayout());
#endif
}