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