Index: llvm/trunk/lib/IR/Globals.cpp =================================================================== --- llvm/trunk/lib/IR/Globals.cpp +++ llvm/trunk/lib/IR/Globals.cpp @@ -96,7 +96,6 @@ if (const auto *GV = dyn_cast(Src)) { setAlignment(GV->getAlignment()); setSection(GV->getSection()); - setComdat(const_cast(GV)->getComdat()); } } Index: llvm/trunk/lib/Linker/IRMover.cpp =================================================================== --- llvm/trunk/lib/Linker/IRMover.cpp +++ llvm/trunk/lib/Linker/IRMover.cpp @@ -637,11 +637,6 @@ NewGV->copyAttributesFrom(SGV); - // Don't copy the comdat, it's from the original module. We'll handle it - // later. - if (auto *NewGO = dyn_cast(NewGV)) - NewGO->setComdat(nullptr); - // Remove these copied constants in case this stays a declaration, since // they point to the source module. If the def is linked the values will // be mapped in during linkFunctionBody. Index: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp =================================================================== --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -147,6 +147,7 @@ // Create the new function body and insert it into the module... Function *NF = Function::Create(NFTy, Fn.getLinkage()); NF->copyAttributesFrom(&Fn); + NF->setComdat(Fn.getComdat()); Fn.getParent()->getFunctionList().insert(Fn.getIterator(), NF); NF->takeName(&Fn); @@ -813,6 +814,7 @@ // Create the new function body and insert it into the module... Function *NF = Function::Create(NFTy, F->getLinkage()); NF->copyAttributesFrom(F); + NF->setComdat(F->getComdat()); NF->setAttributes(NewPAL); // Insert the new function before the old function, so we won't be processing // it again.