Skip to content

Commit

Permalink
Removed attributes from arguments to gc_preserve_begin (#47482)
Browse files Browse the repository at this point in the history
LLVM adds the nonnull attribute on its own, which makes
the verifier fail.

Fixes #47245

(cherry picked from commit bc39fd1)
  • Loading branch information
apaz-cli authored and KristofferC committed Dec 21, 2022
1 parent 0668ee4 commit e0b8288
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/llvm-alloc-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static void removeGCPreserve(CallInst *call, Instruction *val)
{
auto replace = Constant::getNullValue(val->getType());
call->replaceUsesOfWith(val, replace);
call->setAttributes(AttributeList());
for (auto &arg: call->arg_operands()) {
if (!isa<Constant>(arg.get())) {
return;
Expand Down Expand Up @@ -1426,7 +1427,6 @@ void Optimizer::splitOnStack(CallInst *orig_inst)
}
auto new_call = builder.CreateCall(pass.gc_preserve_begin_func, operands);
new_call->takeName(call);
new_call->setAttributes(call->getAttributes());
call->replaceAllUsesWith(new_call);
call->eraseFromParent();
return;
Expand Down
4 changes: 2 additions & 2 deletions test/llvmpasses/alloc-opt-pass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ define void @preserve_branches(i8* %fptr, i1 %b, i1 %b2) {
L1:
%v = call noalias {} addrspace(10)* @julia.gc_alloc_obj(i8* %ptls_i8, $isz 8, {} addrspace(10)* @tag)
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v)
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* nonnull %v)
call void @external_function()
br i1 %b2, label %L2, label %L3
Expand Down Expand Up @@ -65,7 +65,7 @@ define void @preserve_branches2(i8* %fptr, i1 %b, i1 %b2) {
L1:
%v = call noalias {} addrspace(10)* @julia.gc_alloc_obj(i8* %ptls_i8, $isz 8, {} addrspace(10)* @tag)
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v, {} addrspace(10)* %v2)
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v, {} addrspace(10)* nonnull %v2)
call void @external_function()
br i1 %b2, label %L2, label %L3
Expand Down

0 comments on commit e0b8288

Please sign in to comment.