Message ID | 5576E293.9030006@mentor.com |
---|---|
State | New |
Headers | show |
On Tue, 9 Jun 2015, Tom de Vries wrote: > On 09/06/15 13:03, Richard Biener wrote: > > On Tue, 9 Jun 2015, Alan Lawrence wrote: > > > > > Hmmm. One side effect of this is that the line number information > > > available in > > > the target hook gimplify_va_arg_expr, is now just the name of the > > > containing > > > function, rather than the specific use of va_arg. Is there some way to get > > > this more precise location (e.g. gimple_location(stmt) in > > > expand_ifn_va_arg_1, > > > the only caller of said hook)? I don't really want to have to add an extra > > > parameter to the target hook... > > > > The x86 variant doesn't use any locations but if then the caller of > > the target hook (expand_ifn_va_arg_1) should assign the IFNs location > > to all statements expanded from it (it could set input_location to > > that during the target hook call...) > > > > That seems to work. > > The scan-assembler-not test in the testcase in attached patch: > - fails without the expand_ifn_va_arg_1 patch hunk, and > - passes with that hunk. > > I'll put it through bootstrap and reg-test on x86_64. > > OK for trunk if that goes well? Ok. Thanks, Richard. > Thanks, > - Tom >
Tom de Vries wrote: > On 09/06/15 13:03, Richard Biener wrote: >> On Tue, 9 Jun 2015, Alan Lawrence wrote: >> >>> Hmmm. One side effect of this is that the line number information available in >>> the target hook gimplify_va_arg_expr, is now just the name of the containing >>> function, rather than the specific use of va_arg. Is there some way to get >>> this more precise location (e.g. gimple_location(stmt) in expand_ifn_va_arg_1, >>> the only caller of said hook)? I don't really want to have to add an extra >>> parameter to the target hook... >> The x86 variant doesn't use any locations but if then the caller of >> the target hook (expand_ifn_va_arg_1) should assign the IFNs location >> to all statements expanded from it (it could set input_location to >> that during the target hook call...) >> > > That seems to work. > > The scan-assembler-not test in the testcase in attached patch: > - fails without the expand_ifn_va_arg_1 patch hunk, and > - passes with that hunk. > > I'll put it through bootstrap and reg-test on x86_64. > > OK for trunk if that goes well? > > Thanks, > - Tom That fixes the issue for me (I'm working with on a patch which uses the line info in error output) - thank you very much! Cheers, Alan
Handle location in expand_ifn_va_arg_1 2015-06-09 Tom de Vries <tom@codesourcery.com> * tree-stdarg.c (expand_ifn_va_arg_1): Handle location. * gcc.target/i386/vararg-loc.c: New test. --- gcc/testsuite/gcc.target/i386/vararg-loc.c | 27 +++++++++++++++++++++++++++ gcc/tree-stdarg.c | 4 ++++ 2 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/vararg-loc.c diff --git a/gcc/testsuite/gcc.target/i386/vararg-loc.c b/gcc/testsuite/gcc.target/i386/vararg-loc.c new file mode 100644 index 0000000..f236fe3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/vararg-loc.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-g -O0" } */ + +#include <stdarg.h> + +int /* 6. */ + /* 7. */ +f (int a, ...) /* 8. */ + /* 9. */ +{ + + int sum = a; + + va_list ap; + + va_start (ap, a); + + sum += va_arg (ap, int); /* 18. */ + + sum += va_arg (ap, int); /* 20. */ + + return sum; +} + +/* { dg-final { scan-assembler-not "\\.loc 1 \[6789\] 0" } } */ +/* { dg-final { scan-assembler-times "\\.loc 1 18 0" 1 } } */ +/* { dg-final { scan-assembler-times "\\.loc 1 20 0" 1 } } */ diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c index 08d10b5..65fe9f9 100644 --- a/gcc/tree-stdarg.c +++ b/gcc/tree-stdarg.c @@ -1031,6 +1031,7 @@ expand_ifn_va_arg_1 (function *fun) bool modified = false; basic_block bb; gimple_stmt_iterator i; + location_t saved_location; FOR_EACH_BB_FN (bb, fun) for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i)) @@ -1051,6 +1052,8 @@ expand_ifn_va_arg_1 (function *fun) ap = build_fold_indirect_ref (ap); push_gimplify_context (false); + saved_location = input_location; + input_location = gimple_location (stmt); /* Make it easier for the backends by protecting the valist argument from multiple evaluations. */ @@ -1081,6 +1084,7 @@ expand_ifn_va_arg_1 (function *fun) else gimplify_expr (&expr, &pre, &post, is_gimple_lvalue, fb_lvalue); + input_location = saved_location; pop_gimplify_context (NULL); gimple_seq_add_seq (&pre, post); -- 1.9.1