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 9dfdc66 commit ba7a7c6Copy full SHA for ba7a7c6
llvm/include/llvm/CodeGen/TargetLowering.h
@@ -5770,7 +5770,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
5770
virtual bool useLoadStackGuardNode(const Module &M) const { return false; }
5771
5772
virtual SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val,
5773
- const SDLoc &DL) const {
+ const SDLoc &DL, bool FailureBB) const {
5774
llvm_unreachable("not implemented for this target");
5775
}
5776
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3087,7 +3087,7 @@ void SelectionDAGBuilder::visitSPDescriptorParent(StackProtectorDescriptor &SPD,
3087
MachineMemOperand::MOVolatile);
3088
3089
if (TLI.useStackGuardXorFP())
3090
- GuardVal = TLI.emitStackGuardXorFP(DAG, GuardVal, dl);
+ GuardVal = TLI.emitStackGuardXorFP(DAG, GuardVal, dl, false);
3091
3092
// If we're using function-based instrumentation, call the guard check
3093
// function
@@ -3192,7 +3192,7 @@ void SelectionDAGBuilder::visitSPDescriptorFailure(
3192
3193
3194
3195
+ GuardVal = TLI.emitStackGuardXorFP(DAG, GuardVal, dl, true);
3196
3197
// The target provides a guard check function to validate the guard value.
3198
// Generate a call to that function with the content of the guard slot as
@@ -7354,7 +7354,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
7354
7355
7356
7357
- Res = TLI.emitStackGuardXorFP(DAG, Res, sdl);
+ Res = TLI.emitStackGuardXorFP(DAG, Res, sdl, false);
7358
DAG.setRoot(Chain);
7359
setValue(&I, Res);
7360
return;
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -28968,6 +28968,25 @@ bool AArch64TargetLowering::useLoadStackGuardNode(const Module &M) const {
28968
return true;
28969
28970
28971
+bool AArch64TargetLowering::useStackGuardXorFP() const {
28972
+ // Currently only MSVC CRTs XOR the frame pointer into the stack guard value.
28973
+ return Subtarget->getTargetTriple().isOSMSVCRT() &&
28974
+ !Subtarget->isTargetMachO() &&
28975
+ !getTargetMachine().Options.EnableGlobalISel;
28976
+}
28977
+
28978
+SDValue AArch64TargetLowering::emitStackGuardXorFP(SelectionDAG &DAG,
28979
+ SDValue Val, const SDLoc &DL,
28980
+ bool FailureBB) const {
28981
+ if (FailureBB) {
28982
+ return DAG.getNode(
28983
+ ISD::XOR, DL, Val.getValueType(), Val,
28984
+ DAG.getCopyFromReg(DAG.getEntryNode(), DL,
28985
+ getStackPointerRegisterToSaveRestore(), MVT::i64));
28986
+ }
28987
+ return Val;
28988
28989
28990
unsigned AArch64TargetLowering::combineRepeatedFPDivisors() const {
28991
// Combine multiple FDIVs with the same divisor into multiple FMULs by the
28992
// reciprocal if there are three or more FDIVs.
llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -359,6 +359,9 @@ class AArch64TargetLowering : public TargetLowering {
359
shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
360
361
bool useLoadStackGuardNode(const Module &M) const override;
362
+ bool useStackGuardXorFP() const override;
363
+ SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val, const SDLoc &DL,
364
+ bool FailureBB) const override;
365
TargetLoweringBase::LegalizeTypeAction
366
getPreferredVectorAction(MVT VT) const override;
367
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
@@ -1594,9 +1594,8 @@ namespace llvm {
1594
bool useStackGuardXorFP() const override;
1595
void insertSSPDeclarations(Module &M) const override;
1596
Function *getSSPStackGuardCheck(const Module &M) const override;
1597
- SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val,
1598
- const SDLoc &DL) const override;
1599
-
1600
1601
/// Return true if the target stores SafeStack pointer at a fixed offset in
1602
/// 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