Skip to content

Commit 658495e

Browse files
author
serge-sans-paille
committed
1 parent af2a384 commit 658495e

30 files changed

+22
-767
lines changed

clang/docs/ClangCommandLineReference.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,10 +1917,6 @@ Use a strong heuristic to apply stack protectors to functions
19171917

19181918
Emit section containing metadata on function stack sizes
19191919

1920-
.. option:: -fstack-clash-protection, -fno-stack-clash-protection
1921-
1922-
Instrument stack allocation to prevent stack clash attacks (x86, non-Windows only).
1923-
19241920
.. option:: -fstandalone-debug, -fno-limit-debug-info, -fno-standalone-debug
19251921

19261922
Emit full debug info for all types used by the program

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ New Compiler Flags
6161
------------------
6262

6363

64-
- -fstack-clash-protection will provide a protection against the stack clash
65-
attack for x86 architecture through automatic probing of each page of
66-
allocated stack.
67-
6864
Deprecated Compiler Flags
6965
-------------------------
7066

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ CODEGENOPT(NoWarn , 1, 0) ///< Set when -Wa,--no-warn is enabled.
150150
CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is enabled.
151151
CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain
152152
///< inline line tables.
153-
CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection is enabled.
154153
CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enabled.
155154
CODEGENOPT(NoInfsFPMath , 1, 0) ///< Assume FP arguments, results not +-Inf.
156155
CODEGENOPT(NoSignedZeros , 1, 0) ///< Allow ignoring the signedness of FP zero

clang/include/clang/Basic/DiagnosticCommonKinds.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,6 @@ def note_invalid_subexpr_in_const_expr : Note<
239239
let CategoryName = "Inline Assembly Issue" in {
240240
def err_asm_invalid_type_in_input : Error<
241241
"invalid type %0 in asm input for constraint '%1'">;
242-
243-
def warn_stack_clash_protection_inline_asm : Warning<
244-
"Unable to protect inline asm that clobbers stack pointer against stack clash">,
245-
InGroup<DiagGroup<"stack-protector">>;
246242
}
247243

248244
// Sema && Serialization

clang/include/clang/Basic/TargetInfo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,6 @@ class TargetInfo : public virtual TransferrableTargetInfo,
816816
StringRef getNormalizedGCCRegisterName(StringRef Name,
817817
bool ReturnCanonical = false) const;
818818

819-
virtual bool isSPRegName(StringRef) const { return false; }
820-
821819
/// Extracts a register from the passed constraint (if it is a
822820
/// single-register constraint) and the asm label expression related to a
823821
/// variable in the input or output list of an inline asm statement.

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,10 +1773,6 @@ def fno_signed_char : Flag<["-"], "fno-signed-char">, Group<f_Group>,
17731773
def fsplit_stack : Flag<["-"], "fsplit-stack">, Group<f_Group>;
17741774
def fstack_protector_all : Flag<["-"], "fstack-protector-all">, Group<f_Group>,
17751775
HelpText<"Enable stack protectors for all functions">;
1776-
def fstack_clash_protection : Flag<["-"], "fstack-clash-protection">, Group<f_Group>, Flags<[CC1Option]>,
1777-
HelpText<"Enable stack clash protection">;
1778-
def fnostack_clash_protection : Flag<["-"], "fnostack-clash-protection">, Group<f_Group>,
1779-
HelpText<"Disable stack clash protection">;
17801776
def fstack_protector_strong : Flag<["-"], "fstack-protector-strong">, Group<f_Group>,
17811777
HelpText<"Enable stack protectors for some functions vulnerable to stack smashing. "
17821778
"Compared to -fstack-protector, this uses a stronger heuristic "

clang/lib/Basic/Targets/X86.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,6 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo {
166166

167167
ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
168168

169-
bool isSPRegName(StringRef RegName) const override {
170-
return RegName.equals("esp") || RegName.equals("rsp");
171-
}
172-
173169
bool validateCpuSupports(StringRef Name) const override;
174170

175171
bool validateCpuIs(StringRef Name) const override;

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,14 +2247,8 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
22472247

22482248
if (Clobber == "memory")
22492249
ReadOnly = ReadNone = false;
2250-
else if (Clobber != "cc") {
2250+
else if (Clobber != "cc")
22512251
Clobber = getTarget().getNormalizedGCCRegisterName(Clobber);
2252-
if (CGM.getCodeGenOpts().StackClashProtector &&
2253-
getTarget().isSPRegName(Clobber)) {
2254-
CGM.getDiags().Report(S.getAsmLoc(),
2255-
diag::warn_stack_clash_protection_inline_asm);
2256-
}
2257-
}
22582252

22592253
if (!Constraints.empty())
22602254
Constraints += ',';

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,9 +1514,6 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
15141514
if (CodeGenOpts.UnwindTables)
15151515
B.addAttribute(llvm::Attribute::UWTable);
15161516

1517-
if (CodeGenOpts.StackClashProtector)
1518-
B.addAttribute("probe-stack", "inline-asm");
1519-
15201517
if (!hasUnwindExceptions(LangOpts))
15211518
B.addAttribute(llvm::Attribute::NoUnwind);
15221519

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,21 +3002,6 @@ static void RenderSSPOptions(const ToolChain &TC, const ArgList &Args,
30023002
}
30033003
}
30043004

3005-
static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
3006-
ArgStringList &CmdArgs) {
3007-
const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
3008-
3009-
if (!EffectiveTriple.isOSLinux())
3010-
return;
3011-
3012-
if (!EffectiveTriple.isX86())
3013-
return;
3014-
3015-
if (Args.hasFlag(options::OPT_fstack_clash_protection,
3016-
options::OPT_fnostack_clash_protection, false))
3017-
CmdArgs.push_back("-fstack-clash-protection");
3018-
}
3019-
30203005
static void RenderTrivialAutoVarInitOptions(const Driver &D,
30213006
const ToolChain &TC,
30223007
const ArgList &Args,
@@ -5263,7 +5248,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
52635248
CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
52645249

52655250
RenderSSPOptions(TC, Args, CmdArgs, KernelOrKext);
5266-
RenderSCPOptions(TC, Args, CmdArgs);
52675251
RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
52685252

52695253
// Translate -mstackrealign

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,8 +1238,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
12381238

12391239
Opts.NoStackArgProbe = Args.hasArg(OPT_mno_stack_arg_probe);
12401240

1241-
Opts.StackClashProtector = Args.hasArg(OPT_fstack_clash_protection);
1242-
12431241
if (Arg *A = Args.getLastArg(OPT_fobjc_dispatch_method_EQ)) {
12441242
StringRef Name = A->getValue();
12451243
unsigned Method = llvm::StringSwitch<unsigned>(Name)

clang/test/CodeGen/stack-clash-protection.c

Lines changed: 0 additions & 22 deletions
This file was deleted.

clang/test/Driver/stack-clash-protection.c

Lines changed: 0 additions & 33 deletions
This file was deleted.

llvm/docs/ReleaseNotes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ Changes to the X86 Target
8484
During this release ...
8585

8686

87-
* Functions with the probe-stack attribute set to "inline-asm" are now protected
88-
against stack clash without the need of a third-party probing function and
89-
with limited impact on performance.
90-
9187
Changes to the AMDGPU Target
9288
-----------------------------
9389

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,10 +1727,6 @@ class TargetLoweringBase {
17271727

17281728
/// Returns the name of the symbol used to emit stack probes or the empty
17291729
/// string if not applicable.
1730-
virtual bool hasStackProbeSymbol(MachineFunction &MF) const { return false; }
1731-
1732-
virtual bool hasInlineStackProbe(MachineFunction &MF) const { return false; }
1733-
17341730
virtual StringRef getStackProbeSymbolName(MachineFunction &MF) const {
17351731
return "";
17361732
}

llvm/lib/Target/X86/X86CallFrameOptimization.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,14 @@ bool X86CallFrameOptimization::isLegal(MachineFunction &MF) {
162162
// memory for arguments.
163163
unsigned FrameSetupOpcode = TII->getCallFrameSetupOpcode();
164164
unsigned FrameDestroyOpcode = TII->getCallFrameDestroyOpcode();
165-
bool EmitStackProbeCall = STI->getTargetLowering()->hasStackProbeSymbol(MF);
165+
bool UseStackProbe =
166+
!STI->getTargetLowering()->getStackProbeSymbolName(MF).empty();
166167
unsigned StackProbeSize = STI->getTargetLowering()->getStackProbeSize(MF);
167168
for (MachineBasicBlock &BB : MF) {
168169
bool InsideFrameSequence = false;
169170
for (MachineInstr &MI : BB) {
170171
if (MI.getOpcode() == FrameSetupOpcode) {
171-
if (TII->getFrameSize(MI) >= StackProbeSize && EmitStackProbeCall)
172+
if (TII->getFrameSize(MI) >= StackProbeSize && UseStackProbe)
172173
return false;
173174
if (InsideFrameSequence)
174175
return false;

0 commit comments

Comments
 (0)