Skip to content

Commit bc39fd1

Browse files
authored
Removed attributes from arguments to gc_preserve_begin (#47482)
LLVM adds the nonnull attribute on its own, which makes the verifier fail. Fixes #47245
1 parent 59fab46 commit bc39fd1

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
@@ -58,6 +58,7 @@ static void removeGCPreserve(CallInst *call, Instruction *val)
5858
++RemovedGCPreserve;
5959
auto replace = Constant::getNullValue(val->getType());
6060
call->replaceUsesOfWith(val, replace);
61+
call->setAttributes(AttributeList());
6162
for (auto &arg: call->args()) {
6263
if (!isa<Constant>(arg.get())) {
6364
return;
@@ -1093,7 +1094,6 @@ void Optimizer::splitOnStack(CallInst *orig_inst)
10931094
}
10941095
auto new_call = builder.CreateCall(pass.gc_preserve_begin_func, operands);
10951096
new_call->takeName(call);
1096-
new_call->setAttributes(call->getAttributes());
10971097
call->replaceAllUsesWith(new_call);
10981098
call->eraseFromParent();
10991099
return;

test/llvmpasses/alloc-opt-pass.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ define void @preserve_branches(i8* %fptr, i1 %b, i1 %b2) {
3232
3333
L1:
3434
%v = call noalias {} addrspace(10)* @julia.gc_alloc_obj(i8* %ptls_i8, $isz 8, {} addrspace(10)* @tag)
35-
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v)
35+
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* nonnull %v)
3636
call void @external_function()
3737
br i1 %b2, label %L2, label %L3
3838
@@ -68,7 +68,7 @@ define void @preserve_branches2(i8* %fptr, i1 %b, i1 %b2) {
6868
6969
L1:
7070
%v = call noalias {} addrspace(10)* @julia.gc_alloc_obj(i8* %ptls_i8, $isz 8, {} addrspace(10)* @tag)
71-
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v, {} addrspace(10)* %v2)
71+
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v, {} addrspace(10)* nonnull %v2)
7272
call void @external_function()
7373
br i1 %b2, label %L2, label %L3
7474

0 commit comments

Comments
 (0)