Skip to content

Commit 5d2435b

Browse files
authored
Merge pull request #657 from JuliaLLVM/tb/llvm23
Support LLVM 23
2 parents 861f61c + 318a0c7 commit 5d2435b

18 files changed

Lines changed: 14967 additions & 27 deletions

File tree

‎NEWS.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
## LLVM.jl v10.1
55

6+
LLVM 23 is supported. Its conditional and unconditional branch opcodes are exposed as
7+
`LLVM.Opcode.CondBr` and `LLVM.Opcode.UncondBr`; both use `BrInst`.
8+
Byte types and constants use `ByteType` and `ConstantByte`.
9+
Size optimization pipelines (`Os`, `Oz`) were removed in LLVM 23; use `O2` with
10+
`optsize` or `minsize` function attributes instead.
11+
612
### Analyses
713

814
Custom passes written in Julia can now use LLVM's analyses. A function pass created with

‎Project.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ BFloat16sExt = "BFloat16s"
2323
[compat]
2424
BFloat16s = "0.4, 0.5, 0.6"
2525
CEnum = "0.2, 0.3, 0.4, 0.5"
26-
LLVMExtra_jll = "=0.0.51"
26+
LLVMExtra_jll = "=0.0.52"
2727
Libdl = "1.8"
2828
PrecompileTools = "1"
2929
Preferences = "1.4"

‎deps/LLVMExtra/include/LLVMExtra.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include <llvm-c/Target.h>
88
#include <llvm-c/Transforms/PassBuilder.h>
99
#include <llvm-c/Types.h>
10+
#ifdef __cplusplus
1011
#include <llvm/Support/CBindingWrapping.h>
12+
#endif
1113

1214
LLVM_C_EXTERN_C_BEGIN
1315

‎deps/LLVMExtra/lib/Analysis.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ LLVMBool LLVMExtraComputeConstantRange(LLVMValueRef V, LLVMBool ForSigned,
271271
return false;
272272
auto *Ctx = CxtI ? unwrap<Instruction>(CxtI) : nullptr;
273273
#if LLVM_VERSION_MAJOR >= 23
274+
if (auto *CI = dyn_cast<ConstantInt>(Val)) {
275+
writeRange(ConstantRange(CI->getValue()), Lower, Upper);
276+
return true;
277+
}
274278
const DataLayout *Layout = queryDataLayout(DL, Val, Ctx);
275279
if (!Layout)
276280
return false;
@@ -406,7 +410,12 @@ LLVMSCEVRef LLVMExtraScalarEvolutionGetAddExpr(LLVMScalarEvolutionRef SE, LLVMSC
406410
Operands.push_back(unwrap(Ops[I]));
407411
if (Operands.empty() || !areCompatibleOperands(*unwrap(SE), Operands, 1))
408412
return nullptr;
413+
#if LLVM_VERSION_MAJOR >= 23
414+
SmallVector<SCEVUse, 4> Uses(Operands.begin(), Operands.end());
415+
return wrap(unwrap(SE)->getAddExpr(Uses));
416+
#else
409417
return wrap(unwrap(SE)->getAddExpr(Operands));
418+
#endif
410419
}
411420

412421
LLVMSCEVRef LLVMExtraScalarEvolutionGetMinusSCEV(LLVMScalarEvolutionRef SE, LLVMSCEVRef LHS,

‎deps/LLVMExtra/lib/Core.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ LLVMBool LLVMExtraGetFirstInsertionPt(LLVMBasicBlockRef BB, LLVMValueRef *Before
13321332
BasicBlock::iterator It = B->getFirstInsertionPt();
13331333
// the end of a terminated block is not a legal insertion point, which happens when the
13341334
// terminator is an EH pad (e.g., a catchswitch)
1335-
if (It == B->end() && B->getTerminator())
1335+
if (It == B->end() && !B->empty() && B->back().isTerminator())
13361336
return false;
13371337
readInsertionPoint(B, It, Before, Head);
13381338
return true;

‎deps/LLVMExtra/lib/NewPM.cpp‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,16 @@ class CustomTargetTransformInfo final
137137
}
138138
#endif
139139

140-
#if LLVM_VERSION_MAJOR >= 22
140+
#if LLVM_VERSION_MAJOR >= 23
141+
ValueUniformity getValueUniformity(const Value *V) const override {
142+
if (Opts.IsSourceOfDivergence &&
143+
Opts.IsSourceOfDivergence(wrap(V), Opts.IsSourceOfDivergenceUD) != 0)
144+
return ValueUniformity::NeverUniform;
145+
if (Opts.IsAlwaysUniform && Opts.IsAlwaysUniform(wrap(V), Opts.IsAlwaysUniformUD) != 0)
146+
return ValueUniformity::AlwaysUniform;
147+
return BaseT::getValueUniformity(V);
148+
}
149+
#elif LLVM_VERSION_MAJOR >= 22
141150
InstructionUniformity getInstructionUniformity(const Value *V) const override {
142151
if (Opts.IsSourceOfDivergence &&
143152
Opts.IsSourceOfDivergence(wrap(V), Opts.IsSourceOfDivergenceUD) != 0)

0 commit comments

Comments
 (0)