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

Using LLVM uses instead of going through every instruction #74

Merged
merged 6 commits into from
Nov 27, 2024
Merged
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
2 changes: 0 additions & 2 deletions src/gc-mmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,6 @@ inline jl_value_t *jl_gc_alloc_(jl_ptls_t ptls, size_t sz, void *ty)
return v;
}



// allocation wrappers that track allocation and let collection run
JL_DLLEXPORT void *jl_gc_counted_malloc(size_t sz)
{
Expand Down
29 changes: 15 additions & 14 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2607,22 +2607,23 @@ bool LateLowerGCFrame::runOnFunction(Function &F, bool *CFGModified) {

#ifdef MMTK_GC
// We lower the julia.gc_alloc_bytes intrinsic in this pass to insert slowpath/fastpath blocks for MMTk
for (BasicBlock &BB : F) {
for (auto it = BB.begin(); it != BB.end();) {
auto *CI = dyn_cast<CallInst>(&*it);
if (!CI) {
++it;
continue;
}
auto GCAllocBytes = getOrNull(jl_intrinsics::GCAllocBytes);

Value *callee = CI->getCalledOperand();
assert(callee);

auto GCAllocBytes = getOrNull(jl_intrinsics::GCAllocBytes);
if (GCAllocBytes == callee) {
if (GCAllocBytes) {
for (auto it = GCAllocBytes->user_begin(); it != GCAllocBytes->user_end(); ) {
if (auto *CI = dyn_cast<CallInst>(*it)) {
*CFGModified = true;
replaceInstruction(CI, lowerGCAllocBytesLate(CI, F), it);
continue;

Value *callee = CI->getCalledOperand();
assert(callee == GCAllocBytes);

auto newI = lowerGCAllocBytesLate(CI, F);
if (newI != CI) {
++it;
CI->replaceAllUsesWith(newI);
CI->eraseFromParent();
continue;
}
}
++it;
}
Expand Down