Skip to content

Commit

Permalink
[Polly] Don't prune non-external function itself from dump.
Browse files Browse the repository at this point in the history
  • Loading branch information
Meinersbur committed Aug 28, 2021
1 parent b35e636 commit e4f3f2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions polly/lib/Support/DumpFunctionPass.cpp
Expand Up @@ -43,9 +43,15 @@ static void runDumpFunction(llvm::Function &F, StringRef Suffix) {
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;
Expand All @@ -58,6 +64,9 @@ static void runDumpFunction(llvm::Function &F, StringRef Suffix) {
MPM.run(*CM, MAM);
}

// Restore old linkage
NewF->setLinkage(OrigLinkage);

LLVM_DEBUG(dbgs() << "Write to file '" << Dumpfile << "'...\n");

std::unique_ptr<ToolOutputFile> Out;
Expand Down
4 changes: 2 additions & 2 deletions polly/test/Support/dumpfunction.ll
Expand Up @@ -22,7 +22,7 @@

@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

Expand All @@ -49,7 +49,7 @@ return:
}


define void @caller(i32 %n, double* noalias nonnull %A) {
define internal void @caller(i32 %n, double* noalias nonnull %A) {
entry:
br label %for

Expand Down

0 comments on commit e4f3f2c

Please sign in to comment.