Skip to content

Commit 6330398

Browse files
authored
Merge pull request #43417 from JuliaLang/vc/backport_llvm_13
[LLVM] Support LLVM 13.0.0
2 parents cba3abf + 1c68695 commit 6330398

34 files changed

+122
-89
lines changed

doc/src/devdocs/llvm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ environment. In addition, it exposes the `-julia` meta-pass, which runs the
7979
entire Julia pass-pipeline over the IR. As an example, to generate a system
8080
image, one could do:
8181
```
82-
opt -load libjulia-internal.so -julia -o opt.bc unopt.bc
82+
opt -enable-new-pm=0 -load libjulia-internal.so -julia -o opt.bc unopt.bc
8383
llc -o sys.o opt.bc
8484
cc -shared -o sys.so sys.o
8585
```

src/abi_aarch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ Type *isHFAorHVA(jl_datatype_t *dt, size_t &nele, LLVMContext &ctx) const
187187
return NULL;
188188
}
189189

190-
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
190+
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
191191
{
192192
// B.2
193193
// If the argument type is an HFA or an HVA, then the argument is used

src/abi_arm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
struct ABI_ARMLayout : AbiLayout {
2525

26-
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &abi, LLVMContext &ctx) override
26+
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &abi, LLVMContext &ctx, Type *Ty) override
2727
{
2828
return false;
2929
}

src/abi_llvm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bool use_sret(jl_datatype_t *ty, LLVMContext &ctx) override
4545
return false;
4646
}
4747

48-
bool needPassByRef(jl_datatype_t *ty, AttrBuilder &ab, LLVMContext &ctx) override
48+
bool needPassByRef(jl_datatype_t *ty, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
4949
{
5050
return false;
5151
}

src/abi_ppc64le.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,16 @@ bool use_sret(jl_datatype_t *dt, LLVMContext &ctx) override
101101
return false;
102102
}
103103

104-
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
104+
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
105105
{
106106
jl_datatype_t *ty0 = NULL;
107107
bool hva = false;
108108
if (jl_datatype_size(dt) > 64 && isHFA(dt, &ty0, &hva) > 8) {
109+
#if JL_LLVM_VERSION < 120000
109110
ab.addAttribute(Attribute::ByVal);
111+
#else
112+
ab.addByValAttr(Ty);
113+
#endif
110114
return true;
111115
}
112116
return false;

src/abi_win32.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ bool use_sret(jl_datatype_t *dt, LLVMContext &ctx) override
4949
return true;
5050
}
5151

52-
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
52+
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
5353
{
5454
// Use pass by reference for all structs
5555
if (dt->layout->nfields > 0) {
56+
#if JL_LLVM_VERSION < 120000
5657
ab.addAttribute(Attribute::ByVal);
58+
#else
59+
ab.addByValAttr(Ty);
60+
#endif
5761
return true;
5862
}
5963
return false;

src/abi_win64.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,19 @@ bool use_sret(jl_datatype_t *dt, LLVMContext &ctx) override
5656
return true;
5757
}
5858

59-
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
59+
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
6060
{
6161
nargs++;
6262
size_t size = jl_datatype_size(dt);
6363
if (win64_reg_size(size))
6464
return false;
65-
if (nargs <= 4)
65+
if (nargs <= 4) {
66+
#if JL_LLVM_VERSION < 120000
6667
ab.addAttribute(Attribute::ByVal);
68+
#else
69+
ab.addByValAttr(Ty);
70+
#endif
71+
}
6772
return true;
6873
}
6974

src/abi_x86.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,16 @@ bool use_sret(jl_datatype_t *dt, LLVMContext &ctx) override
6767
return true;
6868
}
6969

70-
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
70+
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
7171
{
7272
size_t size = jl_datatype_size(dt);
7373
if (is_complex64(dt) || is_complex128(dt) || (jl_is_primitivetype(dt) && size <= 8))
7474
return false;
75-
ab.addAttribute(Attribute::ByVal);
75+
#if JL_LLVM_VERSION < 120000
76+
ab.addAttribute(Attribute::ByVal);
77+
#else
78+
ab.addByValAttr(Ty);
79+
#endif
7680
return true;
7781
}
7882

src/abi_x86_64.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,15 @@ bool use_sret(jl_datatype_t *dt, LLVMContext &ctx) override
178178
return sret;
179179
}
180180

181-
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
181+
bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
182182
{
183183
Classification cl = classify(dt);
184184
if (cl.isMemory) {
185+
#if JL_LLVM_VERSION < 120000
185186
ab.addAttribute(Attribute::ByVal);
187+
#else
188+
ab.addByValAttr(Ty);
189+
#endif
186190
return true;
187191
}
188192

@@ -202,7 +206,12 @@ bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) overrid
202206
else if (jl_is_structtype(dt)) {
203207
// spill to memory even though we would ordinarily pass
204208
// it in registers
209+
#if JL_LLVM_VERSION < 120000
205210
ab.addAttribute(Attribute::ByVal);
211+
#else
212+
Type* Ty = preferred_llvm_type(dt, false, ctx);
213+
ab.addByValAttr(Ty);
214+
#endif
206215
return true;
207216
}
208217
return false;

src/aotcompile.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@ void jl_dump_native_impl(void *native_code,
550550
std::unique_ptr<Module> sysimage(new Module("sysimage", Context));
551551
sysimage->setTargetTriple(data->M->getTargetTriple());
552552
sysimage->setDataLayout(data->M->getDataLayout());
553+
#if JL_LLVM_VERSION >= 130000
554+
sysimage->setStackProtectorGuard(data->M->getStackProtectorGuard());
555+
sysimage->setOverrideStackAlignment(data->M->getOverrideStackAlignment());
556+
#endif
553557
data->M.reset(); // free memory for data->M
554558

555559
if (sysimg_data) {

0 commit comments

Comments
 (0)