return GV == &F;
};
std::unique_ptr<Module> CM = CloneModule(*M, VMap, ShouldCloneDefinition);
+ Function *NewF = cast<Function>(VMap.lookup(&F));
+ assert(NewF && "Expected selected function to be cloned");
LLVM_DEBUG(dbgs() << "Global DCE...\n");
+ // Stop F itself from being pruned
+ GlobalValue::LinkageTypes OrigLinkage = NewF->getLinkage();
+ NewF->setLinkage(GlobalValue::ExternalLinkage);
+
{
ModuleAnalysisManager MAM;
ModulePassManager MPM;
MPM.run(*CM, MAM);
}
+ // Restore old linkage
+ NewF->setLinkage(OrigLinkage);
+
LLVM_DEBUG(dbgs() << "Write to file '" << Dumpfile << "'...\n");
std::unique_ptr<ToolOutputFile> Out;
@callee_alias = dso_local unnamed_addr alias void(i32, double*, i32), void(i32, double*, i32 )* @callee
-define void @callee(i32 %n, double* noalias nonnull %A, i32 %i) {
+define internal void @callee(i32 %n, double* noalias nonnull %A, i32 %i) {
entry:
br label %for
}
-define void @caller(i32 %n, double* noalias nonnull %A) {
+define internal void @caller(i32 %n, double* noalias nonnull %A) {
entry:
br label %for