[PATCH] D40712: Add cc1 flag enabling the function stack size section that was added in r319430

2017-12-08 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

The title says "Add cc1 option..." which to me implies a "cc1 only" option.  
What you're actually doing is adding a driver option.  Please update the title.




Comment at: test/Driver/stack-size-section.c:2
+// RUN: %clang -target x86_64-unknown %s -S -o %t
+// RUN: not grep '.stack_sizes' %t
+// RUN: %clang -target x86_64-unknown -fstack-size-section %s -S -o %t

Driver tests use `-###` to report the command line they'd use to invoke cc1, 
and verify the presence or absence of the option that you expect to see in the 
cc1 command line.  The actual functionality test (presence or absence of 
something in the IR or whatever) should go in some other more appropriate place.
Also, we use FileCheck not grep.


https://reviews.llvm.org/D40712



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40712: Add cc1 flag enabling the function stack size section that was added in r319430

2017-12-08 Thread Matthias Braun via Phabricator via cfe-commits
MatzeB added a comment.

Looks good to me, but I'm not too familiar with the clang driver code. So it 
would be good if you could at least add some more experienced clang developers 
into the reviewer list and wait some more days before committing.

I also wonder whether it would be possible to move the fact that it defaults to 
on for PS4 into the PS4CPU.cpp file somehow (not that things are distributed 
that cleanly right now anyway).


https://reviews.llvm.org/D40712



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40712: Add cc1 flag enabling the function stack size section that was added in r319430

2017-12-08 Thread Sean Eveson via Phabricator via cfe-commits
seaneveson added a comment.

Ping.


https://reviews.llvm.org/D40712



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40712: Add cc1 flag enabling the function stack size section that was added in r319430

2017-12-01 Thread Sean Eveson via Phabricator via cfe-commits
seaneveson created this revision.

Adds the -fstack-size-section flag to enable the .stack_sizes section. The flag 
defaults to on for the PS4 triple.

Follow up change from: https://reviews.llvm.org/D39788

Original RFC: http://lists.llvm.org/pipermail/llvm-dev/2017-August/117028.html


https://reviews.llvm.org/D40712

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/stack-size-section.c


Index: test/Driver/stack-size-section.c
===
--- test/Driver/stack-size-section.c
+++ test/Driver/stack-size-section.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target x86_64-unknown %s -S -o %t
+// RUN: not grep '.stack_sizes' %t
+// RUN: %clang -target x86_64-unknown -fstack-size-section %s -S -o %t
+// RUN: grep '.stack_sizes' %t
+
+// RUN: %clang -target x86_64-scei-ps4 %s -S -o %t
+// RUN: grep '.stack_sizes' %t
+// RUN: %clang -target x86_64-scei-ps4 -fno-stack-size-section %s -S -o %t
+// RUN: not grep '.stack_sizes' %t
+
+int foo() { return 42; }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -681,6 +681,8 @@
OPT_fno_function_sections, false);
   Opts.DataSections = Args.hasFlag(OPT_fdata_sections,
OPT_fno_data_sections, false);
+  Opts.StackSizeSection = Args.hasFlag(
+  OPT_fstack_size_section, OPT_fno_stack_size_section, Triple.isPS4());
   Opts.UniqueSectionNames = Args.hasFlag(OPT_funique_section_names,
  OPT_fno_unique_section_names, true);
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3775,6 +3775,12 @@
 CmdArgs.push_back(A->getValue());
   }
 
+  if (Args.hasFlag(options::OPT_fstack_size_section,
+   options::OPT_fno_stack_size_section, RawTriple.isPS4()))
+CmdArgs.push_back("-fstack-size-section");
+  else
+CmdArgs.push_back("-fno-stack-size-section");
+
   CmdArgs.push_back("-ferror-limit");
   if (Arg *A = Args.getLastArg(options::OPT_ferror_limit_EQ))
 CmdArgs.push_back(A->getValue());
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -439,6 +439,7 @@
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
+  Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
 
   if (CodeGenOpts.EnableSplitDwarf)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -83,6 +83,7 @@
 
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
+CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
 
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1564,6 +1564,10 @@
  Flags<[CC1Option]>, HelpText<"Place each data in its own section (ELF Only)">;
 def fno_data_sections : Flag <["-"], "fno-data-sections">, Group,
   Flags<[CC1Option]>;
+def fstack_size_section : Flag<["-"], "fstack-size-section">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Emit section containing metadata on function stack sizes">;
+def fno_stack_size_section : Flag<["-"], "fno-stack-size-section">, 
Group, Flags<[CC1Option]>,
+  HelpText<"Don't emit section containing metadata on function stack sizes">;
 
 def funique_section_names : Flag <["-"], "funique-section-names">,
   Group, Flags<[CC1Option]>,


Index: test/Driver/stack-size-section.c
===
--- test/Driver/stack-size-section.c
+++ test/Driver/stack-size-section.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target x86_64-unknown %s -S -o %t
+// RUN: not grep '.stack_sizes' %t
+// RUN: %clang -target x86_64-unknown -fstack-size-section %s -S -o %t
+// RUN: grep '.stack_sizes' %t
+
+// RUN: %clang -target x86_64-scei-ps4 %s -S -o %t
+// RUN: grep '.stack_sizes' %t
+// RUN: %clang -target x86_64-scei-ps4 -fno-stack-size-section %s -S -o %t
+// RUN: not grep '.stack_sizes' %t
+
+int foo() { return 42; }
Index: