@@ -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);
0 commit comments