Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt some more code for LLVM 20 #57793

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5824,7 +5824,11 @@ static void emit_phinode_assign(jl_codectx_t &ctx, ssize_t idx, jl_value_t *r)
unsigned nb = jl_datatype_size(phiType);
dest = emit_static_alloca(ctx, nb, align);
phi = cast<AllocaInst>(dest->clone());
#if JL_LLVM_VERSION >= 200000
phi->insertBefore(dest->getIterator());
#else
phi->insertBefore(dest);
#endif
ctx.builder.CreateMemCpy(phi, align, dest, align, nb, false);
ctx.builder.CreateLifetimeEnd(dest);
}
Expand Down
3 changes: 2 additions & 1 deletion src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#include <llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h>
#include <llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h>
#if JL_LLVM_VERSION >= 200000
#include "llvm/ExecutionEngine/Orc/AbsoluteSymbols.h"
#include <llvm/ExecutionEngine/Orc/AbsoluteSymbols.h>
#include <llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h>
#endif
#if JL_LLVM_VERSION >= 180000
#include <llvm/ExecutionEngine/Orc/Debugging/DebugInfoSupport.h>
Expand Down
4 changes: 4 additions & 0 deletions src/llvm-julia-licm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ static void moveInstructionBefore(Instruction &I, Instruction &Dest,
MemorySSAUpdater &MSSAU,
ScalarEvolution *SE,
MemorySSA::InsertionPlace Place = MemorySSA::BeforeTerminator) {
#if JL_LLVM_VERSION >= 200000
I.moveBefore(Dest.getIterator());
#else
I.moveBefore(&Dest);
#endif
if (MSSAU.getMemorySSA())
if (MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
MSSAU.getMemorySSA()->getMemoryAccess(&I)))
Expand Down
24 changes: 22 additions & 2 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2372,7 +2372,11 @@ void LateLowerGCFrame::PlaceGCFrameStore(State &S, unsigned R, unsigned MinColor
// free to rewrite them if convenient. We need to change
// it back here for the store.
assert(Val->getType() == T_prjlvalue);
#if JL_LLVM_VERSION >= 200000
new StoreInst(Val, slotAddress, InsertBefore->getIterator());
#else
new StoreInst(Val, slotAddress, InsertBefore);
#endif
}

void LateLowerGCFrame::PlaceGCFrameReset(State &S, unsigned R, unsigned MinColorRoot,
Expand All @@ -2382,10 +2386,18 @@ void LateLowerGCFrame::PlaceGCFrameReset(State &S, unsigned R, unsigned MinColor
auto slotAddress = CallInst::Create(
getOrDeclare(jl_intrinsics::getGCFrameSlot),
{GCFrame, ConstantInt::get(Type::getInt32Ty(InsertBefore->getContext()), Colors[R] + MinColorRoot)},
#if JL_LLVM_VERSION >= 200000
"gc_slot_addr_" + StringRef(std::to_string(Colors[R] + MinColorRoot)), InsertBefore->getIterator());
#else
"gc_slot_addr_" + StringRef(std::to_string(Colors[R] + MinColorRoot)), InsertBefore);
#endif
// Reset the slot to NULL.
Value *Val = ConstantPointerNull::get(T_prjlvalue);
#if JL_LLVM_VERSION >= 200000
new StoreInst(Val, slotAddress, InsertBefore->getIterator());
#else
new StoreInst(Val, slotAddress, InsertBefore);
#endif
}

void LateLowerGCFrame::PlaceGCFrameStores(State &S, unsigned MinColorRoot,
Expand All @@ -2406,7 +2418,7 @@ void LateLowerGCFrame::PlaceGCFrameStores(State &S, unsigned MinColorRoot,
for (int Idx : *LastLive) {
if (Colors[Idx] >= PreAssignedColors && !HasBitSet(NowLive, Idx)) {
PlaceGCFrameReset(S, Idx, MinColorRoot, Colors, GCFrame,
S.ReverseSafepointNumbering[*rit]);
S.ReverseSafepointNumbering[*rit]);
}
}
// store values which are alive in this safepoint but
Expand Down Expand Up @@ -2438,7 +2450,7 @@ void LateLowerGCFrame::PlaceRootsAndUpdateCalls(ArrayRef<int> Colors, int PreAss
getOrDeclare(jl_intrinsics::newGCFrame),
{ConstantInt::get(T_int32, 0)},
"gcframe");
gcframe->insertBefore(&*F->getEntryBlock().begin());
gcframe->insertBefore(F->getEntryBlock().begin());

auto pushGcframe = CallInst::Create(
getOrDeclare(jl_intrinsics::pushGCFrame),
Expand Down Expand Up @@ -2536,7 +2548,11 @@ void LateLowerGCFrame::PlaceRootsAndUpdateCalls(ArrayRef<int> Colors, int PreAss
assert(Elem->getType() == T_prjlvalue);
//auto Idxs = ArrayRef<unsigned>(Tracked[i]);
//Value *Elem = ExtractScalar(Base, true, Idxs, SI);
#if JL_LLVM_VERSION >= 200000
Value *shadowStore = new StoreInst(Elem, slotAddress, SI->getIterator());
#else
Value *shadowStore = new StoreInst(Elem, slotAddress, SI);
#endif
(void)shadowStore;
// TODO: shadowStore->setMetadata(LLVMContext::MD_tbaa, tbaa_gcframe);
AllocaSlot++;
Expand All @@ -2554,7 +2570,11 @@ void LateLowerGCFrame::PlaceRootsAndUpdateCalls(ArrayRef<int> Colors, int PreAss
auto popGcframe = CallInst::Create(
getOrDeclare(jl_intrinsics::popGCFrame),
{gcframe});
#if JL_LLVM_VERSION >= 200000
popGcframe->insertBefore(BB.getTerminator()->getIterator());
#else
popGcframe->insertBefore(BB.getTerminator());
#endif
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/llvm-propagate-addrspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ bool propagateJuliaAddrspaces(Function &F) {
PropagateJuliaAddrspacesVisitor visitor;
visitor.visit(F);
for (auto it : visitor.ToInsert)
#if JL_LLVM_VERSION >= 200000
it.first->insertBefore(it.second->getIterator());
#else
it.first->insertBefore(it.second);
#endif
for (Instruction *I : visitor.ToDelete)
I->eraseFromParent();
visitor.ToInsert.clear();
Expand Down
8 changes: 8 additions & 0 deletions src/llvm-ptls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ void LowerPTLS::fix_pgcstack_use(CallInst *pgcstack, Function *pgcstack_getter,
adoptFunc->copyMetadata(pgcstack_getter, 0);
}
adopt->setCalledFunction(adoptFunc);
#if JL_LLVM_VERSION >= 200000
adopt->insertBefore(slowTerm->getIterator());
#else
adopt->insertBefore(slowTerm);
#endif
phi->addIncoming(adopt, slowTerm->getParent());
// emit fast branch code
builder.SetInsertPoint(fastTerm->getParent());
Expand Down Expand Up @@ -237,7 +241,11 @@ void LowerPTLS::fix_pgcstack_use(CallInst *pgcstack, Function *pgcstack_getter,
builder.SetInsertPoint(pgcstack);
auto phi = builder.CreatePHI(T_pppjlvalue, 2, "pgcstack");
pgcstack->replaceAllUsesWith(phi);
#if JL_LLVM_VERSION >= 200000
pgcstack->moveBefore(slowTerm->getIterator());
#else
pgcstack->moveBefore(slowTerm);
#endif
// refresh the basic block in the builder
builder.SetInsertPoint(pgcstack);
auto getter = builder.CreateLoad(T_pgcstack_getter, pgcstack_func_slot);
Expand Down
2 changes: 1 addition & 1 deletion test/llvmpasses/gcroots.ll
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ define i8 @gather_arrayptrs_alltrue() {
; OPAQUE: %gcframe = alloca ptr addrspace(10), i32 3


; 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)
; 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)
; OPAQUE: [[GEP0:%.*]] = getelementptr inbounds ptr addrspace(10), ptr %gcframe, i32 2
; OPAQUE: store ptr addrspace(10) %obj1, ptr [[GEP0]]
;
Expand Down