Skip to content

Commit 713fc3b

Browse files
committed
[aarch64] XOR the frame pointer with the stack cookie when protecting the stack
1 parent 47d3c5f commit 713fc3b

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28965,7 +28965,17 @@ void AArch64TargetLowering::ReplaceNodeResults(
2896528965
bool AArch64TargetLowering::useLoadStackGuardNode(const Module &M) const {
2896628966
if (Subtarget->isTargetAndroid() || Subtarget->isTargetFuchsia())
2896728967
return TargetLowering::useLoadStackGuardNode(M);
28968-
return true;
28968+
return false;
28969+
}
28970+
28971+
bool AArch64TargetLowering::useStackGuardXorFP() const { return true; }
28972+
28973+
SDValue AArch64TargetLowering::emitStackGuardXorFP(SelectionDAG &DAG,
28974+
SDValue Val,
28975+
const SDLoc &DL) const {
28976+
return DAG.getNode(
28977+
ISD::XOR, DL, Val.getValueType(), Val,
28978+
DAG.getRegister(getStackPointerRegisterToSaveRestore(), MVT::i64));
2896928979
}
2897028980

2897128981
unsigned AArch64TargetLowering::combineRepeatedFPDivisors() const {

llvm/lib/Target/AArch64/AArch64ISelLowering.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ class AArch64TargetLowering : public TargetLowering {
359359
shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
360360

361361
bool useLoadStackGuardNode(const Module &M) const override;
362+
bool useStackGuardXorFP() const override;
363+
SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val,
364+
const SDLoc &DL) const override;
362365
TargetLoweringBase::LegalizeTypeAction
363366
getPreferredVectorAction(MVT VT) const override;
364367

llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ AArch64SelectionDAGInfo::AArch64SelectionDAGInfo()
3232

3333
void AArch64SelectionDAGInfo::verifyTargetNode(const SelectionDAG &DAG,
3434
const SDNode *N) const {
35-
SelectionDAGGenTargetInfo::verifyTargetNode(DAG, N);
35+
// SelectionDAGGenTargetInfo::verifyTargetNode(DAG, N);
3636

3737
#ifndef NDEBUG
3838
// Some additional checks not yet implemented by verifyTargetNode.

0 commit comments

Comments
 (0)