diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-07-16 15:48:16 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-07-16 20:25:52 -0700 |
| commit | 958d5638254958ea42652de7444b63f2e67e7fe3 (patch) | |
| tree | 7c7d91d57f427a2c26abc2d3be24a63809cb3873 /src/rustllvm/PassWrapper.cpp | |
| parent | 74e198126b19efb7871aa673ae17483753f067b0 (diff) | |
| download | rust-958d5638254958ea42652de7444b63f2e67e7fe3.tar.gz rust-958d5638254958ea42652de7444b63f2e67e7fe3.zip | |
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.
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
| -rw-r--r-- | src/rustllvm/PassWrapper.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 2c0240eb8f9..6513fdfd2f2 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -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 +} |
