Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h
Show All 29 Lines | |||||
struct AArch64FunctionInfo; | struct AArch64FunctionInfo; | ||||
} // end namespace yaml | } // end namespace yaml | ||||
class MachineInstr; | class MachineInstr; | ||||
/// AArch64FunctionInfo - This class is derived from MachineFunctionInfo and | /// AArch64FunctionInfo - This class is derived from MachineFunctionInfo and | ||||
/// contains private AArch64-specific information for each MachineFunction. | /// contains private AArch64-specific information for each MachineFunction. | ||||
class AArch64FunctionInfo final : public MachineFunctionInfo { | class AArch64FunctionInfo final : public MachineFunctionInfo { | ||||
/// Backreference to the machine function. | |||||
MachineFunction &MF; | |||||
/// Number of bytes of arguments this function has on the stack. If the callee | /// Number of bytes of arguments this function has on the stack. If the callee | ||||
/// is expected to restore the argument stack this should be a multiple of 16, | /// is expected to restore the argument stack this should be a multiple of 16, | ||||
/// all usable during a tail call. | /// all usable during a tail call. | ||||
/// | /// | ||||
/// The alternative would forbid tail call optimisation in some cases: if we | /// The alternative would forbid tail call optimisation in some cases: if we | ||||
/// want to transfer control from a function with 8-bytes of stack-argument | /// want to transfer control from a function with 8-bytes of stack-argument | ||||
/// space to a function with 16-bytes then misalignment of this value would | /// space to a function with 16-bytes then misalignment of this value would | ||||
/// make a stack adjustment necessary, which could not be undone by the | /// make a stack adjustment necessary, which could not be undone by the | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | class AArch64FunctionInfo final : public MachineFunctionInfo { | ||||
/// OutliningStyle denotes, if a function was outined, how it was outlined, | /// OutliningStyle denotes, if a function was outined, how it was outlined, | ||||
/// e.g. Tail Call, Thunk, or Function if none apply. | /// e.g. Tail Call, Thunk, or Function if none apply. | ||||
Optional<std::string> OutliningStyle; | Optional<std::string> OutliningStyle; | ||||
// Offset from SP-after-callee-saved-spills (i.e. SP-at-entry minus | // Offset from SP-after-callee-saved-spills (i.e. SP-at-entry minus | ||||
// CalleeSavedStackSize) to the address of the frame record. | // CalleeSavedStackSize) to the address of the frame record. | ||||
int CalleeSaveBaseToFrameRecordOffset = 0; | int CalleeSaveBaseToFrameRecordOffset = 0; | ||||
public: | /// SignReturnAddress is true if PAC-RET is enabled for the function with | ||||
AArch64FunctionInfo() = default; | /// defaults being sign non-leaf functions only, with the B key. | ||||
bool SignReturnAddress = false; | |||||
/// SignReturnAddressAll modifies the default PAC-RET mode to signing leaf | |||||
/// functions as well. | |||||
tellenbach: The key type could in fact also be made an enum just like you did for the type of return… | |||||
If I would be bothered to change it, I'd rather go in the opposite direction, replace the SignReturnAddress by two booleans. That'll remove the need for a typedef and make the code less verbose. chill: If I would be bothered to change it, I'd rather go in the opposite direction, replace the… | |||||
Yep, makes sense. Anyway, the current version is fine for me. tellenbach: Yep, makes sense. Anyway, the current version is fine for me. | |||||
bool SignReturnAddressAll = false; | |||||
/// SignWithBKey modifies the default PAC-RET mode to signing with the B key. | |||||
bool SignWithBKey = false; | |||||
danielkiss: A way is needed to turn it to false even, when to the rule below turns it on. see D81251.
A… | |||||
/// BranchTargetEnforcement enables placing BTI instructions at potential | |||||
/// indirect branch destinations. | |||||
bool BranchTargetEnforcement = false; | |||||
explicit AArch64FunctionInfo(MachineFunction &MF) { | public: | ||||
(void)MF; | explicit AArch64FunctionInfo(MachineFunction &MF); | ||||
// If we already know that the function doesn't have a redzone, set | |||||
// HasRedZone here. | |||||
if (MF.getFunction().hasFnAttribute(Attribute::NoRedZone)) | |||||
HasRedZone = false; | |||||
} | |||||
void initializeBaseYamlFields(const yaml::AArch64FunctionInfo &YamlMFI); | void initializeBaseYamlFields(const yaml::AArch64FunctionInfo &YamlMFI); | ||||
unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; } | unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; } | ||||
void setBytesInStackArgArea(unsigned bytes) { BytesInStackArgArea = bytes; } | void setBytesInStackArgArea(unsigned bytes) { BytesInStackArgArea = bytes; } | ||||
unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; } | unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; } | ||||
void setArgumentStackToRestore(unsigned bytes) { | void setArgumentStackToRestore(unsigned bytes) { | ||||
ArgumentStackToRestore = bytes; | ArgumentStackToRestore = bytes; | ||||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | #endif | ||||
int getCalleeSaveBaseToFrameRecordOffset() const { | int getCalleeSaveBaseToFrameRecordOffset() const { | ||||
return CalleeSaveBaseToFrameRecordOffset; | return CalleeSaveBaseToFrameRecordOffset; | ||||
} | } | ||||
void setCalleeSaveBaseToFrameRecordOffset(int Offset) { | void setCalleeSaveBaseToFrameRecordOffset(int Offset) { | ||||
CalleeSaveBaseToFrameRecordOffset = Offset; | CalleeSaveBaseToFrameRecordOffset = Offset; | ||||
} | } | ||||
bool shouldSignReturnAddress() const; | |||||
bool shouldSignReturnAddress(bool SpillsLR) const; | |||||
bool shouldSignWithBKey() const { return SignWithBKey; } | |||||
bool branchTargetEnforcement() const { return BranchTargetEnforcement; } | |||||
private: | private: | ||||
// Hold the lists of LOHs. | // Hold the lists of LOHs. | ||||
MILOHContainer LOHContainerSet; | MILOHContainer LOHContainerSet; | ||||
SetOfInstructions LOHRelated; | SetOfInstructions LOHRelated; | ||||
SmallVector<std::pair<unsigned, MCSymbol *>, 2> JumpTableEntryInfo; | SmallVector<std::pair<unsigned, MCSymbol *>, 2> JumpTableEntryInfo; | ||||
}; | }; | ||||
Show All 22 Lines |
The key type could in fact also be made an enum just like you did for the type of return address signing but no strong opinion here.