diff mbox series

[11/13] AMD GCN symbol output with null cfun

Message ID 140d572813ba6d84a164819ae36caaeeaa99c14c.1573849744.git.julian@codesourcery.com
State New
Headers show
Series AMD GCN worker partitioning support | expand

Commit Message

Julian Brown Nov. 15, 2019, 9:44 p.m. UTC
This patch checks that cfun is valid in the gcn_asm_output_symbol_ref
function. This prevents a crash when that function is called with NULL
cfun, i.e. when outputting debug symbols.

OK?

Thanks,

Julian

ChangeLog

	gcc/
	* config/gcn/gcn.c (gcn_asm_output_symbol_ref): Handle null cfun.
---
 gcc/config/gcn/gcn.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Andrew Stubbs Nov. 18, 2019, 11:10 a.m. UTC | #1
On 15/11/2019 21:44, Julian Brown wrote:
> This patch checks that cfun is valid in the gcn_asm_output_symbol_ref
> function. This prevents a crash when that function is called with NULL
> cfun, i.e. when outputting debug symbols.
> 
> OK?

OK, although that FIXME still baffles me.

Andrew
diff mbox series

Patch

diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c
index 2f758ef3ddc..3584ac85021 100644
--- a/gcc/config/gcn/gcn.c
+++ b/gcc/config/gcn/gcn.c
@@ -5199,7 +5199,8 @@  void
 gcn_asm_output_symbol_ref (FILE *file, rtx x)
 {
   tree decl;
-  if ((decl = SYMBOL_REF_DECL (x)) != 0
+  if (cfun
+      && (decl = SYMBOL_REF_DECL (x)) != 0
       && TREE_CODE (decl) == VAR_DECL
       && AS_LDS_P (TYPE_ADDR_SPACE (TREE_TYPE (decl))))
     {
@@ -5214,7 +5215,8 @@  gcn_asm_output_symbol_ref (FILE *file, rtx x)
     {
       assemble_name (file, XSTR (x, 0));
       /* FIXME: See above -- this condition is unreachable.  */
-      if ((decl = SYMBOL_REF_DECL (x)) != 0
+      if (cfun
+	  && (decl = SYMBOL_REF_DECL (x)) != 0
 	  && TREE_CODE (decl) == VAR_DECL
 	  && AS_LDS_P (TYPE_ADDR_SPACE (TREE_TYPE (decl))))
 	fputs ("@abs32", file);