Index: docs/ClangCommandLineReference.rst =================================================================== --- docs/ClangCommandLineReference.rst +++ docs/ClangCommandLineReference.rst @@ -2180,6 +2180,10 @@ Set the stack probe size +.. option:: -mno-stack-arg-probe + +Disable stack probes + .. option:: -mstackrealign, -mno-stackrealign Force realign the stack at entry to every function Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1822,6 +1822,8 @@ HelpText<"Set the stack alignment">; def mstack_probe_size : Joined<["-"], "mstack-probe-size=">, Group, Flags<[CC1Option]>, HelpText<"Set the stack probe size">; +def mno_stack_arg_probe : Flag<["-"], "mno-stack-arg-probe">, Group, Flags<[CC1Option]>, + HelpText<"Disable stack probes">; def mthread_model : Separate<["-"], "mthread-model">, Group, Flags<[CC1Option]>, HelpText<"The thread model to use, e.g. posix, single (posix by default)">, Values<"posix,single">; def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>, Index: include/clang/Frontend/CodeGenOptions.def =================================================================== --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -223,6 +223,7 @@ ///< alignment, if not 0. VALUE_CODEGENOPT(StackProbeSize , 32, 4096) ///< Overrides default stack ///< probe size, even if 0. +CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used CODEGENOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information ///< in debug info. Index: lib/CodeGen/TargetInfo.cpp =================================================================== --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -2355,16 +2355,17 @@ } }; -static void addStackProbeSizeTargetAttribute(const Decl *D, - llvm::GlobalValue *GV, - CodeGen::CodeGenModule &CGM) { +static void addStackProbeParamsTargetAttribute(const Decl *D, + llvm::GlobalValue *GV, + CodeGen::CodeGenModule &CGM) { if (D && isa(D)) { - if (CGM.getCodeGenOpts().StackProbeSize != 4096) { - llvm::Function *Fn = cast(GV); + llvm::Function *Fn = cast(GV); + if (CGM.getCodeGenOpts().StackProbeSize != 4096) Fn->addFnAttr("stack-probe-size", llvm::utostr(CGM.getCodeGenOpts().StackProbeSize)); - } + if (CGM.getCodeGenOpts().NoStackArgProbe) + Fn->addFnAttr("no-stack-arg-probe"); } } @@ -2374,7 +2375,7 @@ X86_32TargetCodeGenInfo::setTargetAttributes(D, GV, CGM, IsForDefinition); if (!IsForDefinition) return; - addStackProbeSizeTargetAttribute(D, GV, CGM); + addStackProbeParamsTargetAttribute(D, GV, CGM); } class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo { @@ -2436,7 +2437,7 @@ } } - addStackProbeSizeTargetAttribute(D, GV, CGM); + addStackProbeParamsTargetAttribute(D, GV, CGM); } } @@ -5622,7 +5623,7 @@ ARMTargetCodeGenInfo::setTargetAttributes(D, GV, CGM, IsForDefinition); if (!IsForDefinition) return; - addStackProbeSizeTargetAttribute(D, GV, CGM); + addStackProbeParamsTargetAttribute(D, GV, CGM); } } Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -4034,6 +4034,9 @@ CmdArgs.push_back("-mstack-probe-size=0"); } + if (Args.hasArg(options::OPT_mno_stack_arg_probe)) + CmdArgs.push_back("-mno-stack-arg-probe"); + if (Arg *A = Args.getLastArg(options::OPT_mrestrict_it, options::OPT_mno_restrict_it)) { if (A->getOption().matches(options::OPT_mrestrict_it)) { Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -914,6 +914,8 @@ Opts.StackProbeSize = StackProbeSize; } + Opts.NoStackArgProbe = Args.hasArg(OPT_mno_stack_arg_probe); + if (Arg *A = Args.getLastArg(OPT_fobjc_dispatch_method_EQ)) { StringRef Name = A->getValue(); unsigned Method = llvm::StringSwitch(Name)