This is the mail archive of the gcc-patches@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]

Change an assignment to an assert in varpool


I noticed that we set node->definition = true in varpool_assemble_decl. The surrounding code suggests that we should only ever get there if definition is already true, so I changed it to an assert. The question is interesting for some modifications I'm making for ptx (which requires declarations for external variables in the assembly).

The only thing that was tripped by the assert was a variable created by asan. AFAICT the problem there is that asan calls varpool_assemble_decl when it should be calling varpool_finalize_decl.

Bootstrapped and tested on x86_64-linux, ok?


Bernd
	* asan.c (asan_finish_file): Use varpool_finalize_decl instead of
	varpool_assemble_decl.
	* varpool.c (varpool_assemble_decl): Assert that node->definition is
	true.

diff --git a/gcc/asan.c b/gcc/asan.c
index b9a4a91..0d78634 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -2595,7 +2595,7 @@ asan_finish_file (void)
       TREE_CONSTANT (ctor) = 1;
       TREE_STATIC (ctor) = 1;
       DECL_INITIAL (var) = ctor;
-      varpool_assemble_decl (varpool_node_for_decl (var));
+      varpool_finalize_decl (var);
 
       fn = builtin_decl_implicit (BUILT_IN_ASAN_REGISTER_GLOBALS);
       tree gcount_tree = build_int_cst (pointer_sized_int_node, gcount);
diff --git a/gcc/varpool.c b/gcc/varpool.c
index 79f07bf..a72fb22 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -473,7 +473,7 @@ varpool_assemble_decl (varpool_node *node)
     {
       assemble_variable (decl, 0, 1, 0);
       gcc_assert (TREE_ASM_WRITTEN (decl));
-      node->definition = true;
+      gcc_assert (node->definition);
       assemble_aliases (node);
       return true;
     }

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