Skip to content

Commit

Permalink
Pass ptls to intrinsic
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Oct 30, 2022
1 parent 1f80964 commit 49932df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/codegen_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ static inline void emit_gc_safepoint(llvm::IRBuilder<> &builder, llvm::Value *pt
// inline jlsafepoint_func->realize(M)
Function *F = M->getFunction("julia.safepoint");
if (!F) {
FunctionType *FT = FunctionType::get(Type::getVoidTy(C), false);
auto T_ppjlvalue = JuliaType::get_ppjlvalue_ty(builder.getContext());
FunctionType *FT = FunctionType::get(Type::getVoidTy(C), {T_ppjlvalue}, false);
F = Function::Create(FT, Function::ExternalLinkage, "julia.safepoint", M);
F->addAttributeAtIndex(AttributeList::FunctionIndex, Attribute::get(C, Attribute::InaccessibleMemOnly));
F->addAttributeAtIndex(AttributeList::FunctionIndex, Attribute::get(C, Attribute::ReadOnly));
F->addFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
}

builder.CreateCall(F);
builder.CreateCall(F, {ptls});
emit_signal_fence(builder);
}

Expand Down
10 changes: 5 additions & 5 deletions src/llvm-final-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct FinalLowerGC: private JuliaPassContext {
Value *lowerQueueGCBinding(CallInst *target, Function &F);

// Lowers a `julia.safepoint` intrinsic.
Value *lowerSafepoint(CallInst *target, Function &F, Value *pgcstack);
Value *lowerSafepoint(CallInst *target, Function &F);
};

Value *FinalLowerGC::lowerNewGCFrame(CallInst *target, Function &F)
Expand Down Expand Up @@ -205,13 +205,13 @@ Value *FinalLowerGC::lowerQueueGCBinding(CallInst *target, Function &F)
return target;
}

Value *FinalLowerGC::lowerSafepoint(CallInst *target, Function &F, Value *pgcstack)
Value *FinalLowerGC::lowerSafepoint(CallInst *target, Function &F)
{
++SafepointCount;
assert(target->arg_size() == 0);
assert(target->arg_size() == 1);
IRBuilder<> builder(target->getContext());
builder.SetInsertPoint(target);
Value* ptls = get_current_ptls_from_task(builder, get_current_task_from_pgcstack(builder, pgcstack), nullptr);
Value* ptls = target->getOperand(0);
Value* load = builder.CreateLoad(getSizeTy(builder.getContext()), get_current_signal_page_from_ptls(builder, ptls, nullptr), true);
return load;
}
Expand Down Expand Up @@ -373,7 +373,7 @@ bool FinalLowerGC::runOnFunction(Function &F)
replaceInstruction(CI, lowerQueueGCBinding(CI, F), it);
}
else if (callee == safepointFunc) {
lowerSafepoint(CI, F, pgcstack);
lowerSafepoint(CI, F);
it = CI->eraseFromParent();
}
else {
Expand Down

0 comments on commit 49932df

Please sign in to comment.