Skip to content

Commit a782dae

Browse files
committed
start
1 parent e7748e9 commit a782dae

File tree

11 files changed

+4334
-34
lines changed

11 files changed

+4334
-34
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===- MSSAArgPromotionPass.cpp - Promote by-reference arguments -----===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
//
10+
//===----------------------------------------------------------------------===//
11+
12+
#include "llvm/Analysis/CGSCCPassManager.h"
13+
#include "llvm/Analysis/LazyCallGraph.h"
14+
#include "llvm/IR/PassManager.h"
15+
16+
namespace llvm {
17+
18+
class MSSAArgPromotionPass : public PassInfoMixin<MSSAArgPromotionPass> {
19+
public:
20+
MSSAArgPromotionPass() {}
21+
22+
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
23+
LazyCallGraph &CG, CGSCCUpdateResult &UR);
24+
};
25+
26+
} // end namespace llvm

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
#include "llvm/Transforms/IPO/LoopExtractor.h"
230230
#include "llvm/Transforms/IPO/LowerTypeTests.h"
231231
#include "llvm/Transforms/IPO/MemProfContextDisambiguation.h"
232+
#include "llvm/Transforms/IPO/MSSAArgPromotion.h"
232233
#include "llvm/Transforms/IPO/MergeFunctions.h"
233234
#include "llvm/Transforms/IPO/OpenMPOpt.h"
234235
#include "llvm/Transforms/IPO/PartialInlining.h"

llvm/lib/Passes/PassRegistry.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ CGSCC_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
314314
CGSCC_PASS("argpromotion", ArgumentPromotionPass())
315315
CGSCC_PASS("attributor-cgscc", AttributorCGSCCPass())
316316
CGSCC_PASS("attributor-light-cgscc", AttributorLightCGSCCPass())
317+
CGSCC_PASS("mssaargpromotion", MSSAArgPromotionPass())
317318
CGSCC_PASS("invalidate<all>", InvalidateAllAnalysesPass())
318319
CGSCC_PASS("no-op-cgscc", NoOpCGSCCPass())
319320
CGSCC_PASS("openmp-opt-cgscc", OpenMPOptCGSCCPass())

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
#include "llvm/Transforms/IPO/ExpandVariadics.h"
103103
#include "llvm/Transforms/IPO/GlobalDCE.h"
104104
#include "llvm/Transforms/IPO/Internalize.h"
105+
#include "llvm/Transforms/IPO/MSSAArgPromotion.h"
105106
#include "llvm/Transforms/Scalar.h"
106107
#include "llvm/Transforms/Scalar/EarlyCSE.h"
107108
#include "llvm/Transforms/Scalar/FlattenCFG.h"
@@ -938,6 +939,10 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
938939
FPM.addPass(AMDGPUPromoteAllocaToVectorPass(*this));
939940
}
940941

942+
// Add pass to promote arguments passed by reference
943+
if (Level.getSpeedupLevel() >= OptimizationLevel::O3.getSpeedupLevel())
944+
PM.addPass(MSSAArgPromotionPass());
945+
941946
PM.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM)));
942947
});
943948

llvm/lib/Transforms/IPO/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ add_llvm_component_library(LLVMipo
3333
MemProfContextDisambiguation.cpp
3434
MergeFunctions.cpp
3535
ModuleInliner.cpp
36+
MSSAArgPromotion.cpp
3637
OpenMPOpt.cpp
3738
PartialInlining.cpp
3839
SampleContextTracker.cpp

0 commit comments

Comments
 (0)