-}
-
-static GlobalObject *makeInternalReplacement(GlobalObject *GO) {
- Module *M = GO->getParent();
- GlobalObject *Ret;
- if (auto *F = dyn_cast<Function>(GO)) {
- auto *NewF = Function::Create(
- F->getFunctionType(), GlobalValue::InternalLinkage, F->getName(), M);
- NewF->getBasicBlockList().splice(NewF->end(), F->getBasicBlockList());
- Ret = NewF;
- F->deleteBody();
- } else {
- auto *Var = cast<GlobalVariable>(GO);
- Ret = new GlobalVariable(
- *M, Var->getType()->getElementType(), Var->isConstant(),
- GlobalValue::InternalLinkage, Var->getInitializer(), Var->getName(),
- nullptr, Var->getThreadLocalMode(), Var->getType()->getAddressSpace(),
- Var->isExternallyInitialized());
- Var->setInitializer(nullptr);
- }
- Ret->copyAttributesFrom(GO);
- Ret->setComdat(GO->getComdat());
-
- return Ret;