Skip to content
Merged
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
4 changes: 1 addition & 3 deletions llvm/include/llvm/CodeGen/SelectionDAGISel.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ class SelectionDAGISel {
AssumptionCache *AC = nullptr;
GCFunctionInfo *GFI = nullptr;
SSPLayoutInfo *SP = nullptr;
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
Copy link
Contributor

@shiltian shiltian Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this only available under LLVM_ENABLE_ABI_BREAKING_CHECKS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was only used in debug printing, for some reason

TargetTransformInfo *TTI = nullptr;
#endif
const TargetTransformInfo *TTI = nullptr;
CodeGenOptLevel OptLevel;
const TargetInstrInfo *TII;
const TargetLowering *TLI;
Expand Down
26 changes: 11 additions & 15 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,14 +1097,15 @@ RegsForValue::getRegsAndSizes() const {
}

void SelectionDAGBuilder::init(GCFunctionInfo *gfi, BatchAAResults *aa,
AssumptionCache *ac,
const TargetLibraryInfo *li) {
AssumptionCache *ac, const TargetLibraryInfo *li,
const TargetTransformInfo &TTI) {
BatchAA = aa;
AC = ac;
GFI = gfi;
LibInfo = li;
Context = DAG.getContext();
LPadToCallSiteMap.clear();
this->TTI = &TTI;
SL->init(DAG.getTargetLoweringInfo(), TM, DAG.getDataLayout());
AssignmentTrackingEnabled = isAssignmentTrackingEnabled(
*DAG.getMachineFunction().getFunction().getParent());
Expand Down Expand Up @@ -2589,10 +2590,6 @@ bool SelectionDAGBuilder::shouldKeepJumpConditionsTogether(
if (!LhsDeps.contains(RhsI))
RhsDeps.try_emplace(RhsI, false);

const auto &TLI = DAG.getTargetLoweringInfo();
const auto &TTI =
TLI.getTargetMachine().getTargetTransformInfo(*I.getFunction());

InstructionCost CostOfIncluding = 0;
// See if this instruction will need to computed independently of whether RHS
// is.
Expand Down Expand Up @@ -2632,8 +2629,8 @@ bool SelectionDAGBuilder::shouldKeepJumpConditionsTogether(
// RHS condition. Use latency because we are essentially trying to calculate
// the cost of the dependency chain.
// Possible TODO: We could try to estimate ILP and make this more precise.
CostOfIncluding +=
TTI.getInstructionCost(InsPair.first, TargetTransformInfo::TCK_Latency);
CostOfIncluding += TTI->getInstructionCost(
InsPair.first, TargetTransformInfo::TCK_Latency);

if (CostOfIncluding > CostThresh)
return false;
Expand Down Expand Up @@ -4915,10 +4912,9 @@ void SelectionDAGBuilder::visitMaskedStore(const CallInst &I,
LocationSize::beforeOrAfterPointer(), Alignment, I.getAAMetadata());

const auto &TLI = DAG.getTargetLoweringInfo();
const auto &TTI =
TLI.getTargetMachine().getTargetTransformInfo(*I.getFunction());

SDValue StoreNode =
!IsCompressing && TTI.hasConditionalLoadStoreForType(
!IsCompressing && TTI->hasConditionalLoadStoreForType(
I.getArgOperand(0)->getType(), /*IsStore=*/true)
? TLI.visitMaskedStore(DAG, sdl, getMemoryRoot(), MMO, Ptr, Src0,
Mask)
Expand Down Expand Up @@ -5073,14 +5069,14 @@ void SelectionDAGBuilder::visitMaskedLoad(const CallInst &I, bool IsExpanding) {
LocationSize::beforeOrAfterPointer(), Alignment, AAInfo, Ranges);

const auto &TLI = DAG.getTargetLoweringInfo();
const auto &TTI =
TLI.getTargetMachine().getTargetTransformInfo(*I.getFunction());

// The Load/Res may point to different values and both of them are output
// variables.
SDValue Load;
SDValue Res;
if (!IsExpanding && TTI.hasConditionalLoadStoreForType(Src0Operand->getType(),
/*IsStore=*/false))
if (!IsExpanding &&
TTI->hasConditionalLoadStoreForType(Src0Operand->getType(),
/*IsStore=*/false))
Res = TLI.visitMaskedLoad(DAG, sdl, InChain, MMO, Load, Ptr, Src0, Mask);
else
Res = Load =
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class SelectionDAGBuilder {
BatchAAResults *BatchAA = nullptr;
AssumptionCache *AC = nullptr;
const TargetLibraryInfo *LibInfo = nullptr;
const TargetTransformInfo *TTI = nullptr;

class SDAGSwitchLowering : public SwitchCG::SwitchLowering {
public:
Expand Down Expand Up @@ -285,7 +286,7 @@ class SelectionDAGBuilder {
FuncInfo(funcinfo), SwiftError(swifterror) {}

void init(GCFunctionInfo *gfi, BatchAAResults *BatchAA, AssumptionCache *AC,
const TargetLibraryInfo *li);
const TargetLibraryInfo *li, const TargetTransformInfo &TTI);

/// Clear out the current SelectionDAG and the associated state and prepare
/// this SelectionDAGBuilder object to be used for a new block. This doesn't
Expand Down
6 changes: 1 addition & 5 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,7 @@ void SelectionDAGISel::initializeAnalysisResults(

SP = &FAM.getResult<SSPLayoutAnalysis>(Fn);

#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
TTI = &FAM.getResult<TargetIRAnalysis>(Fn);
#endif
}

void SelectionDAGISel::initializeAnalysisResults(MachineFunctionPass &MFP) {
Expand Down Expand Up @@ -578,9 +576,7 @@ void SelectionDAGISel::initializeAnalysisResults(MachineFunctionPass &MFP) {

SP = &MFP.getAnalysis<StackProtector>().getLayoutInfo();

#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
TTI = &MFP.getAnalysis<TargetTransformInfoWrapperPass>().getTTI(Fn);
#endif
}

bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
Expand All @@ -593,7 +589,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {

ISEL_DUMP(dbgs() << "\n\n\n=== " << FuncName << '\n');

SDB->init(GFI, getBatchAA(), AC, LibInfo);
SDB->init(GFI, getBatchAA(), AC, LibInfo, *TTI);

MF->setHasInlineAsm(false);

Expand Down
Loading