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

2019-11-18 Thread Andrew Stubbs

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


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

2019-11-15 Thread Julian Brown
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(-)

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);
-- 
2.23.0