[polly] e4f3f2c - [Polly] Don't prune non-external function itself from dump.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 28 15:07:44 PDT 2021
Author: Michael Kruse
Date: 2021-08-28T17:06:53-05:00
New Revision: e4f3f2c0c5f22ddfe86d16ba09fd0171bed0f2b3
URL: https://github.com/llvm/llvm-project/commit/e4f3f2c0c5f22ddfe86d16ba09fd0171bed0f2b3
DIFF: https://github.com/llvm/llvm-project/commit/e4f3f2c0c5f22ddfe86d16ba09fd0171bed0f2b3.diff
LOG: [Polly] Don't prune non-external function itself from dump.
Added:
Modified:
polly/lib/Support/DumpFunctionPass.cpp
polly/test/Support/dumpfunction.ll
Removed:
################################################################################
diff --git a/polly/lib/Support/DumpFunctionPass.cpp b/polly/lib/Support/DumpFunctionPass.cpp
index 313fc71159348..a14e0efb82caf 100644
--- a/polly/lib/Support/DumpFunctionPass.cpp
+++ b/polly/lib/Support/DumpFunctionPass.cpp
@@ -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;
@@ -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;
diff --git a/polly/test/Support/dumpfunction.ll b/polly/test/Support/dumpfunction.ll
index 70b586bd244b1..243322f99ecaa 100644
--- a/polly/test/Support/dumpfunction.ll
+++ b/polly/test/Support/dumpfunction.ll
@@ -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
@@ -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
More information about the llvm-commits
mailing list