Skip to content

Commit a8474dc

Browse files
authored
Merge pull request #49597 from JuliaLang/tb/llvm_attributes_bis
Improves #49551: Instead of copying attributes manually, just ensure we always call CloneFunctionInto, as it does useful work for declarations too.
2 parents 1a973c7 + b815bb1 commit a8474dc

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/llvm-remove-addrspaces.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ bool removeAddrspaces(Module &M, AddrspaceRemapFunction ASRemapper)
323323

324324
Function *NF = Function::Create(
325325
NFTy, F->getLinkage(), F->getAddressSpace(), Name, &M);
326-
NF->copyAttributesFrom(F);
326+
// no need to copy attributes here, that's done by CloneFunctionInto
327327
VMap[F] = NF;
328328
}
329329

@@ -356,11 +356,9 @@ bool removeAddrspaces(Module &M, AddrspaceRemapFunction ASRemapper)
356356

357357
// Similarly, copy over and rewrite function bodies
358358
for (Function *F : Functions) {
359-
if (F->isDeclaration())
360-
continue;
361-
362359
Function *NF = cast<Function>(VMap[F]);
363360
LLVM_DEBUG(dbgs() << "Processing function " << NF->getName() << "\n");
361+
// we also need this to run for declarations, or attributes won't be copied
364362

365363
Function::arg_iterator DestI = NF->arg_begin();
366364
for (Function::const_arg_iterator I = F->arg_begin(); I != F->arg_end();
@@ -410,9 +408,6 @@ bool removeAddrspaces(Module &M, AddrspaceRemapFunction ASRemapper)
410408
}
411409
NF->setAttributes(Attrs);
412410

413-
if (F->hasPersonalityFn())
414-
NF->setPersonalityFn(MapValue(F->getPersonalityFn(), VMap));
415-
416411
copyComdat(NF, F);
417412

418413
RemoveNoopAddrSpaceCasts(NF);

test/llvmpasses/remove-addrspaces.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ define void @byval_type([1 x {} addrspace(10)*] addrspace(11)* byval([1 x {} add
111111
}
112112

113113

114-
; COM: check that other function attributes are preserved
114+
; COM: check that function attributes are preserved on declarations too
115115
declare void @convergent_function() #0
116116
attributes #0 = { convergent }
117117
; CHECK: attributes #0 = { convergent }

0 commit comments

Comments
 (0)