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 2763964 commit 414995aCopy full SHA for 414995a
llvm/include/llvm/CodeGen/TargetLowering.h
@@ -5828,7 +5828,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
5828
virtual bool useLoadStackGuardNode(const Module &M) const { return false; }
5829
5830
virtual SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val,
5831
- const SDLoc &DL) const {
+ const SDLoc &DL, bool FailureBB) const {
5832
llvm_unreachable("not implemented for this target");
5833
}
5834
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
@@ -7429,7 +7429,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
7429
7430
7431
7432
- Res = TLI.emitStackGuardXorFP(DAG, Res, sdl);
+ Res = TLI.emitStackGuardXorFP(DAG, Res, sdl, false);
7433
DAG.setRoot(Chain);
7434
setValue(&I, Res);
7435
return;
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -29242,6 +29242,25 @@ bool AArch64TargetLowering::useLoadStackGuardNode(const Module &M) const {
29242
return true;
29243
29244
29245
+bool AArch64TargetLowering::useStackGuardXorFP() const {
29246
+ // Currently only MSVC CRTs XOR the frame pointer into the stack guard value.
29247
+ return Subtarget->getTargetTriple().isOSMSVCRT() &&
29248
+ !Subtarget->isTargetMachO() &&
29249
+ !getTargetMachine().Options.EnableGlobalISel;
29250
+}
29251
+
29252
+SDValue AArch64TargetLowering::emitStackGuardXorFP(SelectionDAG &DAG,
29253
+ SDValue Val, const SDLoc &DL,
29254
+ bool FailureBB) const {
29255
+ if (FailureBB) {
29256
+ return DAG.getNode(
29257
+ ISD::XOR, DL, Val.getValueType(), Val,
29258
+ DAG.getCopyFromReg(DAG.getEntryNode(), DL,
29259
+ getStackPointerRegisterToSaveRestore(), MVT::i64));
29260
+ }
29261
+ return Val;
29262
29263
29264
unsigned AArch64TargetLowering::combineRepeatedFPDivisors() const {
29265
// Combine multiple FDIVs with the same divisor into multiple FMULs by the
29266
// reciprocal if there are three or more FDIVs.
llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -363,6 +363,9 @@ class AArch64TargetLowering : public TargetLowering {
363
shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
364
365
bool useLoadStackGuardNode(const Module &M) const override;
366
+ bool useStackGuardXorFP() const override;
367
+ SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val, const SDLoc &DL,
368
+ bool FailureBB) const override;
369
TargetLoweringBase::LegalizeTypeAction
370
getPreferredVectorAction(MVT VT) const override;
371
llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2744,7 +2744,8 @@ bool X86TargetLowering::useStackGuardXorFP() const {
2744
2745
2746
SDValue X86TargetLowering::emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val,
2747
+ const SDLoc &DL,
2748
2749
EVT PtrTy = getPointerTy(DAG.getDataLayout());
2750
unsigned XorOp = Subtarget.is64Bit() ? X86::XOR64_FP : X86::XOR32_FP;
2751
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