Skip to content

[CodeGen] Move EnableSinkAndFold to TargetOptions #114746

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions llvm/include/llvm/CodeGen/TargetPassConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@ class TargetPassConfig : public ImmutablePass {
/// Default setting for -enable-tail-merge on this target.
bool EnableTailMerge = true;

/// Enable sinking of instructions in MachineSink where a computation can be
/// folded into the addressing mode of a memory load/store instruction or
/// replace a copy.
bool EnableSinkAndFold = false;

/// Require processing of functions such that callees are generated before
/// callers.
bool RequireCodeGenSCCOrder = false;
Expand Down Expand Up @@ -198,9 +193,6 @@ class TargetPassConfig : public ImmutablePass {
bool getEnableTailMerge() const { return EnableTailMerge; }
void setEnableTailMerge(bool Enable) { setOpt(EnableTailMerge, Enable); }

bool getEnableSinkAndFold() const { return EnableSinkAndFold; }
void setEnableSinkAndFold(bool Enable) { setOpt(EnableSinkAndFold, Enable); }

bool requiresCodeGenSCCOrder() const { return RequireCodeGenSCCOrder; }
void setRequiresCodeGenSCCOrder(bool Enable = true) {
setOpt(RequireCodeGenSCCOrder, Enable);
Expand Down
8 changes: 7 additions & 1 deletion llvm/include/llvm/Target/TargetOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ namespace llvm {
ApproxFuncFPMath(false), EnableAIXExtendedAltivecABI(false),
HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
EnableSinkAndFold(false), EnableFastISel(false),
EnableGlobalISel(false), UseInitArray(false),
DisableIntegratedAS(false), FunctionSections(false),
DataSections(false), IgnoreXCOFFVisibility(false),
XCOFFTracebackTable(true), UniqueSectionNames(true),
Expand Down Expand Up @@ -239,6 +240,11 @@ namespace llvm {
/// they were generated. Default is true.
unsigned StackSymbolOrdering : 1;

/// EnableSinkAndFold - Enable sinking of instructions in MachineSink where
/// a computation can be folded into the addressing mode of a memory
/// load/store instruction or replace a copy.
unsigned EnableSinkAndFold : 1;

/// EnableFastISel - This flag enables fast-path instruction selection
/// which trades away generated code quality in favor of reducing
/// compile time.
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/CodeGen/MachineSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
Expand Down Expand Up @@ -729,7 +730,8 @@ bool MachineSinking::runOnMachineFunction(MachineFunction &MF) {
AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
RegClassInfo.runOnMachineFunction(MF);
TargetPassConfig *PassConfig = &getAnalysis<TargetPassConfig>();
EnableSinkAndFold = PassConfig->getEnableSinkAndFold();
auto &TM = PassConfig->getTM<TargetMachine>();
EnableSinkAndFold = TM.Options.EnableSinkAndFold;

bool EverMadeChange = false;

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ class AArch64PassConfig : public TargetPassConfig {
: TargetPassConfig(TM, PM) {
if (TM.getOptLevel() != CodeGenOptLevel::None)
substitutePass(&PostRASchedulerID, &PostMachineSchedulerID);
setEnableSinkAndFold(EnableSinkFold);
TM.Options.EnableSinkAndFold = EnableSinkFold;
}

AArch64TargetMachine &getAArch64TargetMachine() const {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class RISCVPassConfig : public TargetPassConfig {
: TargetPassConfig(TM, PM) {
if (TM.getOptLevel() != CodeGenOptLevel::None)
substitutePass(&PostRASchedulerID, &PostMachineSchedulerID);
setEnableSinkAndFold(EnableSinkFold);
TM.Options.EnableSinkAndFold = EnableSinkFold;
EnableLoopTermFold = true;
}

Expand Down
Loading