We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 23fbbbb commit c61707aCopy full SHA for c61707a
llvm/include/llvm/CodeGen/TargetLowering.h
@@ -5798,7 +5798,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
5798
virtual bool useLoadStackGuardNode(const Module &M) const { return false; }
5799
5800
virtual SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val,
5801
- const SDLoc &DL) const {
+ const SDLoc &DL, bool FailureBB) const {
5802
llvm_unreachable("not implemented for this target");
5803
}
5804
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3129,7 +3129,7 @@ void SelectionDAGBuilder::visitSPDescriptorParent(StackProtectorDescriptor &SPD,
3129
MachineMemOperand::MOVolatile);
3130
3131
if (TLI.useStackGuardXorFP())
3132
- GuardVal = TLI.emitStackGuardXorFP(DAG, GuardVal, dl);
+ GuardVal = TLI.emitStackGuardXorFP(DAG, GuardVal, dl, false);
3133
3134
// If we're using function-based instrumentation, call the guard check
3135
// function
@@ -3238,7 +3238,7 @@ void SelectionDAGBuilder::visitSPDescriptorFailure(
3238
3239
3240
3241
+ GuardVal = TLI.emitStackGuardXorFP(DAG, GuardVal, dl, true);
3242
3243
// The target provides a guard check function to validate the guard value.
3244
// Generate a call to that function with the content of the guard slot as
@@ -7381,7 +7381,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
7381
7382
7383
7384
- Res = TLI.emitStackGuardXorFP(DAG, Res, sdl);
+ Res = TLI.emitStackGuardXorFP(DAG, Res, sdl, false);
7385
DAG.setRoot(Chain);
7386
setValue(&I, Res);
7387
return;
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -29096,6 +29096,25 @@ bool AArch64TargetLowering::useLoadStackGuardNode(const Module &M) const {
29096
return true;
29097
29098
29099
+bool AArch64TargetLowering::useStackGuardXorFP() const {
29100
+ // Currently only MSVC CRTs XOR the frame pointer into the stack guard value.
29101
+ return Subtarget->getTargetTriple().isOSMSVCRT() &&
29102
+ !Subtarget->isTargetMachO() &&
29103
+ !getTargetMachine().Options.EnableGlobalISel;
29104
+}
29105
+
29106
+SDValue AArch64TargetLowering::emitStackGuardXorFP(SelectionDAG &DAG,
29107
+ SDValue Val, const SDLoc &DL,
29108
+ bool FailureBB) const {
29109
+ if (FailureBB) {
29110
+ return DAG.getNode(
29111
+ ISD::XOR, DL, Val.getValueType(), Val,
29112
+ DAG.getCopyFromReg(DAG.getEntryNode(), DL,
29113
+ getStackPointerRegisterToSaveRestore(), MVT::i64));
29114
+ }
29115
+ return Val;
29116
29117
29118
unsigned AArch64TargetLowering::combineRepeatedFPDivisors() const {
29119
// Combine multiple FDIVs with the same divisor into multiple FMULs by the
29120
// reciprocal if there are three or more FDIVs.
llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -358,6 +358,9 @@ class AArch64TargetLowering : public TargetLowering {
358
shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
359
360
bool useLoadStackGuardNode(const Module &M) const override;
361
+ bool useStackGuardXorFP() const override;
362
+ SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val, const SDLoc &DL,
363
+ bool FailureBB) const override;
364
TargetLoweringBase::LegalizeTypeAction
365
getPreferredVectorAction(MVT VT) const override;
366
llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2739,7 +2739,8 @@ bool X86TargetLowering::useStackGuardXorFP() const {
2739
2740
2741
SDValue X86TargetLowering::emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val,
2742
+ const SDLoc &DL,
2743
2744
EVT PtrTy = getPointerTy(DAG.getDataLayout());
2745
unsigned XorOp = Subtarget.is64Bit() ? X86::XOR64_FP : X86::XOR32_FP;
2746
MachineSDNode *Node = DAG.getMachineNode(XorOp, DL, PtrTy, Val);
llvm/lib/Target/X86/X86ISelLowering.h
@@ -1592,9 +1592,8 @@ namespace llvm {
1592
1593
bool useStackGuardXorFP() const override;
1594
void insertSSPDeclarations(Module &M) const override;
1595
- SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val,
1596
- const SDLoc &DL) const override;
1597
-
1598
1599
/// Return true if the target stores SafeStack pointer at a fixed offset in
1600
/// some non-standard address space, and populates the address space and
llvm/test/CodeGen/AArch64/stack-protector-target.ll
@@ -34,13 +34,17 @@ declare void @_Z7CapturePi(ptr)
34
; WINDOWS-AARCH64: eor x8, x8, sp
35
; WINDOWS-AARCH64: str x8, [sp, #8]
36
; WINDOWS-AARCH64: bl _Z7CapturePi
37
-; WINDOWS-AARCH64: ldr x0, [sp, #8]
+; WINDOWS-AARCH64: ldr x8, [sp, #8]
38
+; WINDOWS-AARCH64: mov x9, sp
39
+; WINDOWS-AARCH64: eor x0, x8, x9
40
; WINDOWS-AARCH64: bl __security_check_cookie
41
42
; WINDOWS-ARM64EC: adrp x8, __security_cookie
43
; WINDOWS-ARM64EC: ldr x8, [x8, :lo12:__security_cookie]
44
; WINDOWS-ARM64EC: eor x8, x8, sp
45
; WINDOWS-ARM64EC: str x8, [sp, #8]
46
; WINDOWS-ARM64EC: bl "#_Z7CapturePi"
-; WINDOWS-ARM64EC: ldr x0, [sp, #8]
47
+; WINDOWS-ARM64EC: ldr x8, [sp, #8]
48
+; WINDOWS-ARM64EC: mov x9, sp
49
+; WINDOWS-ARM64EC: eor x0, x8, x9
50
; WINDOWS-ARM64EC: bl "#__security_check_cookie_arm64ec"
0 commit comments