Skip to content

Commit e0b8288

Browse files
apaz-cliKristofferC
authored andcommitted
Removed attributes from arguments to gc_preserve_begin (#47482)
LLVM adds the nonnull attribute on its own, which makes the verifier fail. Fixes #47245 (cherry picked from commit bc39fd1)
1 parent 0668ee4 commit e0b8288

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/llvm-alloc-opt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static void removeGCPreserve(CallInst *call, Instruction *val)
4646
{
4747
auto replace = Constant::getNullValue(val->getType());
4848
call->replaceUsesOfWith(val, replace);
49+
call->setAttributes(AttributeList());
4950
for (auto &arg: call->arg_operands()) {
5051
if (!isa<Constant>(arg.get())) {
5152
return;
@@ -1426,7 +1427,6 @@ void Optimizer::splitOnStack(CallInst *orig_inst)
14261427
}
14271428
auto new_call = builder.CreateCall(pass.gc_preserve_begin_func, operands);
14281429
new_call->takeName(call);
1429-
new_call->setAttributes(call->getAttributes());
14301430
call->replaceAllUsesWith(new_call);
14311431
call->eraseFromParent();
14321432
return;

test/llvmpasses/alloc-opt-pass.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ define void @preserve_branches(i8* %fptr, i1 %b, i1 %b2) {
3030
3131
L1:
3232
%v = call noalias {} addrspace(10)* @julia.gc_alloc_obj(i8* %ptls_i8, $isz 8, {} addrspace(10)* @tag)
33-
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v)
33+
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* nonnull %v)
3434
call void @external_function()
3535
br i1 %b2, label %L2, label %L3
3636
@@ -65,7 +65,7 @@ define void @preserve_branches2(i8* %fptr, i1 %b, i1 %b2) {
6565
6666
L1:
6767
%v = call noalias {} addrspace(10)* @julia.gc_alloc_obj(i8* %ptls_i8, $isz 8, {} addrspace(10)* @tag)
68-
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v, {} addrspace(10)* %v2)
68+
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v, {} addrspace(10)* nonnull %v2)
6969
call void @external_function()
7070
br i1 %b2, label %L2, label %L3
7171

0 commit comments

Comments
 (0)