[PM] Port PreISelIntrinsicLowering to the new PM

llvm-svn: 273713
This commit is contained in:
Michael Kuperstein 2016-06-24 20:13:42 +00:00
parent 3b3e954ea2
commit 82d5da5aac
8 changed files with 52 additions and 14 deletions

View File

@ -0,0 +1,26 @@
//===--- PreISelIntrinsicLowering.h - Pre-ISel intrinsic lowering pass ----===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This pass implements IR lowering for the llvm.load.relative intrinsic.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_PREISELINTRINSICLOWERING_H
#define LLVM_CODEGEN_PREISELINTRINSICLOWERING_H
#include "llvm/IR/PassManager.h"
namespace llvm {
struct PreISelIntrinsicLoweringPass
: PassInfoMixin<PreISelIntrinsicLoweringPass> {
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
};
}
#endif // LLVM_CODEGEN_PREISELINTRINSICLOWERING_H

View File

@ -261,7 +261,7 @@ void initializePostMachineSchedulerPass(PassRegistry&);
void initializePostOrderFunctionAttrsLegacyPassPass(PassRegistry&); void initializePostOrderFunctionAttrsLegacyPassPass(PassRegistry&);
void initializePostRAHazardRecognizerPass(PassRegistry&); void initializePostRAHazardRecognizerPass(PassRegistry&);
void initializePostRASchedulerPass(PassRegistry&); void initializePostRASchedulerPass(PassRegistry&);
void initializePreISelIntrinsicLoweringPass(PassRegistry&); void initializePreISelIntrinsicLoweringLegacyPassPass(PassRegistry&);
void initializePrintBasicBlockPassPass(PassRegistry&); void initializePrintBasicBlockPassPass(PassRegistry&);
void initializePrintFunctionPassWrapperPass(PassRegistry&); void initializePrintFunctionPassWrapperPass(PassRegistry&);
void initializePrintModulePassWrapperPass(PassRegistry&); void initializePrintModulePassWrapperPass(PassRegistry&);

View File

@ -65,7 +65,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
initializePostMachineSchedulerPass(Registry); initializePostMachineSchedulerPass(Registry);
initializePostRAHazardRecognizerPass(Registry); initializePostRAHazardRecognizerPass(Registry);
initializePostRASchedulerPass(Registry); initializePostRASchedulerPass(Registry);
initializePreISelIntrinsicLoweringPass(Registry); initializePreISelIntrinsicLoweringLegacyPassPass(Registry);
initializeProcessImplicitDefsPass(Registry); initializeProcessImplicitDefsPass(Registry);
initializeRegisterCoalescerPass(Registry); initializeRegisterCoalescerPass(Registry);
initializeRenameIndependentSubregsPass(Registry); initializeRenameIndependentSubregsPass(Registry);

View File

@ -11,6 +11,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/CodeGen/PreISelIntrinsicLowering.h"
#include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/Passes.h"
#include "llvm/IR/Function.h" #include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h" #include "llvm/IR/IRBuilder.h"
@ -63,23 +64,31 @@ bool lowerIntrinsics(Module &M) {
return Changed; return Changed;
} }
class PreISelIntrinsicLowering : public ModulePass { class PreISelIntrinsicLoweringLegacyPass : public ModulePass {
public: public:
static char ID; static char ID;
PreISelIntrinsicLowering() : ModulePass(ID) {} PreISelIntrinsicLoweringLegacyPass() : ModulePass(ID) {}
bool runOnModule(Module &M) { bool runOnModule(Module &M) { return lowerIntrinsics(M); }
return lowerIntrinsics(M);
}
}; };
char PreISelIntrinsicLowering::ID; char PreISelIntrinsicLoweringLegacyPass::ID;
} }
INITIALIZE_PASS(PreISelIntrinsicLowering, "pre-isel-intrinsic-lowering", INITIALIZE_PASS(PreISelIntrinsicLoweringLegacyPass,
"Pre-ISel Intrinsic Lowering", false, false) "pre-isel-intrinsic-lowering", "Pre-ISel Intrinsic Lowering",
false, false)
ModulePass *llvm::createPreISelIntrinsicLoweringPass() { namespace llvm {
return new PreISelIntrinsicLowering; ModulePass *createPreISelIntrinsicLoweringPass() {
return new PreISelIntrinsicLoweringLegacyPass;
} }
PreservedAnalyses PreISelIntrinsicLoweringPass::run(Module &M,
ModuleAnalysisManager &AM) {
if (!lowerIntrinsics(M))
return PreservedAnalyses::all();
else
return PreservedAnalyses::none();
}
} // End llvm namespace

View File

@ -44,6 +44,7 @@
#include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/TypeBasedAliasAnalysis.h" #include "llvm/Analysis/TypeBasedAliasAnalysis.h"
#include "llvm/CodeGen/PreISelIntrinsicLowering.h"
#include "llvm/IR/Dominators.h" #include "llvm/IR/Dominators.h"
#include "llvm/IR/IRPrintingPasses.h" #include "llvm/IR/IRPrintingPasses.h"
#include "llvm/IR/PassManager.h" #include "llvm/IR/PassManager.h"

View File

@ -53,6 +53,7 @@ MODULE_PASS("no-op-module", NoOpModulePass())
MODULE_PASS("pgo-icall-prom", PGOIndirectCallPromotion()) MODULE_PASS("pgo-icall-prom", PGOIndirectCallPromotion())
MODULE_PASS("pgo-instr-gen", PGOInstrumentationGen()) MODULE_PASS("pgo-instr-gen", PGOInstrumentationGen())
MODULE_PASS("pgo-instr-use", PGOInstrumentationUse()) MODULE_PASS("pgo-instr-use", PGOInstrumentationUse())
MODULE_PASS("pre-isel-intrinsic-lowering", PreISelIntrinsicLoweringPass())
MODULE_PASS("print-profile-summary", ProfileSummaryPrinterPass(dbgs())) MODULE_PASS("print-profile-summary", ProfileSummaryPrinterPass(dbgs()))
MODULE_PASS("print-callgraph", CallGraphPrinterPass(dbgs())) MODULE_PASS("print-callgraph", CallGraphPrinterPass(dbgs()))
MODULE_PASS("print", PrintModulePass(dbgs())) MODULE_PASS("print", PrintModulePass(dbgs()))

View File

@ -1,4 +1,5 @@
; RUN: opt -pre-isel-intrinsic-lowering -S -o - %s | FileCheck %s ; RUN: opt -pre-isel-intrinsic-lowering -S -o - %s | FileCheck %s
; RUN: opt -passes='pre-isel-intrinsic-lowering' -S -o - %s | FileCheck %s
; CHECK: define i8* @foo32(i8* [[P:%.*]], i32 [[O:%.*]]) ; CHECK: define i8* @foo32(i8* [[P:%.*]], i32 [[O:%.*]])
define i8* @foo32(i8* %p, i32 %o) { define i8* @foo32(i8* %p, i32 %o) {

View File

@ -361,7 +361,7 @@ int main(int argc, char **argv) {
initializeDwarfEHPreparePass(Registry); initializeDwarfEHPreparePass(Registry);
initializeSafeStackPass(Registry); initializeSafeStackPass(Registry);
initializeSjLjEHPreparePass(Registry); initializeSjLjEHPreparePass(Registry);
initializePreISelIntrinsicLoweringPass(Registry); initializePreISelIntrinsicLoweringLegacyPassPass(Registry);
initializeGlobalMergePass(Registry); initializeGlobalMergePass(Registry);
initializeInterleavedAccessPass(Registry); initializeInterleavedAccessPass(Registry);