Handle a location with NULL as a file (PR driver/90495)

Message ID c1817b1b-c329-1e52-c458-e03300fb7377@suse.cz
State New
Headers show
Series
  • Handle a location with NULL as a file (PR driver/90495)
Related show

Commit Message

Martin Liška May 16, 2019, 11:19 a.m.
Hi.

With LTO and -fsanitize we end up with a static ctor
(_GLOBAL__sub_I_00099_0_main) that has no source location.
With that stack usage will print '(artificial)' as a location
of the function.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

2019-05-16  Martin Liska  <mliska@suse.cz>

	PR driver/90495
	* toplev.c (output_stack_usage): With LTO and sanitizer it
	happens that a global ctor (_GLOBAL__sub_I_00099_0_main)
	has no file location.
---
 gcc/toplev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jeff Law May 16, 2019, 6:03 p.m. | #1
On 5/16/19 5:19 AM, Martin Liška wrote:
> Hi.

> 

> With LTO and -fsanitize we end up with a static ctor

> (_GLOBAL__sub_I_00099_0_main) that has no source location.

> With that stack usage will print '(artificial)' as a location

> of the function.

> 

> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

> 

> Ready to be installed?

> Thanks,

> Martin

> 

> gcc/ChangeLog:

> 

> 2019-05-16  Martin Liska  <mliska@suse.cz>

> 

> 	PR driver/90495

> 	* toplev.c (output_stack_usage): With LTO and sanitizer it

> 	happens that a global ctor (_GLOBAL__sub_I_00099_0_main)

> 	has no file location.

> ---

>  gcc/toplev.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> 

OK
jeff

Patch

diff --git a/gcc/toplev.c b/gcc/toplev.c
index 397a164068d..a27cdc4325d 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1019,7 +1019,7 @@  output_stack_usage (void)
 
       fprintf (stack_usage_file,
 	       "%s:%d:%d:%s\t" HOST_WIDE_INT_PRINT_DEC"\t%s\n",
-	       lbasename (loc.file),
+	       loc.file == NULL ? "(artificial)" : lbasename (loc.file),
 	       loc.line,
 	       loc.column,
 	       name,