|
4 | 4 | #include "platform.h" |
5 | 5 |
|
6 | 6 | // target support |
| 7 | +#include "llvm/Support/CodeGen.h" |
7 | 8 | #include <llvm/ADT/Triple.h> |
8 | 9 | #include <llvm/ADT/Statistic.h> |
9 | 10 | #include <llvm/Analysis/TargetLibraryInfo.h> |
@@ -1615,10 +1616,11 @@ void jl_dump_native_impl(void *native_code, |
1615 | 1616 | if (TheTriple.isOSLinux() || TheTriple.isOSFreeBSD()) { |
1616 | 1617 | RelocModel = Reloc::PIC_; |
1617 | 1618 | } |
| 1619 | + |
1618 | 1620 | CodeModel::Model CMModel = CodeModel::Small; |
1619 | | - if (TheTriple.isPPC()) { |
1620 | | - // On PPC the small model is limited to 16bit offsets |
1621 | | - CMModel = CodeModel::Medium; |
| 1621 | + if (TheTriple.isPPC() || (TheTriple.isX86() && TheTriple.isArch64Bit() && TheTriple.isOSLinux())) { |
| 1622 | + // On PPC the small model is limited to 16bit offsets. For very large images the small code model |
| 1623 | + CMModel = CodeModel::Medium; // isn't good enough on x86 so use Medium, it has no cost because only the image goes in .ldata |
1622 | 1624 | } |
1623 | 1625 | std::unique_ptr<TargetMachine> SourceTM( |
1624 | 1626 | jl_ExecutionEngine->getTarget().createTargetMachine( |
@@ -1661,6 +1663,12 @@ void jl_dump_native_impl(void *native_code, |
1661 | 1663 | GlobalVariable::ExternalLinkage, |
1662 | 1664 | data, "jl_system_image_data"); |
1663 | 1665 | sysdata->setAlignment(Align(64)); |
| 1666 | +#if JL_LLVM_VERSION >= 180000 |
| 1667 | + sysdata->setCodeModel(CodeModel::Large); |
| 1668 | +#else |
| 1669 | + if (TheTriple.isX86() && TheTriple.isArch64Bit() && TheTriple.isOSLinux()) |
| 1670 | + sysdata->setSection(".ldata"); |
| 1671 | +#endif |
1664 | 1672 | addComdat(sysdata, TheTriple); |
1665 | 1673 | Constant *len = ConstantInt::get(sysimgM.getDataLayout().getIntPtrType(Context), z->size); |
1666 | 1674 | addComdat(new GlobalVariable(sysimgM, len->getType(), true, |
|
0 commit comments