forked from OSchip/llvm-project
[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 llvm-svn: 278509
This commit is contained in:
parent
f93b246f8b
commit
4223dd8559
|
@ -242,7 +242,7 @@ void initializeMergedLoadStoreMotionLegacyPassPass(PassRegistry &);
|
|||
void initializeMetaRenamerPass(PassRegistry&);
|
||||
void initializeModuleDebugInfoPrinterPass(PassRegistry&);
|
||||
void initializeModuleSummaryIndexWrapperPassPass(PassRegistry &);
|
||||
void initializeNameAnonFunctionPass(PassRegistry &);
|
||||
void initializeNameAnonFunctionLegacyPassPass(PassRegistry &);
|
||||
void initializeNaryReassociateLegacyPassPass(PassRegistry &);
|
||||
void initializeNoAAPass(PassRegistry&);
|
||||
void initializeObjCARCAAWrapperPassPass(PassRegistry&);
|
||||
|
|
|
@ -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
|
|
@ -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"
|
||||
|
|
|
@ -53,6 +53,7 @@ MODULE_PASS("internalize", InternalizePass())
|
|||
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())
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ void llvm::initializeTransformUtils(PassRegistry &Registry) {
|
|||
initializeLoopSimplifyPass(Registry);
|
||||
initializeLowerInvokePass(Registry);
|
||||
initializeLowerSwitchPass(Registry);
|
||||
initializeNameAnonFunctionPass(Registry);
|
||||
initializeNameAnonFunctionLegacyPassPass(Registry);
|
||||
initializePromoteLegacyPassPass(Registry);
|
||||
initializeUnifyFunctionExitNodesPass(Registry);
|
||||
initializeInstSimplifierPass(Registry);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue