From c3ae583a9a2e0e5c862a94b678c7cdfaab46a981 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 14 Mar 2013 05:14:01 +0000 Subject: Update GCOVProfiling pass creation for API change in r177002. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177004 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/BackendUtil.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'lib/CodeGen/BackendUtil.cpp') diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index ab65801ce5..9c9c561380 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -303,13 +303,18 @@ void EmitAssemblyHelper::CreatePasses(TargetMachine *TM) { PassManager *MPM = getPerModulePasses(TM); if (CodeGenOpts.EmitGcovArcs || CodeGenOpts.EmitGcovNotes) { - MPM->add(createGCOVProfilerPass(CodeGenOpts.EmitGcovNotes, - CodeGenOpts.EmitGcovArcs, - CodeGenOpts.CoverageVersion, - CodeGenOpts.CoverageExtraChecksum, - CodeGenOpts.DisableRedZone, - CodeGenOpts.CoverageFunctionNamesInData)); - + // Not using 'GCOVOptions::getDefault' allows us to avoid exiting if + // LLVM's -default-gcov-version flag is set to something invalid. + GCOVOptions Options; + Options.EmitNotes = CodeGenOpts.EmitGcovNotes; + Options.EmitData = CodeGenOpts.EmitGcovArcs; + memcpy(Options.Version, CodeGenOpts.CoverageVersion, 4); + Options.UseCfgChecksum = CodeGenOpts.CoverageExtraChecksum; + Options.NoRedZone = CodeGenOpts.DisableRedZone; + // FIXME: the clang flag name is backwards. + Options.FunctionNamesInData = + !CodeGenOpts.CoverageFunctionNamesInData; + MPM->add(createGCOVProfilerPass(Options)); if (CodeGenOpts.getDebugInfo() == CodeGenOptions::NoDebugInfo) MPM->add(createStripSymbolsPass(true)); } -- cgit v1.2.3-70-g09d2 From f2b5e0707229e1149828ebc8d01d9308a997d6df Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 20 Mar 2013 01:38:16 +0000 Subject: Make clang emit linkage names in debug info for subprograms when coverage info is enabled. Also add a new -test-coverage cc1 flag which makes testing coverage possible and add our first clang-side coverage test. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177470 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/CC1Options.td | 2 ++ include/clang/Frontend/CodeGenOptions.def | 1 + lib/CodeGen/BackendUtil.cpp | 3 ++- lib/CodeGen/CGDebugInfo.cpp | 9 +++++++-- lib/Frontend/CompilerInvocation.cpp | 1 + test/CodeGenCXX/coverage.cpp | 7 +++++++ 6 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 test/CodeGenCXX/coverage.cpp (limited to 'lib/CodeGen/BackendUtil.cpp') diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 24ac33d9ff..444789348c 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -155,6 +155,8 @@ def coverage_function_names_in_data : Flag<["-"], "coverage-function-names-in-da HelpText<"Emit function names in .gcda files.">; def coverage_version_EQ : Joined<["-"], "coverage-version=">, HelpText<"Four-byte version string for gcov files.">; +def test_coverage : Flag<["-"], "test-coverage">, + HelpText<"Do not generate coverage files or remove coverage changes from IR">; def fuse_register_sized_bitfield_access: Flag<["-"], "fuse-register-sized-bitfield-access">, HelpText<"Use register sized accesses to bit-fields, when possible.">; def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">, diff --git a/include/clang/Frontend/CodeGenOptions.def b/include/clang/Frontend/CodeGenOptions.def index 333fa1e88f..54785cffc1 100644 --- a/include/clang/Frontend/CodeGenOptions.def +++ b/include/clang/Frontend/CodeGenOptions.def @@ -42,6 +42,7 @@ CODEGENOPT(DisableLLVMOpts , 1, 0) ///< Don't run any optimizations, for use i ///< getting .bc files that correspond to the ///< internal state before optimizations are ///< done. +CODEGENOPT(DisableGCov , 1, 0) ///< Don't run the GCov pass, for testing. CODEGENOPT(DisableRedZone , 1, 0) ///< Set when -mno-red-zone is enabled. CODEGENOPT(DisableTailCalls , 1, 0) ///< Do not emit tail calls. CODEGENOPT(EmitDeclMetadata , 1, 0) ///< Emit special metadata indicating what diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 9c9c561380..23d8b97ae1 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -302,7 +302,8 @@ void EmitAssemblyHelper::CreatePasses(TargetMachine *TM) { // Set up the per-module pass manager. PassManager *MPM = getPerModulePasses(TM); - if (CodeGenOpts.EmitGcovArcs || CodeGenOpts.EmitGcovNotes) { + if (!CodeGenOpts.DisableGCov && + (CodeGenOpts.EmitGcovArcs || CodeGenOpts.EmitGcovNotes)) { // Not using 'GCOVOptions::getDefault' allows us to avoid exiting if // LLVM's -default-gcov-version flag is set to something invalid. GCOVOptions Options; diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index ae88732c82..e7931a8a84 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -2224,13 +2224,18 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType, } } Name = getFunctionName(FD); - // Use mangled name as linkage name for c/c++ functions. + // Use mangled name as linkage name for C/C++ functions. if (FD->hasPrototype()) { LinkageName = CGM.getMangledName(GD); Flags |= llvm::DIDescriptor::FlagPrototyped; } + // No need to replicate the linkage name if it isn't different from the + // subprogram name, no need to have it at all unless coverage is enabled or + // debug is set to more than just line tables. if (LinkageName == Name || - CGM.getCodeGenOpts().getDebugInfo() <= CodeGenOptions::DebugLineTablesOnly) + (!CGM.getCodeGenOpts().EmitGcovArcs && + !CGM.getCodeGenOpts().EmitGcovNotes && + CGM.getCodeGenOpts().getDebugInfo() <= CodeGenOptions::DebugLineTablesOnly)) LinkageName = StringRef(); if (CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo) { diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index f6ba4e50ac..9f1228a403 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -380,6 +380,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.VerifyModule = !Args.hasArg(OPT_disable_llvm_verifier); Opts.SanitizeRecover = !Args.hasArg(OPT_fno_sanitize_recover); + Opts.DisableGCov = Args.hasArg(OPT_test_coverage); Opts.EmitGcovArcs = Args.hasArg(OPT_femit_coverage_data); Opts.EmitGcovNotes = Args.hasArg(OPT_femit_coverage_notes); if (Opts.EmitGcovArcs || Opts.EmitGcovNotes) { diff --git a/test/CodeGenCXX/coverage.cpp b/test/CodeGenCXX/coverage.cpp new file mode 100644 index 0000000000..1f1611bd8f --- /dev/null +++ b/test/CodeGenCXX/coverage.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - -test-coverage -femit-coverage-notes | FileCheck %s + +extern "C" void test_name1() {} +void test_name2() {} + +// CHECK: metadata !"test_name1", metadata !"test_name1", metadata !"",{{.*}}DW_TAG_subprogram +// CHECK: metadata !"test_name2", metadata !"test_name2", metadata !"_Z10test_name2v",{{.*}}DW_TAG_subprogram -- cgit v1.2.3-70-g09d2 From 83c546afef39d6b7be69f3f399804ebf037c4022 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 20 Mar 2013 02:14:38 +0000 Subject: The flag "-coverage-function-names-in-data" is actually backwards -- we do emit function names in .gcda files by default, and the flag turns that off! Rename the flag to make it match what it actually does. This keeps the default format compatible with gcc 4.2. Also add a test for this flag. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177475 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/CC1Options.td | 2 +- include/clang/Frontend/CodeGenOptions.def | 2 +- lib/CodeGen/BackendUtil.cpp | 3 +-- lib/Frontend/CompilerInvocation.cpp | 4 ++-- test/CodeGen/code-coverage.c | 8 ++++++++ 5 files changed, 13 insertions(+), 6 deletions(-) (limited to 'lib/CodeGen/BackendUtil.cpp') diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 444789348c..c2ac1cfe51 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -151,7 +151,7 @@ def coverage_file : Separate<["-"], "coverage-file">, def coverage_file_EQ : Joined<["-"], "coverage-file=">, Alias; def coverage_cfg_checksum : Flag<["-"], "coverage-cfg-checksum">, HelpText<"Emit CFG checksum for functions in .gcno files.">; -def coverage_function_names_in_data : Flag<["-"], "coverage-function-names-in-data">, +def coverage_no_function_names_in_data : Flag<["-"], "coverage-no-function-names-in-data">, HelpText<"Emit function names in .gcda files.">; def coverage_version_EQ : Joined<["-"], "coverage-version=">, HelpText<"Four-byte version string for gcov files.">; diff --git a/include/clang/Frontend/CodeGenOptions.def b/include/clang/Frontend/CodeGenOptions.def index 54785cffc1..92df6bb871 100644 --- a/include/clang/Frontend/CodeGenOptions.def +++ b/include/clang/Frontend/CodeGenOptions.def @@ -31,7 +31,7 @@ CODEGENOPT(Name, Bits, Default) CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm. CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe. CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum for functions in GCNO files. -CODEGENOPT(CoverageFunctionNamesInData, 1, 0) ///< Whether we should include function names in GCDA files. +CODEGENOPT(CoverageNoFunctionNamesInData, 1, 0) ///< Do not include function names in GCDA files. CODEGENOPT(CUDAIsDevice , 1, 0) ///< Set when compiling for CUDA device. CODEGENOPT(CXAAtExit , 1, 1) ///< Use __cxa_atexit for calling destructors. CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 23d8b97ae1..952d1fb15d 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -312,9 +312,8 @@ void EmitAssemblyHelper::CreatePasses(TargetMachine *TM) { memcpy(Options.Version, CodeGenOpts.CoverageVersion, 4); Options.UseCfgChecksum = CodeGenOpts.CoverageExtraChecksum; Options.NoRedZone = CodeGenOpts.DisableRedZone; - // FIXME: the clang flag name is backwards. Options.FunctionNamesInData = - !CodeGenOpts.CoverageFunctionNamesInData; + !CodeGenOpts.CoverageNoFunctionNamesInData; MPM->add(createGCOVProfilerPass(Options)); if (CodeGenOpts.getDebugInfo() == CodeGenOptions::NoDebugInfo) MPM->add(createStripSymbolsPass(true)); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 9f1228a403..301a082cbd 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -386,8 +386,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, if (Opts.EmitGcovArcs || Opts.EmitGcovNotes) { Opts.CoverageFile = Args.getLastArgValue(OPT_coverage_file); Opts.CoverageExtraChecksum = Args.hasArg(OPT_coverage_cfg_checksum); - Opts.CoverageFunctionNamesInData = - Args.hasArg(OPT_coverage_function_names_in_data); + Opts.CoverageNoFunctionNamesInData = + Args.hasArg(OPT_coverage_no_function_names_in_data); if (Args.hasArg(OPT_coverage_version_EQ)) { StringRef CoverageVersion = Args.getLastArgValue(OPT_coverage_version_EQ); if (CoverageVersion.size() != 4) { diff --git a/test/CodeGen/code-coverage.c b/test/CodeGen/code-coverage.c index 2c5aa6b227..1b87d649dd 100644 --- a/test/CodeGen/code-coverage.c +++ b/test/CodeGen/code-coverage.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data -coverage-no-function-names-in-data %s -o - | FileCheck %s --check-prefix WITHOUTNAMES // @@ -15,7 +16,14 @@ int test1(int a) { // Check that the noredzone flag is set on the generated functions. // CHECK: void @__llvm_gcov_indirect_counter_increment(i32* %{{.*}}, i64** %{{.*}}) unnamed_addr [[NRZ:#[0-9]+]] + +// Inside llvm_gcov_writeout, check that -coverage-no-function-names-in-data +// passes null as the function name. // CHECK: void @__llvm_gcov_writeout() unnamed_addr [[NRZ]] +// CHECK: call void @llvm_gcda_emit_function({{.*}}, i8* getelementptr {{.*}}, {{.*}}) +// WITHOUTNAMES: void @__llvm_gcov_writeout() unnamed_addr +// WITHOUTNAMES: call void @llvm_gcda_emit_function({{.*}}, i8* null, {{.*}}) + // CHECK: void @__llvm_gcov_flush() unnamed_addr [[NRZ]] // CHECK: void @__llvm_gcov_init() unnamed_addr [[NRZ]] -- cgit v1.2.3-70-g09d2 From e2359e21320f39b167b31afb0c281419361faa51 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Tue, 26 Mar 2013 18:01:48 +0000 Subject: Fix a crasher by reporting a fatal error if we're unable to create the target machine and one is required. Part of rdar://13295753 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178042 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticFrontendKinds.td | 2 -- lib/CodeGen/BackendUtil.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/CodeGen/BackendUtil.cpp') diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index 111622e0fe..29822683ed 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -42,8 +42,6 @@ def err_fe_unable_to_load_pch : Error< "unable to load PCH file">; def err_fe_unable_to_load_plugin : Error< "unable to load plugin '%0': '%1'">; -def err_fe_unable_to_create_target : Error< - "unable to create target: '%0'">; def err_fe_unable_to_interface_with_target : Error< "unable to interface with target machine">; def err_fe_unable_to_open_output : Error< diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 952d1fb15d..1d7395915b 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -329,7 +329,7 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error); if (!TheTarget) { if (MustCreateTM) - Diags.Report(diag::err_fe_unable_to_create_target) << Error; + llvm::report_fatal_error ("Unable to create target: " + Error); return 0; } -- cgit v1.2.3-70-g09d2 From a03fc6e249e1662f879467f66c49a3c866850773 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 27 Mar 2013 00:14:35 +0000 Subject: If we're unable to create the TargetMachine, then just quit producing the backend output; there's no need to report a fatal error. This reverts r178042. Part of rdar://13295753 and rdar://13401547 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178102 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticFrontendKinds.td | 2 ++ lib/CodeGen/BackendUtil.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/BackendUtil.cpp') diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index 29822683ed..111622e0fe 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -42,6 +42,8 @@ def err_fe_unable_to_load_pch : Error< "unable to load PCH file">; def err_fe_unable_to_load_plugin : Error< "unable to load plugin '%0': '%1'">; +def err_fe_unable_to_create_target : Error< + "unable to create target: '%0'">; def err_fe_unable_to_interface_with_target : Error< "unable to interface with target machine">; def err_fe_unable_to_open_output : Error< diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 1d7395915b..019570ce23 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -329,7 +329,7 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error); if (!TheTarget) { if (MustCreateTM) - llvm::report_fatal_error ("Unable to create target: " + Error); + Diags.Report(diag::err_fe_unable_to_create_target) << Error; return 0; } @@ -527,6 +527,7 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, raw_ostream *OS) { Action != Backend_EmitBC && Action != Backend_EmitLL); TargetMachine *TM = CreateTargetMachine(UsesCodeGen); + if (UsesCodeGen && !TM) return; CreatePasses(TM); switch (Action) { -- cgit v1.2.3-70-g09d2 From 3105627bd76d6a0cc5ee305c99f4c96519bac9ac Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 4 Apr 2013 06:29:47 +0000 Subject: Plumb through the -fsplit-stack option using the existing backend support. Caveat: Other than the existing segmented stacks support, no claims are made of this working. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178744 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/CC1Options.td | 2 ++ include/clang/Driver/Options.td | 1 + include/clang/Frontend/CodeGenOptions.def | 1 + lib/CodeGen/BackendUtil.cpp | 1 + lib/Driver/Tools.cpp | 4 ++++ lib/Frontend/CompilerInvocation.cpp | 1 + test/Driver/clang_f_opts.c | 3 ++- 7 files changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/BackendUtil.cpp') diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 65326c67ba..ab2d5dc4fb 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -184,6 +184,8 @@ def mlimit_float_precision : Separate<["-"], "mlimit-float-precision">, HelpText<"Limit float precision to the given value">; def mno_exec_stack : Flag<["-"], "mnoexecstack">, HelpText<"Mark the file as not needing an executable stack">; +def split_stacks : Flag<["-"], "split-stacks">, + HelpText<"Try to use a split stack if possible.">; def mno_zero_initialized_in_bss : Flag<["-"], "mno-zero-initialized-in-bss">, HelpText<"Do not put zero initialized data in the BSS">; def backend_option : Separate<["-"], "backend-option">, diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 6aea22f7cd..dd5062c078 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -675,6 +675,7 @@ def fshow_source_location : Flag<["-"], "fshow-source-location">, Group def fspell_checking : Flag<["-"], "fspell-checking">, Group; def fsigned_bitfields : Flag<["-"], "fsigned-bitfields">, Group; def fsigned_char : Flag<["-"], "fsigned-char">, Group; +def fsplit_stack : Flag<["-"], "fsplit-stack">, Group; def fstack_protector_all : Flag<["-"], "fstack-protector-all">, Group; def fstack_protector : Flag<["-"], "fstack-protector">, Group; def fstrict_aliasing : Flag<["-"], "fstrict-aliasing">, Group; diff --git a/include/clang/Frontend/CodeGenOptions.def b/include/clang/Frontend/CodeGenOptions.def index 92df6bb871..4b6754d5dc 100644 --- a/include/clang/Frontend/CodeGenOptions.def +++ b/include/clang/Frontend/CodeGenOptions.def @@ -70,6 +70,7 @@ CODEGENOPT(NoDwarf2CFIAsm , 1, 0) ///< Set when -fno-dwarf2-cfi-asm is enable CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is ///< enabled. CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled. +CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is enabled. CODEGENOPT(NoGlobalMerge , 1, 0) ///< Set when -mno-global-merge is enabled. CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enabled. CODEGENOPT(NoInfsFPMath , 1, 0) ///< Assume FP arguments, results not +-Inf. diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 019570ce23..45079c0989 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -457,6 +457,7 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { Options.TrapFuncName = CodeGenOpts.TrapFuncName; Options.PositionIndependentExecutable = LangOpts.PIELevel != 0; Options.SSPBufferSize = CodeGenOpts.SSPBufferSize; + Options.EnableSegmentedStacks = CodeGenOpts.EnableSegmentedStacks; TargetMachine *TM = TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr, Options, diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 5ddb95c022..83c140d2b3 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2112,6 +2112,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, options::OPT_fno_optimize_sibling_calls)) CmdArgs.push_back("-mdisable-tail-calls"); + // Handle segmented stacks. + if (Args.hasArg(options::OPT_fsplit_stack)) + CmdArgs.push_back("-split-stacks"); + // Handle various floating point optimization flags, mapping them to the // appropriate LLVM code generation flags. The pattern for all of these is to // default off the codegen optimizations, and if any flag enables them and no diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index fbf0349978..611e784814 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -358,6 +358,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.NumRegisterParameters = Args.getLastArgIntValue(OPT_mregparm, 0, Diags); Opts.NoGlobalMerge = Args.hasArg(OPT_mno_global_merge); Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack); + Opts.EnableSegmentedStacks = Args.hasArg(OPT_split_stacks); Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c index 1bd2e140b2..c1431a1f9e 100644 --- a/test/Driver/clang_f_opts.c +++ b/test/Driver/clang_f_opts.c @@ -1,6 +1,7 @@ -// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s +// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s +// CHECK-OPTIONS1: -split-stacks // CHECK-OPTIONS1: -fgnu-keywords // CHECK-OPTIONS1: -fblocks // CHECK-OPTIONS1: -fpascal-strings -- cgit v1.2.3-70-g09d2