Skip to content

Commit 5c6d5de

Browse files
authored
Adapt some more code for LLVM 20 (#57793)
I missed some deprecations in the previous pr and if we're using jitlink another header file needs to be included.
1 parent f3474b5 commit 5c6d5de

File tree

7 files changed

+45
-4
lines changed

7 files changed

+45
-4
lines changed

src/codegen.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5823,7 +5823,11 @@ static void emit_phinode_assign(jl_codectx_t &ctx, ssize_t idx, jl_value_t *r)
58235823
unsigned nb = jl_datatype_size(phiType);
58245824
dest = emit_static_alloca(ctx, nb, align);
58255825
phi = cast<AllocaInst>(dest->clone());
5826+
#if JL_LLVM_VERSION >= 200000
5827+
phi->insertBefore(dest->getIterator());
5828+
#else
58265829
phi->insertBefore(dest);
5830+
#endif
58275831
ctx.builder.CreateMemCpy(phi, align, dest, align, nb, false);
58285832
ctx.builder.CreateLifetimeEnd(dest);
58295833
}

src/jitlayers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#include <llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h>
1616
#include <llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h>
1717
#if JL_LLVM_VERSION >= 200000
18-
#include "llvm/ExecutionEngine/Orc/AbsoluteSymbols.h"
18+
#include <llvm/ExecutionEngine/Orc/AbsoluteSymbols.h>
19+
#include <llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h>
1920
#endif
2021
#if JL_LLVM_VERSION >= 180000
2122
#include <llvm/ExecutionEngine/Orc/Debugging/DebugInfoSupport.h>

src/llvm-julia-licm.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ static void moveInstructionBefore(Instruction &I, Instruction &Dest,
5959
MemorySSAUpdater &MSSAU,
6060
ScalarEvolution *SE,
6161
MemorySSA::InsertionPlace Place = MemorySSA::BeforeTerminator) {
62+
#if JL_LLVM_VERSION >= 200000
63+
I.moveBefore(Dest.getIterator());
64+
#else
6265
I.moveBefore(&Dest);
66+
#endif
6367
if (MSSAU.getMemorySSA())
6468
if (MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
6569
MSSAU.getMemorySSA()->getMemoryAccess(&I)))

src/llvm-late-gc-lowering.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,11 @@ void LateLowerGCFrame::PlaceGCFrameStore(State &S, unsigned R, unsigned MinColor
23722372
// free to rewrite them if convenient. We need to change
23732373
// it back here for the store.
23742374
assert(Val->getType() == T_prjlvalue);
2375+
#if JL_LLVM_VERSION >= 200000
23752376
new StoreInst(Val, slotAddress, InsertBefore->getIterator());
2377+
#else
2378+
new StoreInst(Val, slotAddress, InsertBefore);
2379+
#endif
23762380
}
23772381

23782382
void LateLowerGCFrame::PlaceGCFrameReset(State &S, unsigned R, unsigned MinColorRoot,
@@ -2382,10 +2386,18 @@ void LateLowerGCFrame::PlaceGCFrameReset(State &S, unsigned R, unsigned MinColor
23822386
auto slotAddress = CallInst::Create(
23832387
getOrDeclare(jl_intrinsics::getGCFrameSlot),
23842388
{GCFrame, ConstantInt::get(Type::getInt32Ty(InsertBefore->getContext()), Colors[R] + MinColorRoot)},
2389+
#if JL_LLVM_VERSION >= 200000
2390+
"gc_slot_addr_" + StringRef(std::to_string(Colors[R] + MinColorRoot)), InsertBefore->getIterator());
2391+
#else
23852392
"gc_slot_addr_" + StringRef(std::to_string(Colors[R] + MinColorRoot)), InsertBefore);
2393+
#endif
23862394
// Reset the slot to NULL.
23872395
Value *Val = ConstantPointerNull::get(T_prjlvalue);
2396+
#if JL_LLVM_VERSION >= 200000
2397+
new StoreInst(Val, slotAddress, InsertBefore->getIterator());
2398+
#else
23882399
new StoreInst(Val, slotAddress, InsertBefore);
2400+
#endif
23892401
}
23902402

23912403
void LateLowerGCFrame::PlaceGCFrameStores(State &S, unsigned MinColorRoot,
@@ -2406,7 +2418,7 @@ void LateLowerGCFrame::PlaceGCFrameStores(State &S, unsigned MinColorRoot,
24062418
for (int Idx : *LastLive) {
24072419
if (Colors[Idx] >= PreAssignedColors && !HasBitSet(NowLive, Idx)) {
24082420
PlaceGCFrameReset(S, Idx, MinColorRoot, Colors, GCFrame,
2409-
S.ReverseSafepointNumbering[*rit]);
2421+
S.ReverseSafepointNumbering[*rit]);
24102422
}
24112423
}
24122424
// store values which are alive in this safepoint but
@@ -2438,7 +2450,7 @@ void LateLowerGCFrame::PlaceRootsAndUpdateCalls(ArrayRef<int> Colors, int PreAss
24382450
getOrDeclare(jl_intrinsics::newGCFrame),
24392451
{ConstantInt::get(T_int32, 0)},
24402452
"gcframe");
2441-
gcframe->insertBefore(&*F->getEntryBlock().begin());
2453+
gcframe->insertBefore(F->getEntryBlock().begin());
24422454

24432455
auto pushGcframe = CallInst::Create(
24442456
getOrDeclare(jl_intrinsics::pushGCFrame),
@@ -2536,7 +2548,11 @@ void LateLowerGCFrame::PlaceRootsAndUpdateCalls(ArrayRef<int> Colors, int PreAss
25362548
assert(Elem->getType() == T_prjlvalue);
25372549
//auto Idxs = ArrayRef<unsigned>(Tracked[i]);
25382550
//Value *Elem = ExtractScalar(Base, true, Idxs, SI);
2551+
#if JL_LLVM_VERSION >= 200000
25392552
Value *shadowStore = new StoreInst(Elem, slotAddress, SI->getIterator());
2553+
#else
2554+
Value *shadowStore = new StoreInst(Elem, slotAddress, SI);
2555+
#endif
25402556
(void)shadowStore;
25412557
// TODO: shadowStore->setMetadata(LLVMContext::MD_tbaa, tbaa_gcframe);
25422558
AllocaSlot++;
@@ -2554,7 +2570,11 @@ void LateLowerGCFrame::PlaceRootsAndUpdateCalls(ArrayRef<int> Colors, int PreAss
25542570
auto popGcframe = CallInst::Create(
25552571
getOrDeclare(jl_intrinsics::popGCFrame),
25562572
{gcframe});
2573+
#if JL_LLVM_VERSION >= 200000
2574+
popGcframe->insertBefore(BB.getTerminator()->getIterator());
2575+
#else
25572576
popGcframe->insertBefore(BB.getTerminator());
2577+
#endif
25582578
}
25592579
}
25602580
}

src/llvm-propagate-addrspaces.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,11 @@ bool propagateJuliaAddrspaces(Function &F) {
289289
PropagateJuliaAddrspacesVisitor visitor;
290290
visitor.visit(F);
291291
for (auto it : visitor.ToInsert)
292+
#if JL_LLVM_VERSION >= 200000
293+
it.first->insertBefore(it.second->getIterator());
294+
#else
292295
it.first->insertBefore(it.second);
296+
#endif
293297
for (Instruction *I : visitor.ToDelete)
294298
I->eraseFromParent();
295299
visitor.ToInsert.clear();

src/llvm-ptls.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,11 @@ void LowerPTLS::fix_pgcstack_use(CallInst *pgcstack, Function *pgcstack_getter,
179179
adoptFunc->copyMetadata(pgcstack_getter, 0);
180180
}
181181
adopt->setCalledFunction(adoptFunc);
182+
#if JL_LLVM_VERSION >= 200000
183+
adopt->insertBefore(slowTerm->getIterator());
184+
#else
182185
adopt->insertBefore(slowTerm);
186+
#endif
183187
phi->addIncoming(adopt, slowTerm->getParent());
184188
// emit fast branch code
185189
builder.SetInsertPoint(fastTerm->getParent());
@@ -237,7 +241,11 @@ void LowerPTLS::fix_pgcstack_use(CallInst *pgcstack, Function *pgcstack_getter,
237241
builder.SetInsertPoint(pgcstack);
238242
auto phi = builder.CreatePHI(T_pppjlvalue, 2, "pgcstack");
239243
pgcstack->replaceAllUsesWith(phi);
244+
#if JL_LLVM_VERSION >= 200000
245+
pgcstack->moveBefore(slowTerm->getIterator());
246+
#else
240247
pgcstack->moveBefore(slowTerm);
248+
#endif
241249
// refresh the basic block in the builder
242250
builder.SetInsertPoint(pgcstack);
243251
auto getter = builder.CreateLoad(T_pgcstack_getter, pgcstack_func_slot);

test/llvmpasses/gcroots.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ define i8 @gather_arrayptrs_alltrue() {
764764
; OPAQUE: %gcframe = alloca ptr addrspace(10), i32 3
765765

766766

767-
; OPAQUE: %arrayptrs = call <2 x ptr addrspace(13)> @llvm.masked.gather.v2p13.v2p11(<2 x ptr addrspace(11)> %arrayptrptrs, i32 16, <2 x i1> <i1 true, i1 true>, <2 x ptr addrspace(13)> zeroinitializer)
767+
; OPAQUE: %arrayptrs = call <2 x ptr addrspace(13)> @llvm.masked.gather.v2p13.v2p11(<2 x ptr addrspace(11)> %arrayptrptrs, i32 16, <2 x i1> {{(<i1 true, i1 true>|splat \(i1 true\))}}, <2 x ptr addrspace(13)> zeroinitializer)
768768
; OPAQUE: [[GEP0:%.*]] = getelementptr inbounds ptr addrspace(10), ptr %gcframe, i32 2
769769
; OPAQUE: store ptr addrspace(10) %obj1, ptr [[GEP0]]
770770
;

0 commit comments

Comments
 (0)