|
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> |
@@ -1506,10 +1507,11 @@ void jl_dump_native_impl(void *native_code, |
1506 | 1507 | if (TheTriple.isOSLinux() || TheTriple.isOSFreeBSD()) { |
1507 | 1508 | RelocModel = Reloc::PIC_; |
1508 | 1509 | } |
| 1510 | + |
1509 | 1511 | CodeModel::Model CMModel = CodeModel::Small; |
1510 | | - if (TheTriple.isPPC()) { |
1511 | | - // On PPC the small model is limited to 16bit offsets |
1512 | | - CMModel = CodeModel::Medium; |
| 1512 | + if (TheTriple.isPPC() || (TheTriple.isX86() && TheTriple.isArch64Bit() && TheTriple.isOSLinux())) { |
| 1513 | + // On PPC the small model is limited to 16bit offsets. For very large images the small code model |
| 1514 | + CMModel = CodeModel::Medium; // isn't good enough on x86 so use Medium, it has no cost because only the image goes in .ldata |
1513 | 1515 | } |
1514 | 1516 | std::unique_ptr<TargetMachine> SourceTM( |
1515 | 1517 | jl_ExecutionEngine->getTarget().createTargetMachine( |
@@ -1549,6 +1551,12 @@ void jl_dump_native_impl(void *native_code, |
1549 | 1551 | GlobalVariable::ExternalLinkage, |
1550 | 1552 | data, "jl_system_image_data"); |
1551 | 1553 | sysdata->setAlignment(Align(64)); |
| 1554 | +#if JL_LLVM_VERSION >= 180000 |
| 1555 | + sysdata->setCodeModel(CodeModel::Large); |
| 1556 | +#else |
| 1557 | + if (TheTriple.isX86() && TheTriple.isArch64Bit() && TheTriple.isOSLinux()) |
| 1558 | + sysdata->setSection(".ldata"); |
| 1559 | +#endif |
1552 | 1560 | addComdat(sysdata, TheTriple); |
1553 | 1561 | Constant *len = ConstantInt::get(sysimgM.getDataLayout().getIntPtrType(Context), z->size); |
1554 | 1562 | addComdat(new GlobalVariable(sysimgM, len->getType(), true, |
|
0 commit comments