Re: r324498 - [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-12 Thread David Blaikie via cfe-commits
Ah.. hrm :/

On Mon, Feb 12, 2018 at 6:03 PM Eric Fiselier  wrote:

> On Mon, Feb 12, 2018 at 4:01 PM, David Blaikie  wrote:
>
>> ah, sweet :)
>>
>> On Mon, Feb 12, 2018 at 2:59 PM Eric Fiselier  wrote:
>>
>>> On Mon, Feb 12, 2018 at 3:35 PM, David Blaikie 
>>> wrote:
>>>


 On Mon, Feb 12, 2018 at 2:25 PM Eric Fiselier  wrote:

> On Mon, Feb 12, 2018 at 9:15 AM, David Blaikie 
> wrote:
>
>>
>>
>> On Wed, Feb 7, 2018 at 10:38 AM Eric Fiselier via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ericwf
>>> Date: Wed Feb  7 10:36:51 2018
>>> New Revision: 324498
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=324498=rev
>>> Log:
>>> [Driver] Add option to manually control discarding value names in
>>> LLVM IR.
>>>
>>> Summary:
>>> Currently, assertion-disabled Clang builds emit value names when
>>> generating LLVM IR. This is controlled by the `NDEBUG` macro, and is not
>>> easily overridable. In order to get IR output containing names from a
>>> release build of Clang, the user must manually construct the CC1 
>>> invocation
>>> w/o the `-discard-value-names` option. This is less than ideal.
>>>
>>> For example, Godbolt uses a release build of Clang, and so when
>>> asked to emit LLVM IR the result lacks names, making it harder to read.
>>> Manually invoking CC1 on Compiler Explorer is not feasible.
>>>
>>
>> It wouldn't necessarily have to invoke CC1, it could use "-Xclang
>> -discard-value-names".
>>
>
> If you were using an assertion build, and wanted to disable value
> names, then yes -- that would work. However it's the opposite case that is
> of interest:
> When you're using a non-assertion build and want to keep value names.
> In that case invoking CC1 directly is required; otherwise the driver would
> pass
> "-discard-value-names".
>

 Ah, thanks for explaining!


>
>
>>
>>
>>>
>>> This patch adds the driver options `-fdiscard-value-names` and
>>> `-fno-discard-value-names` which allow the user to override the default
>>> behavior. If neither is specified, the old behavior remains.
>>>
>>> Reviewers: erichkeane, aaron.ballman, lebedev.ri
>>>
>>> Reviewed By: aaron.ballman
>>>
>>> Subscribers: bogner, cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D42887
>>>
>>> Modified:
>>> cfe/trunk/docs/UsersManual.rst
>>> cfe/trunk/include/clang/Driver/Options.td
>>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>>> cfe/trunk/test/Driver/clang_f_opts.c
>>>
>>> Modified: cfe/trunk/docs/UsersManual.rst
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=324498=324497=324498=diff
>>>
>>> ==
>>> --- cfe/trunk/docs/UsersManual.rst (original)
>>> +++ cfe/trunk/docs/UsersManual.rst Wed Feb  7 10:36:51 2018
>>> @@ -1855,6 +1855,27 @@ features. You can "tune" the debug info
>>>must come first.)
>>>
>>>
>>> +Controlling LLVM IR Output
>>> +--
>>> +
>>> +Controlling Value Names in LLVM IR
>>> +^^
>>> +
>>> +Emitting value names in LLVM IR increases the size and verbosity of
>>> the IR.
>>> +By default, value names are only emitted in assertion-enabled
>>> builds of Clang.
>>> +However, when reading IR it can be useful to re-enable the emission
>>> of value
>>> +names to improve readability.
>>> +
>>> +.. option:: -fdiscard-value-names
>>> +
>>> +  Discard value names when generating LLVM IR.
>>> +
>>> +.. option:: -fno-discard-value-names
>>> +
>>> +  Do not discard value names when generating LLVM IR. This option
>>> can be used
>>> +  to re-enable names for release builds of Clang.
>>> +
>>> +
>>>  Comment Parsing Options
>>>  ---
>>>
>>>
>>> Modified: cfe/trunk/include/clang/Driver/Options.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=324498=324497=324498=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>>> +++ cfe/trunk/include/clang/Driver/Options.td Wed Feb  7 10:36:51
>>> 2018
>>> @@ -790,6 +790,10 @@ def fdiagnostics_show_template_tree : Fl
>>>  HelpText<"Print a template comparison tree for differing
>>> templates">;
>>>  def fdeclspec : Flag<["-"], "fdeclspec">, Group,
>>>HelpText<"Allow __declspec as a keyword">, 

Re: r324498 - [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-12 Thread Eric Fiselier via cfe-commits
On Mon, Feb 12, 2018 at 4:01 PM, David Blaikie  wrote:

> ah, sweet :)
>
> On Mon, Feb 12, 2018 at 2:59 PM Eric Fiselier  wrote:
>
>> On Mon, Feb 12, 2018 at 3:35 PM, David Blaikie 
>> wrote:
>>
>>>
>>>
>>> On Mon, Feb 12, 2018 at 2:25 PM Eric Fiselier  wrote:
>>>
 On Mon, Feb 12, 2018 at 9:15 AM, David Blaikie 
 wrote:

>
>
> On Wed, Feb 7, 2018 at 10:38 AM Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ericwf
>> Date: Wed Feb  7 10:36:51 2018
>> New Revision: 324498
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=324498=rev
>> Log:
>> [Driver] Add option to manually control discarding value names in
>> LLVM IR.
>>
>> Summary:
>> Currently, assertion-disabled Clang builds emit value names when
>> generating LLVM IR. This is controlled by the `NDEBUG` macro, and is not
>> easily overridable. In order to get IR output containing names from a
>> release build of Clang, the user must manually construct the CC1 
>> invocation
>> w/o the `-discard-value-names` option. This is less than ideal.
>>
>> For example, Godbolt uses a release build of Clang, and so when asked
>> to emit LLVM IR the result lacks names, making it harder to read. 
>> Manually
>> invoking CC1 on Compiler Explorer is not feasible.
>>
>
> It wouldn't necessarily have to invoke CC1, it could use "-Xclang
> -discard-value-names".
>

 If you were using an assertion build, and wanted to disable value
 names, then yes -- that would work. However it's the opposite case that is
 of interest:
 When you're using a non-assertion build and want to keep value names.
 In that case invoking CC1 directly is required; otherwise the driver would
 pass
 "-discard-value-names".

>>>
>>> Ah, thanks for explaining!
>>>
>>>


>
>
>>
>> This patch adds the driver options `-fdiscard-value-names` and
>> `-fno-discard-value-names` which allow the user to override the default
>> behavior. If neither is specified, the old behavior remains.
>>
>> Reviewers: erichkeane, aaron.ballman, lebedev.ri
>>
>> Reviewed By: aaron.ballman
>>
>> Subscribers: bogner, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D42887
>>
>> Modified:
>> cfe/trunk/docs/UsersManual.rst
>> cfe/trunk/include/clang/Driver/Options.td
>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> cfe/trunk/test/Driver/clang_f_opts.c
>>
>> Modified: cfe/trunk/docs/UsersManual.rst
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
>> UsersManual.rst?rev=324498=324497=324498=diff
>> 
>> ==
>> --- cfe/trunk/docs/UsersManual.rst (original)
>> +++ cfe/trunk/docs/UsersManual.rst Wed Feb  7 10:36:51 2018
>> @@ -1855,6 +1855,27 @@ features. You can "tune" the debug info
>>must come first.)
>>
>>
>> +Controlling LLVM IR Output
>> +--
>> +
>> +Controlling Value Names in LLVM IR
>> +^^
>> +
>> +Emitting value names in LLVM IR increases the size and verbosity of
>> the IR.
>> +By default, value names are only emitted in assertion-enabled builds
>> of Clang.
>> +However, when reading IR it can be useful to re-enable the emission
>> of value
>> +names to improve readability.
>> +
>> +.. option:: -fdiscard-value-names
>> +
>> +  Discard value names when generating LLVM IR.
>> +
>> +.. option:: -fno-discard-value-names
>> +
>> +  Do not discard value names when generating LLVM IR. This option
>> can be used
>> +  to re-enable names for release builds of Clang.
>> +
>> +
>>  Comment Parsing Options
>>  ---
>>
>>
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
>> clang/Driver/Options.td?rev=324498=324497=324498=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Wed Feb  7 10:36:51
>> 2018
>> @@ -790,6 +790,10 @@ def fdiagnostics_show_template_tree : Fl
>>  HelpText<"Print a template comparison tree for differing
>> templates">;
>>  def fdeclspec : Flag<["-"], "fdeclspec">, Group,
>>HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
>> +def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">,
>> Group,
>> +  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
>> +def 

Re: r324498 - [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-12 Thread David Blaikie via cfe-commits
ah, sweet :)

On Mon, Feb 12, 2018 at 2:59 PM Eric Fiselier  wrote:

> On Mon, Feb 12, 2018 at 3:35 PM, David Blaikie  wrote:
>
>>
>>
>> On Mon, Feb 12, 2018 at 2:25 PM Eric Fiselier  wrote:
>>
>>> On Mon, Feb 12, 2018 at 9:15 AM, David Blaikie 
>>> wrote:
>>>


 On Wed, Feb 7, 2018 at 10:38 AM Eric Fiselier via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Wed Feb  7 10:36:51 2018
> New Revision: 324498
>
> URL: http://llvm.org/viewvc/llvm-project?rev=324498=rev
> Log:
> [Driver] Add option to manually control discarding value names in LLVM
> IR.
>
> Summary:
> Currently, assertion-disabled Clang builds emit value names when
> generating LLVM IR. This is controlled by the `NDEBUG` macro, and is not
> easily overridable. In order to get IR output containing names from a
> release build of Clang, the user must manually construct the CC1 
> invocation
> w/o the `-discard-value-names` option. This is less than ideal.
>
> For example, Godbolt uses a release build of Clang, and so when asked
> to emit LLVM IR the result lacks names, making it harder to read. Manually
> invoking CC1 on Compiler Explorer is not feasible.
>

 It wouldn't necessarily have to invoke CC1, it could use "-Xclang
 -discard-value-names".

>>>
>>> If you were using an assertion build, and wanted to disable value names,
>>> then yes -- that would work. However it's the opposite case that is of
>>> interest:
>>> When you're using a non-assertion build and want to keep value names. In
>>> that case invoking CC1 directly is required; otherwise the driver would pass
>>> "-discard-value-names".
>>>
>>
>> Ah, thanks for explaining!
>>
>>
>>>
>>>


>
> This patch adds the driver options `-fdiscard-value-names` and
> `-fno-discard-value-names` which allow the user to override the default
> behavior. If neither is specified, the old behavior remains.
>
> Reviewers: erichkeane, aaron.ballman, lebedev.ri
>
> Reviewed By: aaron.ballman
>
> Subscribers: bogner, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D42887
>
> Modified:
> cfe/trunk/docs/UsersManual.rst
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/test/Driver/clang_f_opts.c
>
> Modified: cfe/trunk/docs/UsersManual.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=324498=324497=324498=diff
>
> ==
> --- cfe/trunk/docs/UsersManual.rst (original)
> +++ cfe/trunk/docs/UsersManual.rst Wed Feb  7 10:36:51 2018
> @@ -1855,6 +1855,27 @@ features. You can "tune" the debug info
>must come first.)
>
>
> +Controlling LLVM IR Output
> +--
> +
> +Controlling Value Names in LLVM IR
> +^^
> +
> +Emitting value names in LLVM IR increases the size and verbosity of
> the IR.
> +By default, value names are only emitted in assertion-enabled builds
> of Clang.
> +However, when reading IR it can be useful to re-enable the emission
> of value
> +names to improve readability.
> +
> +.. option:: -fdiscard-value-names
> +
> +  Discard value names when generating LLVM IR.
> +
> +.. option:: -fno-discard-value-names
> +
> +  Do not discard value names when generating LLVM IR. This option can
> be used
> +  to re-enable names for release builds of Clang.
> +
> +
>  Comment Parsing Options
>  ---
>
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=324498=324497=324498=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed Feb  7 10:36:51 2018
> @@ -790,6 +790,10 @@ def fdiagnostics_show_template_tree : Fl
>  HelpText<"Print a template comparison tree for differing
> templates">;
>  def fdeclspec : Flag<["-"], "fdeclspec">, Group,
>HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
> +def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">,
> Group,
> +  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
> +def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">,
> Group,
> +  HelpText<"Do not discard value names in LLVM IR">,
> Flags<[DriverOption]>;
>  def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">,
> 

Re: r324498 - [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-12 Thread Eric Fiselier via cfe-commits
On Mon, Feb 12, 2018 at 3:35 PM, David Blaikie  wrote:

>
>
> On Mon, Feb 12, 2018 at 2:25 PM Eric Fiselier  wrote:
>
>> On Mon, Feb 12, 2018 at 9:15 AM, David Blaikie 
>> wrote:
>>
>>>
>>>
>>> On Wed, Feb 7, 2018 at 10:38 AM Eric Fiselier via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: ericwf
 Date: Wed Feb  7 10:36:51 2018
 New Revision: 324498

 URL: http://llvm.org/viewvc/llvm-project?rev=324498=rev
 Log:
 [Driver] Add option to manually control discarding value names in LLVM
 IR.

 Summary:
 Currently, assertion-disabled Clang builds emit value names when
 generating LLVM IR. This is controlled by the `NDEBUG` macro, and is not
 easily overridable. In order to get IR output containing names from a
 release build of Clang, the user must manually construct the CC1 invocation
 w/o the `-discard-value-names` option. This is less than ideal.

 For example, Godbolt uses a release build of Clang, and so when asked
 to emit LLVM IR the result lacks names, making it harder to read. Manually
 invoking CC1 on Compiler Explorer is not feasible.

>>>
>>> It wouldn't necessarily have to invoke CC1, it could use "-Xclang
>>> -discard-value-names".
>>>
>>
>> If you were using an assertion build, and wanted to disable value names,
>> then yes -- that would work. However it's the opposite case that is of
>> interest:
>> When you're using a non-assertion build and want to keep value names. In
>> that case invoking CC1 directly is required; otherwise the driver would pass
>> "-discard-value-names".
>>
>
> Ah, thanks for explaining!
>
>
>>
>>
>>>
>>>

 This patch adds the driver options `-fdiscard-value-names` and
 `-fno-discard-value-names` which allow the user to override the default
 behavior. If neither is specified, the old behavior remains.

 Reviewers: erichkeane, aaron.ballman, lebedev.ri

 Reviewed By: aaron.ballman

 Subscribers: bogner, cfe-commits

 Differential Revision: https://reviews.llvm.org/D42887

 Modified:
 cfe/trunk/docs/UsersManual.rst
 cfe/trunk/include/clang/Driver/Options.td
 cfe/trunk/lib/Driver/ToolChains/Clang.cpp
 cfe/trunk/test/Driver/clang_f_opts.c

 Modified: cfe/trunk/docs/UsersManual.rst
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
 UsersManual.rst?rev=324498=324497=324498=diff
 
 ==
 --- cfe/trunk/docs/UsersManual.rst (original)
 +++ cfe/trunk/docs/UsersManual.rst Wed Feb  7 10:36:51 2018
 @@ -1855,6 +1855,27 @@ features. You can "tune" the debug info
must come first.)


 +Controlling LLVM IR Output
 +--
 +
 +Controlling Value Names in LLVM IR
 +^^
 +
 +Emitting value names in LLVM IR increases the size and verbosity of
 the IR.
 +By default, value names are only emitted in assertion-enabled builds
 of Clang.
 +However, when reading IR it can be useful to re-enable the emission of
 value
 +names to improve readability.
 +
 +.. option:: -fdiscard-value-names
 +
 +  Discard value names when generating LLVM IR.
 +
 +.. option:: -fno-discard-value-names
 +
 +  Do not discard value names when generating LLVM IR. This option can
 be used
 +  to re-enable names for release builds of Clang.
 +
 +
  Comment Parsing Options
  ---


 Modified: cfe/trunk/include/clang/Driver/Options.td
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
 clang/Driver/Options.td?rev=324498=324497=324498=diff
 
 ==
 --- cfe/trunk/include/clang/Driver/Options.td (original)
 +++ cfe/trunk/include/clang/Driver/Options.td Wed Feb  7 10:36:51 2018
 @@ -790,6 +790,10 @@ def fdiagnostics_show_template_tree : Fl
  HelpText<"Print a template comparison tree for differing
 templates">;
  def fdeclspec : Flag<["-"], "fdeclspec">, Group,
HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
 +def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">,
 Group,
 +  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
 +def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">,
 Group,
 +  HelpText<"Do not discard value names in LLVM IR">,
 Flags<[DriverOption]>;
  def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">,
 Group,
HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
  def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">,
 Group;

 Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
 URL: 

Re: r324498 - [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-12 Thread David Blaikie via cfe-commits
On Mon, Feb 12, 2018 at 2:25 PM Eric Fiselier  wrote:

> On Mon, Feb 12, 2018 at 9:15 AM, David Blaikie  wrote:
>
>>
>>
>> On Wed, Feb 7, 2018 at 10:38 AM Eric Fiselier via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ericwf
>>> Date: Wed Feb  7 10:36:51 2018
>>> New Revision: 324498
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=324498=rev
>>> Log:
>>> [Driver] Add option to manually control discarding value names in LLVM
>>> IR.
>>>
>>> Summary:
>>> Currently, assertion-disabled Clang builds emit value names when
>>> generating LLVM IR. This is controlled by the `NDEBUG` macro, and is not
>>> easily overridable. In order to get IR output containing names from a
>>> release build of Clang, the user must manually construct the CC1 invocation
>>> w/o the `-discard-value-names` option. This is less than ideal.
>>>
>>> For example, Godbolt uses a release build of Clang, and so when asked to
>>> emit LLVM IR the result lacks names, making it harder to read. Manually
>>> invoking CC1 on Compiler Explorer is not feasible.
>>>
>>
>> It wouldn't necessarily have to invoke CC1, it could use "-Xclang
>> -discard-value-names".
>>
>
> If you were using an assertion build, and wanted to disable value names,
> then yes -- that would work. However it's the opposite case that is of
> interest:
> When you're using a non-assertion build and want to keep value names. In
> that case invoking CC1 directly is required; otherwise the driver would pass
> "-discard-value-names".
>

Ah, thanks for explaining!


>
>
>>
>>
>>>
>>> This patch adds the driver options `-fdiscard-value-names` and
>>> `-fno-discard-value-names` which allow the user to override the default
>>> behavior. If neither is specified, the old behavior remains.
>>>
>>> Reviewers: erichkeane, aaron.ballman, lebedev.ri
>>>
>>> Reviewed By: aaron.ballman
>>>
>>> Subscribers: bogner, cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D42887
>>>
>>> Modified:
>>> cfe/trunk/docs/UsersManual.rst
>>> cfe/trunk/include/clang/Driver/Options.td
>>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>>> cfe/trunk/test/Driver/clang_f_opts.c
>>>
>>> Modified: cfe/trunk/docs/UsersManual.rst
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=324498=324497=324498=diff
>>>
>>> ==
>>> --- cfe/trunk/docs/UsersManual.rst (original)
>>> +++ cfe/trunk/docs/UsersManual.rst Wed Feb  7 10:36:51 2018
>>> @@ -1855,6 +1855,27 @@ features. You can "tune" the debug info
>>>must come first.)
>>>
>>>
>>> +Controlling LLVM IR Output
>>> +--
>>> +
>>> +Controlling Value Names in LLVM IR
>>> +^^
>>> +
>>> +Emitting value names in LLVM IR increases the size and verbosity of the
>>> IR.
>>> +By default, value names are only emitted in assertion-enabled builds of
>>> Clang.
>>> +However, when reading IR it can be useful to re-enable the emission of
>>> value
>>> +names to improve readability.
>>> +
>>> +.. option:: -fdiscard-value-names
>>> +
>>> +  Discard value names when generating LLVM IR.
>>> +
>>> +.. option:: -fno-discard-value-names
>>> +
>>> +  Do not discard value names when generating LLVM IR. This option can
>>> be used
>>> +  to re-enable names for release builds of Clang.
>>> +
>>> +
>>>  Comment Parsing Options
>>>  ---
>>>
>>>
>>> Modified: cfe/trunk/include/clang/Driver/Options.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=324498=324497=324498=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>>> +++ cfe/trunk/include/clang/Driver/Options.td Wed Feb  7 10:36:51 2018
>>> @@ -790,6 +790,10 @@ def fdiagnostics_show_template_tree : Fl
>>>  HelpText<"Print a template comparison tree for differing
>>> templates">;
>>>  def fdeclspec : Flag<["-"], "fdeclspec">, Group,
>>>HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
>>> +def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">,
>>> Group,
>>> +  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
>>> +def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">,
>>> Group,
>>> +  HelpText<"Do not discard value names in LLVM IR">,
>>> Flags<[DriverOption]>;
>>>  def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">,
>>> Group,
>>>HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
>>>  def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">,
>>> Group;
>>>
>>> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=324498=324497=324498=diff
>>>
>>> ==
>>> --- 

Re: r324498 - [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-12 Thread Eric Fiselier via cfe-commits
On Mon, Feb 12, 2018 at 9:15 AM, David Blaikie  wrote:

>
>
> On Wed, Feb 7, 2018 at 10:38 AM Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ericwf
>> Date: Wed Feb  7 10:36:51 2018
>> New Revision: 324498
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=324498=rev
>> Log:
>> [Driver] Add option to manually control discarding value names in LLVM IR.
>>
>> Summary:
>> Currently, assertion-disabled Clang builds emit value names when
>> generating LLVM IR. This is controlled by the `NDEBUG` macro, and is not
>> easily overridable. In order to get IR output containing names from a
>> release build of Clang, the user must manually construct the CC1 invocation
>> w/o the `-discard-value-names` option. This is less than ideal.
>>
>> For example, Godbolt uses a release build of Clang, and so when asked to
>> emit LLVM IR the result lacks names, making it harder to read. Manually
>> invoking CC1 on Compiler Explorer is not feasible.
>>
>
> It wouldn't necessarily have to invoke CC1, it could use "-Xclang
> -discard-value-names".
>

If you were using an assertion build, and wanted to disable value names,
then yes -- that would work. However it's the opposite case that is of
interest:
When you're using a non-assertion build and want to keep value names. In
that case invoking CC1 directly is required; otherwise the driver would pass
"-discard-value-names".


>
>
>>
>> This patch adds the driver options `-fdiscard-value-names` and
>> `-fno-discard-value-names` which allow the user to override the default
>> behavior. If neither is specified, the old behavior remains.
>>
>> Reviewers: erichkeane, aaron.ballman, lebedev.ri
>>
>> Reviewed By: aaron.ballman
>>
>> Subscribers: bogner, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D42887
>>
>> Modified:
>> cfe/trunk/docs/UsersManual.rst
>> cfe/trunk/include/clang/Driver/Options.td
>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> cfe/trunk/test/Driver/clang_f_opts.c
>>
>> Modified: cfe/trunk/docs/UsersManual.rst
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
>> UsersManual.rst?rev=324498=324497=324498=diff
>> 
>> ==
>> --- cfe/trunk/docs/UsersManual.rst (original)
>> +++ cfe/trunk/docs/UsersManual.rst Wed Feb  7 10:36:51 2018
>> @@ -1855,6 +1855,27 @@ features. You can "tune" the debug info
>>must come first.)
>>
>>
>> +Controlling LLVM IR Output
>> +--
>> +
>> +Controlling Value Names in LLVM IR
>> +^^
>> +
>> +Emitting value names in LLVM IR increases the size and verbosity of the
>> IR.
>> +By default, value names are only emitted in assertion-enabled builds of
>> Clang.
>> +However, when reading IR it can be useful to re-enable the emission of
>> value
>> +names to improve readability.
>> +
>> +.. option:: -fdiscard-value-names
>> +
>> +  Discard value names when generating LLVM IR.
>> +
>> +.. option:: -fno-discard-value-names
>> +
>> +  Do not discard value names when generating LLVM IR. This option can be
>> used
>> +  to re-enable names for release builds of Clang.
>> +
>> +
>>  Comment Parsing Options
>>  ---
>>
>>
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
>> clang/Driver/Options.td?rev=324498=324497=324498=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Wed Feb  7 10:36:51 2018
>> @@ -790,6 +790,10 @@ def fdiagnostics_show_template_tree : Fl
>>  HelpText<"Print a template comparison tree for differing templates">;
>>  def fdeclspec : Flag<["-"], "fdeclspec">, Group,
>>HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
>> +def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">,
>> Group,
>> +  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
>> +def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">,
>> Group,
>> +  HelpText<"Do not discard value names in LLVM IR">,
>> Flags<[DriverOption]>;
>>  def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">,
>> Group,
>>HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
>>  def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">,
>> Group;
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
>> ToolChains/Clang.cpp?rev=324498=324497=324498=diff
>> 
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Feb  7 10:36:51 2018
>> @@ -3266,13 +3266,24 @@ void Clang::ConstructJob(Compilation ,
>>if (!C.isForDiagnostics())
>>  

Re: r324498 - [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-12 Thread David Blaikie via cfe-commits
On Wed, Feb 7, 2018 at 10:38 AM Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Wed Feb  7 10:36:51 2018
> New Revision: 324498
>
> URL: http://llvm.org/viewvc/llvm-project?rev=324498=rev
> Log:
> [Driver] Add option to manually control discarding value names in LLVM IR.
>
> Summary:
> Currently, assertion-disabled Clang builds emit value names when
> generating LLVM IR. This is controlled by the `NDEBUG` macro, and is not
> easily overridable. In order to get IR output containing names from a
> release build of Clang, the user must manually construct the CC1 invocation
> w/o the `-discard-value-names` option. This is less than ideal.
>
> For example, Godbolt uses a release build of Clang, and so when asked to
> emit LLVM IR the result lacks names, making it harder to read. Manually
> invoking CC1 on Compiler Explorer is not feasible.
>

It wouldn't necessarily have to invoke CC1, it could use "-Xclang
-discard-value-names".


>
> This patch adds the driver options `-fdiscard-value-names` and
> `-fno-discard-value-names` which allow the user to override the default
> behavior. If neither is specified, the old behavior remains.
>
> Reviewers: erichkeane, aaron.ballman, lebedev.ri
>
> Reviewed By: aaron.ballman
>
> Subscribers: bogner, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D42887
>
> Modified:
> cfe/trunk/docs/UsersManual.rst
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/test/Driver/clang_f_opts.c
>
> Modified: cfe/trunk/docs/UsersManual.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=324498=324497=324498=diff
>
> ==
> --- cfe/trunk/docs/UsersManual.rst (original)
> +++ cfe/trunk/docs/UsersManual.rst Wed Feb  7 10:36:51 2018
> @@ -1855,6 +1855,27 @@ features. You can "tune" the debug info
>must come first.)
>
>
> +Controlling LLVM IR Output
> +--
> +
> +Controlling Value Names in LLVM IR
> +^^
> +
> +Emitting value names in LLVM IR increases the size and verbosity of the
> IR.
> +By default, value names are only emitted in assertion-enabled builds of
> Clang.
> +However, when reading IR it can be useful to re-enable the emission of
> value
> +names to improve readability.
> +
> +.. option:: -fdiscard-value-names
> +
> +  Discard value names when generating LLVM IR.
> +
> +.. option:: -fno-discard-value-names
> +
> +  Do not discard value names when generating LLVM IR. This option can be
> used
> +  to re-enable names for release builds of Clang.
> +
> +
>  Comment Parsing Options
>  ---
>
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=324498=324497=324498=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed Feb  7 10:36:51 2018
> @@ -790,6 +790,10 @@ def fdiagnostics_show_template_tree : Fl
>  HelpText<"Print a template comparison tree for differing templates">;
>  def fdeclspec : Flag<["-"], "fdeclspec">, Group,
>HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
> +def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">,
> Group,
> +  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
> +def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">,
> Group,
> +  HelpText<"Do not discard value names in LLVM IR">,
> Flags<[DriverOption]>;
>  def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">,
> Group,
>HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
>  def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">,
> Group;
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=324498=324497=324498=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Feb  7 10:36:51 2018
> @@ -3266,13 +3266,24 @@ void Clang::ConstructJob(Compilation ,
>if (!C.isForDiagnostics())
>  CmdArgs.push_back("-disable-free");
>
> -// Disable the verification pass in -asserts builds.
>  #ifdef NDEBUG
> -  CmdArgs.push_back("-disable-llvm-verifier");
> -  // Discard LLVM value names in -asserts builds.
> -  CmdArgs.push_back("-discard-value-names");
> +  const bool IsAssertBuild = false;
> +#else
> +  const bool IsAssertBuild = true;
>  #endif
>
> +  // Disable the verification pass in -asserts builds.
> +  if (!IsAssertBuild)
> +CmdArgs.push_back("disable-llvm-verifier");
> +
> +  // Discard value names in assert builds unless otherwise specified.
>