Skip to content

Commit

Permalink
Remove the ScalarReplAggregates pass
Browse files Browse the repository at this point in the history
Nearly all the changes to this pass have been done while maintaining and
updating other parts of LLVM.  LLVM has had another pass, SROA, which
has superseded ScalarReplAggregates for quite some time.

Differential Revision: http://reviews.llvm.org/D21316

llvm-svn: 272737
  • Loading branch information
majnemer committed Jun 15, 2016
1 parent f42c692 commit cbf614a
Show file tree
Hide file tree
Showing 83 changed files with 30 additions and 5,114 deletions.
Expand Up @@ -127,17 +127,17 @@ external add_sccp
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
= "llvm_add_sccp"

(** See the [llvm::createScalarReplAggregatesPass] function. *)
(** See the [llvm::createSROAPass] function. *)
external add_scalar_repl_aggregation
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
= "llvm_add_scalar_repl_aggregates"

(** See the [llvm::createScalarReplAggregatesPassSSA] function. *)
(** See the [llvm::createSROAPass] function. *)
external add_scalar_repl_aggregation_ssa
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
= "llvm_add_scalar_repl_aggregates_ssa"

(** See the [llvm::createScalarReplAggregatesWithThreshold] function. *)
(** See the [llvm::createSROAPass] function. *)
external add_scalar_repl_aggregation_with_threshold
: int -> [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
= "llvm_add_scalar_repl_aggregates_with_threshold"
Expand Down
2 changes: 1 addition & 1 deletion llvm/docs/Atomics.rst
Expand Up @@ -398,7 +398,7 @@ operations:
MemoryDependencyAnalysis (which is also used by other passes like GVN).

* Folding a load: Any atomic load from a constant global can be constant-folded,
because it cannot be observed. Similar reasoning allows scalarrepl with
because it cannot be observed. Similar reasoning allows sroa with
atomic loads and stores.

Atomics and Codegen
Expand Down
8 changes: 1 addition & 7 deletions llvm/docs/Passes.rst
Expand Up @@ -947,7 +947,7 @@ that this should make CFG hacking much easier. To make later hacking easier,
the entry block is split into two, such that all introduced ``alloca``
instructions (and nothing else) are in the entry block.

``-scalarrepl``: Scalar Replacement of Aggregates (DT)
``-sroa``: Scalar Replacement of Aggregates
------------------------------------------------------

The well-known scalar replacement of aggregates transformation. This transform
Expand All @@ -956,12 +956,6 @@ individual ``alloca`` instructions for each member if possible. Then, if
possible, it transforms the individual ``alloca`` instructions into nice clean
scalar SSA form.

This combines a simple scalar replacement of aggregates algorithm with the
:ref:`mem2reg <passes-mem2reg>` algorithm because they often interact,
especially for C++ programs. As such, iterating between ``scalarrepl``, then
:ref:`mem2reg <passes-mem2reg>` until we run out of things to promote works
well.

.. _passes-sccp:

``-sccp``: Sparse Conditional Constant Propagation
Expand Down
2 changes: 1 addition & 1 deletion llvm/docs/tutorial/LangImpl7.rst
Expand Up @@ -224,7 +224,7 @@ variables in certain circumstances:
class <../LangRef.html#first-class-types>`_ values (such as pointers,
scalars and vectors), and only if the array size of the allocation is
1 (or missing in the .ll file). mem2reg is not capable of promoting
structs or arrays to registers. Note that the "scalarrepl" pass is
structs or arrays to registers. Note that the "sroa" pass is
more powerful and can promote structs, "unions", and arrays in many
cases.

Expand Down
2 changes: 1 addition & 1 deletion llvm/docs/tutorial/OCamlLangImpl7.rst
Expand Up @@ -224,7 +224,7 @@ variables in certain circumstances:
class <../LangRef.html#first-class-types>`_ values (such as pointers,
scalars and vectors), and only if the array size of the allocation is
1 (or missing in the .ll file). mem2reg is not capable of promoting
structs or arrays to registers. Note that the "scalarrepl" pass is
structs or arrays to registers. Note that the "sroa" pass is
more powerful and can promote structs, "unions", and arrays in many
cases.

Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm-c/Transforms/Scalar.h
Expand Up @@ -104,13 +104,13 @@ void LLVMAddReassociatePass(LLVMPassManagerRef PM);
/** See llvm::createSCCPPass function. */
void LLVMAddSCCPPass(LLVMPassManagerRef PM);

/** See llvm::createScalarReplAggregatesPass function. */
/** See llvm::createSROAPass function. */
void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM);

/** See llvm::createScalarReplAggregatesPass function. */
/** See llvm::createSROAPass function. */
void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM);

/** See llvm::createScalarReplAggregatesPass function. */
/** See llvm::createSROAPass function. */
void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM,
int Threshold);

Expand Down
2 changes: 0 additions & 2 deletions llvm/include/llvm/InitializePasses.h
Expand Up @@ -286,8 +286,6 @@ void initializeSCCPLegacyPassPass(PassRegistry &);
void initializeSCEVAAWrapperPassPass(PassRegistry&);
void initializeSLPVectorizerPass(PassRegistry&);
void initializeSROALegacyPassPass(PassRegistry&);
void initializeSROA_DTPass(PassRegistry&);
void initializeSROA_SSAUpPass(PassRegistry&);
void initializeSafeStackPass(PassRegistry&);
void initializeSampleProfileLoaderLegacyPassPass(PassRegistry&);
void initializeSanitizerCoverageModulePass(PassRegistry&);
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/LinkAllPasses.h
Expand Up @@ -145,7 +145,7 @@ namespace {
(void) llvm::createRegionViewerPass();
(void) llvm::createSCCPPass();
(void) llvm::createSafeStackPass();
(void) llvm::createScalarReplAggregatesPass();
(void) llvm::createSROAPass();
(void) llvm::createSingleLoopExtractorPass();
(void) llvm::createStripSymbolsPass();
(void) llvm::createStripNonDebugSymbolsPass();
Expand Down
11 changes: 0 additions & 11 deletions llvm/include/llvm/Transforms/Scalar.h
Expand Up @@ -104,17 +104,6 @@ FunctionPass *createBitTrackingDCEPass();
//
FunctionPass *createSROAPass();

//===----------------------------------------------------------------------===//
//
// ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
// if possible.
//
FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1,
bool UseDomTree = true,
signed StructMemberThreshold = -1,
signed ArrayElementThreshold = -1,
signed ScalarLoadThreshold = -1);

//===----------------------------------------------------------------------===//
//
// InductiveRangeCheckElimination - Transform loops to elide range checks on
Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/LTO/LTOCodeGenerator.cpp
Expand Up @@ -119,8 +119,6 @@ void LTOCodeGenerator::initializeLTOPasses() {
initializeArgPromotionPass(R);
initializeJumpThreadingPass(R);
initializeSROALegacyPassPass(R);
initializeSROA_DTPass(R);
initializeSROA_SSAUpPass(R);
initializePostOrderFunctionAttrsLegacyPassPass(R);
initializeReversePostOrderFunctionAttrsLegacyPassPass(R);
initializeGlobalsAAWrapperPassPass(R);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/README.txt
Expand Up @@ -2081,7 +2081,7 @@ struct x testfunc() {
}

We currently compile this to:
$ clang t.c -S -o - -O0 -emit-llvm | opt -scalarrepl -S
$ clang t.c -S -o - -O0 -emit-llvm | opt -sroa -S


%struct.x = type { i8, [4 x i32] }
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/X86/README-X86-64.txt
Expand Up @@ -170,7 +170,7 @@ generated for it. The primary issue with the result is that it doesn't do any
of the optimizations which are possible if we know the address of a va_list
in the current function is never taken:
1. We shouldn't spill the XMM registers because we only call va_arg with "int".
2. It would be nice if we could scalarrepl the va_list.
2. It would be nice if we could sroa the va_list.
3. Probably overkill, but it'd be cool if we could peel off the first five
iterations of the loop.

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
Expand Up @@ -307,7 +307,7 @@ CallGraphNode *ArgPromotion::PromoteArguments(CallGraphNode *CGN) {
}

// Safe to transform, don't even bother trying to "promote" it.
// Passing the elements as a scalar will allow scalarrepl to hack on
// Passing the elements as a scalar will allow sroa to hack on
// the new alloca we introduce.
if (AllSimple) {
ByValArgsToTransform.insert(PtrArg);
Expand Down
19 changes: 3 additions & 16 deletions llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
Expand Up @@ -61,10 +61,6 @@ static cl::opt<bool> ExtraVectorizerPasses(
"extra-vectorizer-passes", cl::init(false), cl::Hidden,
cl::desc("Run cleanup optimization passes after vectorization."));

static cl::opt<bool> UseNewSROA("use-new-sroa",
cl::init(true), cl::Hidden,
cl::desc("Enable the new, experimental SROA pass"));

static cl::opt<bool>
RunLoopRerolling("reroll-loops", cl::Hidden,
cl::desc("Run the loop rerolling pass"));
Expand Down Expand Up @@ -201,10 +197,7 @@ void PassManagerBuilder::populateFunctionPassManager(
addInitialAliasAnalysisPasses(FPM);

FPM.add(createCFGSimplificationPass());
if (UseNewSROA)
FPM.add(createSROAPass());
else
FPM.add(createScalarReplAggregatesPass());
FPM.add(createSROAPass());
FPM.add(createEarlyCSEPass());
FPM.add(createLowerExpectIntrinsicPass());
}
Expand All @@ -225,10 +218,7 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
legacy::PassManagerBase &MPM) {
// Start of function pass.
// Break up aggregate allocas, using SSAUpdater.
if (UseNewSROA)
MPM.add(createSROAPass());
else
MPM.add(createScalarReplAggregatesPass(-1, false));
MPM.add(createSROAPass());
MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
// Speculative execution if the target has divergent branches; otherwise nop.
MPM.add(createSpeculativeExecutionIfHasBranchDivergencePass());
Expand Down Expand Up @@ -654,10 +644,7 @@ void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
PM.add(createJumpThreadingPass());

// Break up allocas
if (UseNewSROA)
PM.add(createSROAPass());
else
PM.add(createScalarReplAggregatesPass());
PM.add(createSROAPass());

// Run a few AA driven optimizations here and now, to cleanup the code.
PM.add(createPostOrderFunctionAttrsLegacyPass()); // Add nocapture.
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Transforms/Scalar/CMakeLists.txt
Expand Up @@ -45,7 +45,6 @@ add_llvm_library(LLVMScalarOpts
SCCP.cpp
SROA.cpp
Scalar.cpp
ScalarReplAggregates.cpp
Scalarizer.cpp
SeparateConstOffsetFromGEP.cpp
SimplifyCFGPass.cpp
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Transforms/Scalar/Scalar.cpp
Expand Up @@ -74,8 +74,6 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
initializeSCCPLegacyPassPass(Registry);
initializeIPSCCPLegacyPassPass(Registry);
initializeSROALegacyPassPass(Registry);
initializeSROA_DTPass(Registry);
initializeSROA_SSAUpPass(Registry);
initializeCFGSimplifyPassPass(Registry);
initializeStructurizeCFGPass(Registry);
initializeSinkingLegacyPassPass(Registry);
Expand Down Expand Up @@ -198,16 +196,16 @@ void LLVMAddSCCPPass(LLVMPassManagerRef PM) {
}

void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createScalarReplAggregatesPass());
unwrap(PM)->add(createSROAPass());
}

void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM) {
unwrap(PM)->add(createScalarReplAggregatesPass(-1, false));
unwrap(PM)->add(createSROAPass());
}

void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM,
int Threshold) {
unwrap(PM)->add(createScalarReplAggregatesPass(Threshold));
unwrap(PM)->add(createSROAPass());
}

void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM) {
Expand Down

0 comments on commit cbf614a

Please sign in to comment.