[llvm] r278509 - [PM] Port NameAnonFunction pass to new pass manager
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 12 07:03:36 PDT 2016
Author: tejohnson
Date: Fri Aug 12 09:03:36 2016
New Revision: 278509
URL: http://llvm.org/viewvc/llvm-project?rev=278509&view=rev
Log:
[PM] Port NameAnonFunction pass to new pass manager
Summary:
Port the NameAnonFunction pass and add a test.
Depends on D23439.
Reviewers: mehdi_amini
Subscribers: llvm-commits, mehdi_amini
Differential Revision: https://reviews.llvm.org/D23440
Added:
llvm/trunk/include/llvm/Transforms/Utils/NameAnonFunctions.h
Modified:
llvm/trunk/include/llvm/InitializePasses.h
llvm/trunk/lib/Passes/PassBuilder.cpp
llvm/trunk/lib/Passes/PassRegistry.def
llvm/trunk/lib/Transforms/Utils/NameAnonFunctions.cpp
llvm/trunk/lib/Transforms/Utils/Utils.cpp
llvm/trunk/test/Bitcode/thinlto-function-summary.ll
Modified: llvm/trunk/include/llvm/InitializePasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=278509&r1=278508&r2=278509&view=diff
==============================================================================
--- llvm/trunk/include/llvm/InitializePasses.h (original)
+++ llvm/trunk/include/llvm/InitializePasses.h Fri Aug 12 09:03:36 2016
@@ -242,7 +242,7 @@ void initializeMergedLoadStoreMotionLega
void initializeMetaRenamerPass(PassRegistry&);
void initializeModuleDebugInfoPrinterPass(PassRegistry&);
void initializeModuleSummaryIndexWrapperPassPass(PassRegistry &);
-void initializeNameAnonFunctionPass(PassRegistry &);
+void initializeNameAnonFunctionLegacyPassPass(PassRegistry &);
void initializeNaryReassociateLegacyPassPass(PassRegistry &);
void initializeNoAAPass(PassRegistry&);
void initializeObjCARCAAWrapperPassPass(PassRegistry&);
Added: llvm/trunk/include/llvm/Transforms/Utils/NameAnonFunctions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/NameAnonFunctions.h?rev=278509&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/NameAnonFunctions.h (added)
+++ llvm/trunk/include/llvm/Transforms/Utils/NameAnonFunctions.h Fri Aug 12 09:03:36 2016
@@ -0,0 +1,31 @@
+//===-- NameAnonFunctions.h - Anonymous Function Naming Pass ----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements naming anonymous function to make sure they can be
+// referred to by ThinLTO.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_UTILS_NAMEANONFUNCTIONS_H
+#define LLVM_TRANSFORMS_UTILS_NAMEANONFUNCTIONS_H
+
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+/// Simple pass that provides a name to every anonymous function.
+class NameAnonFunctionPass : public PassInfoMixin<NameAnonFunctionPass> {
+public:
+ NameAnonFunctionPass() {}
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+}
+
+#endif // LLVM_TRANSFORMS_UTILS_NAMEANONFUNCTIONS_H
Modified: llvm/trunk/lib/Passes/PassBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Passes/PassBuilder.cpp?rev=278509&r1=278508&r2=278509&view=diff
==============================================================================
--- llvm/trunk/lib/Passes/PassBuilder.cpp (original)
+++ llvm/trunk/lib/Passes/PassBuilder.cpp Fri Aug 12 09:03:36 2016
@@ -121,6 +121,7 @@
#include "llvm/Transforms/Utils/LoopSimplify.h"
#include "llvm/Transforms/Utils/Mem2Reg.h"
#include "llvm/Transforms/Utils/MemorySSA.h"
+#include "llvm/Transforms/Utils/NameAnonFunctions.h"
#include "llvm/Transforms/Utils/SimplifyInstructions.h"
#include "llvm/Transforms/Utils/SymbolRewriter.h"
#include "llvm/Transforms/Vectorize/LoopVectorize.h"
Modified: llvm/trunk/lib/Passes/PassRegistry.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Passes/PassRegistry.def?rev=278509&r1=278508&r2=278509&view=diff
==============================================================================
--- llvm/trunk/lib/Passes/PassRegistry.def (original)
+++ llvm/trunk/lib/Passes/PassRegistry.def Fri Aug 12 09:03:36 2016
@@ -53,6 +53,7 @@ MODULE_PASS("internalize", InternalizePa
MODULE_PASS("invalidate<all>", InvalidateAllAnalysesPass())
MODULE_PASS("ipsccp", IPSCCPPass())
MODULE_PASS("lowertypetests", LowerTypeTestsPass())
+MODULE_PASS("name-anon-functions", NameAnonFunctionPass())
MODULE_PASS("no-op-module", NoOpModulePass())
MODULE_PASS("partial-inliner", PartialInlinerPass())
MODULE_PASS("pgo-icall-prom", PGOIndirectCallPromotion())
Modified: llvm/trunk/lib/Transforms/Utils/NameAnonFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/NameAnonFunctions.cpp?rev=278509&r1=278508&r2=278509&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/NameAnonFunctions.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/NameAnonFunctions.cpp Fri Aug 12 09:03:36 2016
@@ -12,6 +12,8 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Transforms/Utils/NameAnonFunctions.h"
+
#include "llvm/ADT/SmallString.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/MD5.h"
@@ -76,8 +78,8 @@ bool llvm::nameUnamedFunctions(Module &M
namespace {
-// Simple pass that provides a name to every anon function.
-class NameAnonFunction : public ModulePass {
+// Legacy pass that provides a name to every anon function.
+class NameAnonFunctionLegacyPass : public ModulePass {
public:
/// Pass identification, replacement for typeid
@@ -86,19 +88,29 @@ public:
/// Specify pass name for debug output
const char *getPassName() const override { return "Name Anon Functions"; }
- explicit NameAnonFunction() : ModulePass(ID) {}
+ explicit NameAnonFunctionLegacyPass() : ModulePass(ID) {}
bool runOnModule(Module &M) override { return nameUnamedFunctions(M); }
};
-char NameAnonFunction::ID = 0;
+char NameAnonFunctionLegacyPass::ID = 0;
} // anonymous namespace
-INITIALIZE_PASS_BEGIN(NameAnonFunction, "name-anon-functions",
+PreservedAnalyses NameAnonFunctionPass::run(Module &M,
+ ModuleAnalysisManager &AM) {
+ if (!nameUnamedFunctions(M))
+ return PreservedAnalyses::all();
+
+ return PreservedAnalyses::none();
+}
+
+INITIALIZE_PASS_BEGIN(NameAnonFunctionLegacyPass, "name-anon-functions",
"Provide a name to nameless functions", false, false)
-INITIALIZE_PASS_END(NameAnonFunction, "name-anon-functions",
+INITIALIZE_PASS_END(NameAnonFunctionLegacyPass, "name-anon-functions",
"Provide a name to nameless functions", false, false)
namespace llvm {
-ModulePass *createNameAnonFunctionPass() { return new NameAnonFunction(); }
+ModulePass *createNameAnonFunctionPass() {
+ return new NameAnonFunctionLegacyPass();
+}
}
Modified: llvm/trunk/lib/Transforms/Utils/Utils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Utils.cpp?rev=278509&r1=278508&r2=278509&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Utils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Utils.cpp Fri Aug 12 09:03:36 2016
@@ -28,7 +28,7 @@ void llvm::initializeTransformUtils(Pass
initializeLoopSimplifyPass(Registry);
initializeLowerInvokePass(Registry);
initializeLowerSwitchPass(Registry);
- initializeNameAnonFunctionPass(Registry);
+ initializeNameAnonFunctionLegacyPassPass(Registry);
initializePromoteLegacyPassPass(Registry);
initializeUnifyFunctionExitNodesPass(Registry);
initializeInstSimplifierPass(Registry);
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary.ll?rev=278509&r1=278508&r2=278509&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary.ll Fri Aug 12 09:03:36 2016
@@ -1,4 +1,5 @@
; RUN: opt -name-anon-functions -module-summary < %s | llvm-bcanalyzer -dump | FileCheck %s -check-prefix=BC
+; RUN: opt -passes=name-anon-functions -module-summary < %s | llvm-bcanalyzer -dump | FileCheck %s -check-prefix=BC
; Check for summary block/records.
; Check the value ids in the summary entries against the
More information about the llvm-commits
mailing list