|
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> |
@@ -1607,10 +1608,11 @@ void jl_dump_native_impl(void *native_code, |
1607 | 1608 | if (TheTriple.isOSLinux() || TheTriple.isOSFreeBSD()) { |
1608 | 1609 | RelocModel = Reloc::PIC_; |
1609 | 1610 | } |
| 1611 | + |
1610 | 1612 | CodeModel::Model CMModel = CodeModel::Small; |
1611 | | - if (TheTriple.isPPC()) { |
1612 | | - // On PPC the small model is limited to 16bit offsets |
1613 | | - CMModel = CodeModel::Medium; |
| 1613 | + if (TheTriple.isPPC() || (TheTriple.isX86() && TheTriple.isArch64Bit() && TheTriple.isOSLinux())) { |
| 1614 | + // On PPC the small model is limited to 16bit offsets. For very large images the small code model |
| 1615 | + CMModel = CodeModel::Medium; // isn't good enough on x86 so use Medium, it has no cost because only the image goes in .ldata |
1614 | 1616 | } |
1615 | 1617 | std::unique_ptr<TargetMachine> SourceTM( |
1616 | 1618 | jl_ExecutionEngine->getTarget().createTargetMachine( |
@@ -1653,6 +1655,12 @@ void jl_dump_native_impl(void *native_code, |
1653 | 1655 | GlobalVariable::ExternalLinkage, |
1654 | 1656 | data, "jl_system_image_data"); |
1655 | 1657 | sysdata->setAlignment(Align(64)); |
| 1658 | +#if JL_LLVM_VERSION >= 180000 |
| 1659 | + sysdata->setCodeModel(CodeModel::Large); |
| 1660 | +#else |
| 1661 | + if (TheTriple.isX86() && TheTriple.isArch64Bit() && TheTriple.isOSLinux()) |
| 1662 | + sysdata->setSection(".ldata"); |
| 1663 | +#endif |
1656 | 1664 | addComdat(sysdata, TheTriple); |
1657 | 1665 | Constant *len = ConstantInt::get(sysimgM.getDataLayout().getIntPtrType(Context), z->size); |
1658 | 1666 | addComdat(new GlobalVariable(sysimgM, len->getType(), true, |
|
0 commit comments