gimple-fold.h: Add missing gimple-iterator.h

Message ID 20230112014440.19153-1-palmer@rivosinc.com
State Unresolved
Headers
Series gimple-fold.h: Add missing gimple-iterator.h |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Palmer Dabbelt Jan. 12, 2023, 1:44 a.m. UTC
  As of 6f5b06032eb ("Finish gimple_build API enhancement") gimple-fold.h
uses some of the declarations from gimple-iterator.h, which causes
issues when building Linux's stackprotector plugin.

gcc/ChangeLog:

	* gimple-fold.h: Add gimple-iterator.h include.

---

I'm not sure if this should instead be fixed in Linux by reordering the
includes along the lines of
  

Comments

Richard Biener Jan. 12, 2023, 7:55 a.m. UTC | #1
On Thu, Jan 12, 2023 at 2:46 AM Palmer Dabbelt <palmer@rivosinc.com> wrote:
>
> As of 6f5b06032eb ("Finish gimple_build API enhancement") gimple-fold.h
> uses some of the declarations from gimple-iterator.h, which causes
> issues when building Linux's stackprotector plugin.
>
> gcc/ChangeLog:
>
>         * gimple-fold.h: Add gimple-iterator.h include.
>
> ---
>
> I'm not sure if this should instead be fixed in Linux by reordering the
> includes along the lines of
>
> diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
> index 9a1895747b15..2c3a3079128a 100644
> --- a/scripts/gcc-plugins/gcc-common.h
> +++ b/scripts/gcc-plugins/gcc-common.h
> @@ -72,6 +72,7 @@
>  #include "stor-layout.h"
>  #include "internal-fn.h"
>  #include "gimple-expr.h"
> +#include "gimple-iterator.h"
>  #include "gimple-fold.h"
>  #include "context.h"
>  #include "tree-ssa-alias.h"
> @@ -88,7 +89,6 @@
>  #include "gimple.h"
>  #include "tree-phinodes.h"
>  #include "tree-cfg.h"
> -#include "gimple-iterator.h"
>  #include "gimple-ssa.h"
>  #include "ssa-iterators.h"

The above change is OK.

> but I figured it was slightly easier for users to keep these compatible.
> It looks like many GCC-internal uses of gimple-fold.h already have the
> gimple-iterator.h include right before, though, so not sure if that's
> how things are meant to be.
> ---
>  gcc/gimple-fold.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/gcc/gimple-fold.h b/gcc/gimple-fold.h
> index 2fd58db9a2e..66bee2b75df 100644
> --- a/gcc/gimple-fold.h
> +++ b/gcc/gimple-fold.h
> @@ -22,6 +22,8 @@ along with GCC; see the file COPYING3.  If not see
>  #ifndef GCC_GIMPLE_FOLD_H
>  #define GCC_GIMPLE_FOLD_H
>
> +#include "gimple-iterator.h"
> +

But this is not - we try to avoid #include directives in headers, we want the
include dependences to be "flat"

>  extern tree create_tmp_reg_or_ssa_name (tree, gimple *stmt = NULL);
>  extern tree canonicalize_constructor_val (tree, tree);
>  extern tree get_symbol_constant_value (tree);
> --
> 2.39.0
>
  
Palmer Dabbelt Jan. 13, 2023, 5:31 p.m. UTC | #2
On Wed, 11 Jan 2023 23:55:15 PST (-0800), richard.guenther@gmail.com wrote:
> On Thu, Jan 12, 2023 at 2:46 AM Palmer Dabbelt <palmer@rivosinc.com> wrote:
>>
>> As of 6f5b06032eb ("Finish gimple_build API enhancement") gimple-fold.h
>> uses some of the declarations from gimple-iterator.h, which causes
>> issues when building Linux's stackprotector plugin.
>>
>> gcc/ChangeLog:
>>
>>         * gimple-fold.h: Add gimple-iterator.h include.
>>
>> ---
>>
>> I'm not sure if this should instead be fixed in Linux by reordering the
>> includes along the lines of
>>
>> diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
>> index 9a1895747b15..2c3a3079128a 100644
>> --- a/scripts/gcc-plugins/gcc-common.h
>> +++ b/scripts/gcc-plugins/gcc-common.h
>> @@ -72,6 +72,7 @@
>>  #include "stor-layout.h"
>>  #include "internal-fn.h"
>>  #include "gimple-expr.h"
>> +#include "gimple-iterator.h"
>>  #include "gimple-fold.h"
>>  #include "context.h"
>>  #include "tree-ssa-alias.h"
>> @@ -88,7 +89,6 @@
>>  #include "gimple.h"
>>  #include "tree-phinodes.h"
>>  #include "tree-cfg.h"
>> -#include "gimple-iterator.h"
>>  #include "gimple-ssa.h"
>>  #include "ssa-iterators.h"
>
> The above change is OK.
>
>> but I figured it was slightly easier for users to keep these compatible.
>> It looks like many GCC-internal uses of gimple-fold.h already have the
>> gimple-iterator.h include right before, though, so not sure if that's
>> how things are meant to be.
>> ---
>>  gcc/gimple-fold.h | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/gcc/gimple-fold.h b/gcc/gimple-fold.h
>> index 2fd58db9a2e..66bee2b75df 100644
>> --- a/gcc/gimple-fold.h
>> +++ b/gcc/gimple-fold.h
>> @@ -22,6 +22,8 @@ along with GCC; see the file COPYING3.  If not see
>>  #ifndef GCC_GIMPLE_FOLD_H
>>  #define GCC_GIMPLE_FOLD_H
>>
>> +#include "gimple-iterator.h"
>> +
>
> But this is not - we try to avoid #include directives in headers, we want the
> include dependences to be "flat"

Makes sense.  I've sent the diff above to Linux: 
https://lore.kernel.org/r/20230113173033.4380-1-palmer@rivosinc.com/

>
>>  extern tree create_tmp_reg_or_ssa_name (tree, gimple *stmt = NULL);
>>  extern tree canonicalize_constructor_val (tree, tree);
>>  extern tree get_symbol_constant_value (tree);
>> --
>> 2.39.0
>>
  

Patch

diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
index 9a1895747b15..2c3a3079128a 100644
--- a/scripts/gcc-plugins/gcc-common.h
+++ b/scripts/gcc-plugins/gcc-common.h
@@ -72,6 +72,7 @@ 
 #include "stor-layout.h"
 #include "internal-fn.h"
 #include "gimple-expr.h"
+#include "gimple-iterator.h"
 #include "gimple-fold.h"
 #include "context.h"
 #include "tree-ssa-alias.h"
@@ -88,7 +89,6 @@ 
 #include "gimple.h"
 #include "tree-phinodes.h"
 #include "tree-cfg.h"
-#include "gimple-iterator.h"
 #include "gimple-ssa.h"
 #include "ssa-iterators.h"

but I figured it was slightly easier for users to keep these compatible.
It looks like many GCC-internal uses of gimple-fold.h already have the
gimple-iterator.h include right before, though, so not sure if that's
how things are meant to be.
---
 gcc/gimple-fold.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/gimple-fold.h b/gcc/gimple-fold.h
index 2fd58db9a2e..66bee2b75df 100644
--- a/gcc/gimple-fold.h
+++ b/gcc/gimple-fold.h
@@ -22,6 +22,8 @@  along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_GIMPLE_FOLD_H
 #define GCC_GIMPLE_FOLD_H
 
+#include "gimple-iterator.h"
+
 extern tree create_tmp_reg_or_ssa_name (tree, gimple *stmt = NULL);
 extern tree canonicalize_constructor_val (tree, tree);
 extern tree get_symbol_constant_value (tree);