This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Option flag with string arguments


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]