-
Notifications
You must be signed in to change notification settings - Fork 13
Merge Vector instruction COT project #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8d13f7c
0f7c021
6755515
1d7ce93
3f93097
f27f9c4
10d7b20
cf0de32
66995b8
c2e024c
17f647d
b58628e
2163921
7bd6485
4ec6e95
ae600be
9883f04
169eb45
a6412bb
76b28e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,9 +124,48 @@ class AddWindowsDLLExportPass: public PassInfoMixin<AddWindowsDLLExportPass> | |
| }; | ||
| }; | ||
|
|
||
| struct mlir::rlc::TargetInfoImpl | ||
| { | ||
| public: | ||
| TargetInfoImpl(std::string triple, bool shared, bool optimize) | ||
| : triple(triple), | ||
| optimize( | ||
| optimize ? CodeGenOptLevel::Aggressive : CodeGenOptLevel::Default), | ||
| reloc(shared ? llvm::Reloc::PIC_ : llvm::Reloc::Static) | ||
| { | ||
| std::string Error; | ||
| target = llvm::TargetRegistry::lookupTarget("", this->triple, Error); | ||
| assert(target); | ||
| options = llvm::codegen::InitTargetOptionsFromCodeGenFlags(this->triple); | ||
|
|
||
| auto *Ptr = target->createTargetMachine( | ||
| this->triple.getTriple(), | ||
| "", | ||
| "", | ||
| options, | ||
| reloc, | ||
| llvm::CodeModel::Large, | ||
| this->optimize); | ||
| targetMachine = unique_ptr<TargetMachine>(Ptr); | ||
|
|
||
| datalayout = | ||
| std::make_unique<llvm::DataLayout>(targetMachine->createDataLayout()); | ||
| } | ||
|
|
||
| llvm::Triple triple; | ||
| llvm::CodeModel::Model model; | ||
| llvm::CodeGenOptLevel optimize; | ||
| llvm::Reloc::Model reloc; | ||
| const llvm::Target *target; | ||
| llvm::TargetOptions options; | ||
| std::unique_ptr<llvm::TargetMachine> targetMachine; | ||
| std::unique_ptr<llvm::DataLayout> datalayout; | ||
| }; | ||
|
|
||
| static const bool printTimings = false; | ||
|
|
||
| static void runOptimizer( | ||
| const mlir::rlc::TargetInfoImpl &pimpl, | ||
| llvm::Module &M, | ||
| bool optimize, | ||
| bool emitSanitizerInstrumentation, | ||
|
|
@@ -144,17 +183,22 @@ static void runOptimizer( | |
| if (printTimings) | ||
| TimePasses->registerCallbacks(PIC); | ||
|
|
||
|
|
||
| // Create the analysis managers. | ||
| LoopAnalysisManager LAM; | ||
| FunctionAnalysisManager FAM; | ||
| CGSCCAnalysisManager CGAM; | ||
| ModuleAnalysisManager MAM; | ||
|
|
||
| PipelineTuningOptions PTO; | ||
| // If !optimize this will be discarded | ||
| PTO.SLPVectorization = true; | ||
|
|
||
| // Create the new pass manager builder. | ||
| // Take a look at the PassBuilder constructor parameters for more | ||
| // customization, e.g. specifying a TargetMachine or various debugging | ||
| // options. | ||
| PassBuilder PB(nullptr, llvm::PipelineTuningOptions(), std::nullopt, &PIC); | ||
| PassBuilder PB(pimpl.targetMachine.get(), PTO, std::nullopt, &PIC); | ||
|
|
||
| // Register all the basic analyses with the managers. | ||
| PB.registerModuleAnalyses(MAM); | ||
|
|
@@ -165,73 +209,35 @@ static void runOptimizer( | |
|
|
||
| // Create the pass manager. | ||
| // This one corresponds to a typical -O2 optimization pipeline. | ||
| ModulePassManager MPM; | ||
|
|
||
| if (optimize) | ||
| { | ||
| ModulePassManager passManager; | ||
| FunctionPassManager functionPassManager; | ||
| MPM = PB.buildPerModuleDefaultPipeline(OptimizationLevel::O2); | ||
| if (targetIsWindows) | ||
| functionPassManager.addPass(AddWindowsDLLExportPass()); | ||
| functionPassManager.addPass(llvm::PromotePass()); | ||
| passManager.addPass( | ||
| MPM.addPass( | ||
| createModuleToFunctionPassAdaptor(std::move(functionPassManager))); | ||
| if (emitSanitizerInstrumentation and not targetIsWindows) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is something going on here that happen probably due to the rebasing. it seem that ode that was there before has been accidentally removed.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These instructions were repeated in both branches' end, I just moved them down |
||
| addFuzzerInstrumentationPass(passManager); | ||
| passManager.run(M, MAM); | ||
|
|
||
| PB.buildPerModuleDefaultPipeline(OptimizationLevel::O2).run(M, MAM); | ||
| } | ||
| else | ||
| { | ||
| ModulePassManager MPM = PB.buildO0DefaultPipeline( | ||
| MPM = PB.buildO0DefaultPipeline( | ||
| OptimizationLevel::O0, ThinOrFullLTOPhase::None); | ||
| if (targetIsWindows) | ||
| MPM.addPass(createModuleToFunctionPassAdaptor(AddWindowsDLLExportPass())); | ||
| if (emitSanitizerInstrumentation and not targetIsWindows) | ||
| addFuzzerInstrumentationPass(MPM); | ||
| MPM.run(M, MAM); | ||
| } | ||
|
|
||
| if (emitSanitizerInstrumentation and not targetIsWindows) | ||
| addFuzzerInstrumentationPass(MPM); | ||
|
|
||
| MPM.run(M, MAM); | ||
|
|
||
| if (printTimings) | ||
| TimePasses->print(); | ||
| } | ||
|
|
||
| struct mlir::rlc::TargetInfoImpl | ||
| { | ||
| public: | ||
| TargetInfoImpl(std::string triple, bool shared, bool optimize) | ||
| : triple(triple), | ||
| optimize( | ||
| optimize ? CodeGenOptLevel::Aggressive : CodeGenOptLevel::Default), | ||
| reloc(shared ? llvm::Reloc::PIC_ : llvm::Reloc::Static) | ||
| { | ||
| std::string Error; | ||
| target = llvm::TargetRegistry::lookupTarget("", this->triple, Error); | ||
| assert(target); | ||
| options = llvm::codegen::InitTargetOptionsFromCodeGenFlags(this->triple); | ||
|
|
||
| auto *Ptr = target->createTargetMachine( | ||
| this->triple.getTriple(), | ||
| "", | ||
| "", | ||
| options, | ||
| reloc, | ||
| llvm::CodeModel::Large, | ||
| this->optimize); | ||
| targetMachine = unique_ptr<TargetMachine>(Ptr); | ||
|
|
||
| datalayout = | ||
| std::make_unique<llvm::DataLayout>(targetMachine->createDataLayout()); | ||
| } | ||
|
|
||
| llvm::Triple triple; | ||
| llvm::CodeModel::Model model; | ||
| llvm::CodeGenOptLevel optimize; | ||
| llvm::Reloc::Model reloc; | ||
| const llvm::Target *target; | ||
| llvm::TargetOptions options; | ||
| std::unique_ptr<llvm::TargetMachine> targetMachine; | ||
| std::unique_ptr<llvm::DataLayout> datalayout; | ||
| }; | ||
|
|
||
| mlir::rlc::TargetInfo::TargetInfo( | ||
| std::string triple, bool shared, bool optimize) | ||
|
|
@@ -556,7 +562,7 @@ namespace mlir::rlc | |
| assert(Module); | ||
| Module->setTargetTriple(targetInfo->triple()); | ||
|
|
||
| runOptimizer( | ||
| runOptimizer(*targetInfo->pimpl, | ||
| *Module, | ||
| targetInfo->optimize(), | ||
| emitSanitizer, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know that this is probably due to the rebase, but does this piece of code really need to be moved away from its original location?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need it to be before runOptimizer() because one of its arguments has this structure type