Skip to content

Commit b66e38c

Browse files
apaz-cliDilumAluthge
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 90ee1b5 commit b66e38c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/llvm-alloc-opt.cpp

+1-1
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->args()) {
5051
if (!isa<Constant>(arg.get())) {
5152
return;
@@ -1079,7 +1080,6 @@ void Optimizer::splitOnStack(CallInst *orig_inst)
10791080
}
10801081
auto new_call = builder.CreateCall(pass.gc_preserve_begin_func, operands);
10811082
new_call->takeName(call);
1082-
new_call->setAttributes(call->getAttributes());
10831083
call->replaceAllUsesWith(new_call);
10841084
call->eraseFromParent();
10851085
return;

test/llvmpasses/alloc-opt-pass.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ define void @preserve_branches(i8* %fptr, i1 %b, i1 %b2) {
3131
3232
L1:
3333
%v = call noalias {} addrspace(10)* @julia.gc_alloc_obj(i8* %ptls_i8, $isz 8, {} addrspace(10)* @tag)
34-
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v)
34+
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* nonnull %v)
3535
call void @external_function()
3636
br i1 %b2, label %L2, label %L3
3737
@@ -67,7 +67,7 @@ define void @preserve_branches2(i8* %fptr, i1 %b, i1 %b2) {
6767
6868
L1:
6969
%v = call noalias {} addrspace(10)* @julia.gc_alloc_obj(i8* %ptls_i8, $isz 8, {} addrspace(10)* @tag)
70-
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v, {} addrspace(10)* %v2)
70+
%tok = call token (...) @llvm.julia.gc_preserve_begin({} addrspace(10)* %v, {} addrspace(10)* nonnull %v2)
7171
call void @external_function()
7272
br i1 %b2, label %L2, label %L3
7373

0 commit comments

Comments
 (0)