public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Option flag with string arguments
@ 2019-12-19 21:47 Erick Ochoa
  2019-12-19 22:01 ` Jozef Lawrynowicz
  2019-12-19 22:06 ` David Malcolm
  0 siblings, 2 replies; 4+ messages in thread
From: Erick Ochoa @ 2019-12-19 21:47 UTC (permalink / raw)
  To: GCC Development; +Cc: Christoph Müllner, Dr. Philipp Tomsich

Hello,

I am working on testing an optimization. I am starting to write
tests in the GCC testing suite. However, I want to develop some
fine grain testing for my own sake.

This optimization I am working on, is a variant of struct reordering.
One way I would like to test my pass is for example, making a test case
and guaranteeing that my pass is able to detect global variables of
a specific struct type.

For example, given the following C file

```
/* { dg-lto-options {{-flto -fipa-struct-reorg -fipa-struct-reorg-assert-has-structs=astruct_s}} } */

struct astruct_s { _Bool a; };
struct astruct_s astruct;

int main() { };
```

I would like to create the option flag that has a list of string arguments

-fipa-struct-reorg-assert-has-structs=<string>+

such that during the analysis time, I'd be able to have an assertion
to make sure that my pass has actually collected the types identified by the
strings.
I'm not very familiar on the DSL to specify option flags.
I've looked at gcc/common.opt for some examples and found this one:

```
frandom-seed=
Common Joined RejectNegative Var(common_deferred_options) Defer
-frandom-seed=<string>  Make compile reproducible using <string>.
```

Could anyone explain how to specify my flag? Or possibly
point to some documentation/source that explains Common, Joined, etc...?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Option flag with string arguments
  2019-12-19 21:47 Option flag with string arguments Erick Ochoa
@ 2019-12-19 22:01 ` Jozef Lawrynowicz
  2019-12-19 22:05   ` Erick Ochoa
  2019-12-19 22:06 ` David Malcolm
  1 sibling, 1 reply; 4+ messages in thread
From: Jozef Lawrynowicz @ 2019-12-19 22:01 UTC (permalink / raw)
  To: Erick Ochoa; +Cc: GCC Development, Christoph Müllner, Dr. Philipp Tomsich

On Thu, 19 Dec 2019 16:47:42 -0500
Erick Ochoa <erick.ochoa@theobroma-systems.com> wrote:

> Hello,
> 
> I am working on testing an optimization. I am starting to write
> tests in the GCC testing suite. However, I want to develop some
> fine grain testing for my own sake.
> 
> This optimization I am working on, is a variant of struct reordering.
> One way I would like to test my pass is for example, making a test case
> and guaranteeing that my pass is able to detect global variables of
> a specific struct type.
> 
> For example, given the following C file
> 
> ```
> /* { dg-lto-options {{-flto -fipa-struct-reorg -fipa-struct-reorg-assert-has-structs=astruct_s}} } */
> 
> struct astruct_s { _Bool a; };
> struct astruct_s astruct;
> 
> int main() { };
> ```
> 
> I would like to create the option flag that has a list of string arguments
> 
> -fipa-struct-reorg-assert-has-structs=<string>+
> 
> such that during the analysis time, I'd be able to have an assertion
> to make sure that my pass has actually collected the types identified by the
> strings.
> I'm not very familiar on the DSL to specify option flags.
> I've looked at gcc/common.opt for some examples and found this one:
> 
> ```
> frandom-seed=
> Common Joined RejectNegative Var(common_deferred_options) Defer
> -frandom-seed=<string>  Make compile reproducible using <string>.
> ```
> 
> Could anyone explain how to specify my flag? Or possibly
> point to some documentation/source that explains Common, Joined, etc...?

Have you looked at the GCC Internals Manual (gccint)? The section on option
specification files is online here:
https://gcc.gnu.org/onlinedocs/gccint/Option-properties.html#Option-properties

Jozef

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Option flag with string arguments
  2019-12-19 22:01 ` Jozef Lawrynowicz
@ 2019-12-19 22:05   ` Erick Ochoa
  0 siblings, 0 replies; 4+ messages in thread
From: Erick Ochoa @ 2019-12-19 22:05 UTC (permalink / raw)
  To: Jozef Lawrynowicz
  Cc: GCC Development, Christoph Müllner, Dr. Philipp Tomsich



On 2019-12-19 5:01 p.m., Jozef Lawrynowicz wrote:
> On Thu, 19 Dec 2019 16:47:42 -0500
> Erick Ochoa <erick.ochoa@theobroma-systems.com> wrote:
> 
>> Hello,
>>
>> I am working on testing an optimization. I am starting to write
>> tests in the GCC testing suite. However, I want to develop some
>> fine grain testing for my own sake.
>>
>> This optimization I am working on, is a variant of struct reordering.
>> One way I would like to test my pass is for example, making a test case
>> and guaranteeing that my pass is able to detect global variables of
>> a specific struct type.
>>
>> For example, given the following C file
>>
>> ```
>> /* { dg-lto-options {{-flto -fipa-struct-reorg -fipa-struct-reorg-assert-has-structs=astruct_s}} } */
>>
>> struct astruct_s { _Bool a; };
>> struct astruct_s astruct;
>>
>> int main() { };
>> ```
>>
>> I would like to create the option flag that has a list of string arguments
>>
>> -fipa-struct-reorg-assert-has-structs=<string>+
>>
>> such that during the analysis time, I'd be able to have an assertion
>> to make sure that my pass has actually collected the types identified by the
>> strings.
>> I'm not very familiar on the DSL to specify option flags.
>> I've looked at gcc/common.opt for some examples and found this one:
>>
>> ```
>> frandom-seed=
>> Common Joined RejectNegative Var(common_deferred_options) Defer
>> -frandom-seed=<string>  Make compile reproducible using <string>.
>> ```
>>
>> Could anyone explain how to specify my flag? Or possibly
>> point to some documentation/source that explains Common, Joined, etc...?
> 
> Have you looked at the GCC Internals Manual (gccint)? The section on option
> specification files is online here:
> https://gcc.gnu.org/onlinedocs/gccint/Option-properties.html#Option-properties> 
> Jozef

Thanks Jozef! This is exactly what I was looking for (and overlooked).

> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Option flag with string arguments
  2019-12-19 21:47 Option flag with string arguments Erick Ochoa
  2019-12-19 22:01 ` Jozef Lawrynowicz
@ 2019-12-19 22:06 ` David Malcolm
  1 sibling, 0 replies; 4+ messages in thread
From: David Malcolm @ 2019-12-19 22:06 UTC (permalink / raw)
  To: Erick Ochoa, GCC Development; +Cc: Christoph Müllner, Dr. Philipp Tomsich

On Thu, 2019-12-19 at 16:47 -0500, Erick Ochoa wrote:
> Hello,
> 
> I am working on testing an optimization. I am starting to write
> tests in the GCC testing suite. However, I want to develop some
> fine grain testing for my own sake.
> 
> This optimization I am working on, is a variant of struct reordering.
> One way I would like to test my pass is for example, making a test
> case
> and guaranteeing that my pass is able to detect global variables of
> a specific struct type.

For example, given the following C file
> 
> ```
> /* { dg-lto-options {{-flto -fipa-struct-reorg -fipa-struct-reorg-
> assert-has-structs=astruct_s}} } */
> 
> struct astruct_s { _Bool a; };
> struct astruct_s astruct;
> 
> int main() { };
> ```
> 
> I would like to create the option flag that has a list of string
> arguments
> 
> -fipa-struct-reorg-assert-has-structs=<string>+
> 
> such that during the analysis time, I'd be able to have an assertion
> to make sure that my pass has actually collected the types identified
> by the
> strings.
> I'm not very familiar on the DSL to specify option flags.
> I've looked at gcc/common.opt for some examples and found this one:
> 
> ```
> frandom-seed=
> Common Joined RejectNegative Var(common_deferred_options) Defer
> -frandom-seed=<string>  Make compile reproducible using <string>.
> ```
> 
> Could anyone explain how to specify my flag? Or possibly
> point to some documentation/source that explains Common, Joined,
> etc...?


It sounds like what you really want is a DejaGnu option to detect that
a specific struct type was handled by your pass, rather than a command-
line option for controlling that pass.

I think you want something like:

/* { dg-options "-fdump-ipa-your-pass" } */
/* { dg-lto-options {{-flto -fipa-struct-reorg }} } */

(not sure of the precise interaction of these two though)

and:

/* { dg-final { scan-ipa-dump "handling type: 'struct_s'"  "your-pass" } } */

then arranging for the dumpfile for your-pass to contain the message:
dg-final queues up a scan of the given dumpfile which will PASS/FAIL
based on whether it sees the message.

Try grepping the testsuite for dg-final to see more examples of the
idea.


Hope this is helpful
Dave


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-19 22:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-19 21:47 Option flag with string arguments Erick Ochoa
2019-12-19 22:01 ` Jozef Lawrynowicz
2019-12-19 22:05   ` Erick Ochoa
2019-12-19 22:06 ` David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).