Skip to content

Commit

Permalink
[NFC][CodeGen] Use const MF in TargetLowering stack probe functions
Browse files Browse the repository at this point in the history
This makes them callable from places like canUseAsPrologue.

Differential Revision: https://reviews.llvm.org/D134492
  • Loading branch information
cuviper committed Sep 23, 2022
1 parent 0de7c15 commit 4dcfb09
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions llvm/include/llvm/CodeGen/TargetLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -1904,11 +1904,11 @@ class TargetLoweringBase {

/// Returns the name of the symbol used to emit stack probes or the empty
/// string if not applicable.
virtual bool hasStackProbeSymbol(MachineFunction &MF) const { return false; }
virtual bool hasStackProbeSymbol(const MachineFunction &MF) const { return false; }

virtual bool hasInlineStackProbe(MachineFunction &MF) const { return false; }
virtual bool hasInlineStackProbe(const MachineFunction &MF) const { return false; }

virtual StringRef getStackProbeSymbolName(MachineFunction &MF) const {
virtual StringRef getStackProbeSymbolName(const MachineFunction &MF) const {
return "";
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/PowerPC/PPCISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11998,15 +11998,15 @@ PPCTargetLowering::emitEHSjLjLongJmp(MachineInstr &MI,
return MBB;
}

bool PPCTargetLowering::hasInlineStackProbe(MachineFunction &MF) const {
bool PPCTargetLowering::hasInlineStackProbe(const MachineFunction &MF) const {
// If the function specifically requests inline stack probes, emit them.
if (MF.getFunction().hasFnAttribute("probe-stack"))
return MF.getFunction().getFnAttribute("probe-stack").getValueAsString() ==
"inline-asm";
return false;
}

unsigned PPCTargetLowering::getStackProbeSize(MachineFunction &MF) const {
unsigned PPCTargetLowering::getStackProbeSize(const MachineFunction &MF) const {
const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
unsigned StackAlign = TFI->getStackAlignment();
assert(StackAlign >= 1 && isPowerOf2_32(StackAlign) &&
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/PowerPC/PPCISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -954,9 +954,9 @@ namespace llvm {
MachineBasicBlock *emitProbedAlloca(MachineInstr &MI,
MachineBasicBlock *MBB) const;

bool hasInlineStackProbe(MachineFunction &MF) const override;
bool hasInlineStackProbe(const MachineFunction &MF) const override;

unsigned getStackProbeSize(MachineFunction &MF) const;
unsigned getStackProbeSize(const MachineFunction &MF) const;

ConstraintType getConstraintType(StringRef Constraint) const override;

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ bool SystemZTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT,
}

/// Returns true if stack probing through inline assembly is requested.
bool SystemZTargetLowering::hasInlineStackProbe(MachineFunction &MF) const {
bool SystemZTargetLowering::hasInlineStackProbe(const MachineFunction &MF) const {
// If the function specifically requests inline stack probes, emit them.
if (MF.getFunction().hasFnAttribute("probe-stack"))
return MF.getFunction().getFnAttribute("probe-stack").getValueAsString() ==
Expand Down Expand Up @@ -7439,7 +7439,7 @@ SystemZTargetLowering::ComputeNumSignBitsForTargetNode(
}

unsigned
SystemZTargetLowering::getStackProbeSize(MachineFunction &MF) const {
SystemZTargetLowering::getStackProbeSize(const MachineFunction &MF) const {
const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
unsigned StackAlign = TFI->getStackAlignment();
assert(StackAlign >=1 && isPowerOf2_32(StackAlign) &&
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/SystemZ/SystemZISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class SystemZTargetLowering : public TargetLowering {
// LD, and having the full constant in memory enables reg/mem opcodes.
return VT != MVT::f64;
}
bool hasInlineStackProbe(MachineFunction &MF) const override;
bool hasInlineStackProbe(const MachineFunction &MF) const override;
bool isLegalICmpImmediate(int64_t Imm) const override;
bool isLegalAddImmediate(int64_t Imm) const override;
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
Expand Down Expand Up @@ -614,7 +614,7 @@ class SystemZTargetLowering : public TargetLowering {
return true;
}

unsigned getStackProbeSize(MachineFunction &MF) const;
unsigned getStackProbeSize(const MachineFunction &MF) const;

private:
const SystemZSubtarget &Subtarget;
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56594,12 +56594,12 @@ bool X86TargetLowering::supportSwiftError() const {
}

/// Returns true if stack probing through a function call is requested.
bool X86TargetLowering::hasStackProbeSymbol(MachineFunction &MF) const {
bool X86TargetLowering::hasStackProbeSymbol(const MachineFunction &MF) const {
return !getStackProbeSymbolName(MF).empty();
}

/// Returns true if stack probing through inline assembly is requested.
bool X86TargetLowering::hasInlineStackProbe(MachineFunction &MF) const {
bool X86TargetLowering::hasInlineStackProbe(const MachineFunction &MF) const {

// No inline stack probe for Windows, they have their own mechanism.
if (Subtarget.isOSWindows() ||
Expand All @@ -56617,7 +56617,7 @@ bool X86TargetLowering::hasInlineStackProbe(MachineFunction &MF) const {
/// Returns the name of the symbol used to emit stack probes or the empty
/// string if not applicable.
StringRef
X86TargetLowering::getStackProbeSymbolName(MachineFunction &MF) const {
X86TargetLowering::getStackProbeSymbolName(const MachineFunction &MF) const {
// Inline Stack probes disable stack probe call
if (hasInlineStackProbe(MF))
return "";
Expand All @@ -56640,7 +56640,7 @@ X86TargetLowering::getStackProbeSymbolName(MachineFunction &MF) const {
}

unsigned
X86TargetLowering::getStackProbeSize(MachineFunction &MF) const {
X86TargetLowering::getStackProbeSize(const MachineFunction &MF) const {
// The default stack probe size is 4096 if the function has no stackprobesize
// attribute.
unsigned StackProbeSize = 4096;
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/X86/X86ISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -1455,11 +1455,11 @@ namespace llvm {

bool supportKCFIBundles() const override { return true; }

bool hasStackProbeSymbol(MachineFunction &MF) const override;
bool hasInlineStackProbe(MachineFunction &MF) const override;
StringRef getStackProbeSymbolName(MachineFunction &MF) const override;
bool hasStackProbeSymbol(const MachineFunction &MF) const override;
bool hasInlineStackProbe(const MachineFunction &MF) const override;
StringRef getStackProbeSymbolName(const MachineFunction &MF) const override;

unsigned getStackProbeSize(MachineFunction &MF) const;
unsigned getStackProbeSize(const MachineFunction &MF) const;

bool hasVectorBlend() const override { return true; }

Expand Down

0 comments on commit 4dcfb09

Please sign in to comment.