After being reminded of the tm.h issues brought up last november (here: https://gcc.gnu.org/ml/gcc-patches/2013-11/msg01731.html ), I started looking back into it.

The general summary is the any header file which has a conditional on a target macro could be affected by include file reordering... ie, if a header file has
#ifdef BLAH
 <whatever>

and we move the header files around a bit, it wouldn't be immediately obvious if the order where changes and BLAH was define later in the include structure. The results for this header files would be different because <whatever> would no longer be in the preprocess source, and it may take a long time to discover the difference.

Josephs solution was to identify these and instead put a default definition in default.h ... then change all the uses to #if instead.. ie,
#if BLAH

This way we can ensure that the definition has been seen and it will be a compile error if not.


I looked at all the target macros listed by Joseph, and decide to start with the ones which are used *only* in an "if defined" situation in a .h files of some sort.
ie
#ifdef
#ifndef
or #if define()

If this happens in a .c file, then changing the order of .h's shouldn't matter. (Unless the .c file is doing something really screwy. So for the moment, ignoring that.)

So looking at only .h files, I found a number of default definitions in rtl.h, which this patch moves to defaults.h. I was going to #error if defaults.h wasn't included, but found that to be unnecessary since it uses some of those macros and would cause a compile failure anyway if it wasn't included. All the other uses of these particular macros use the #if model, so no further adjustment is required for them.

This patch bootstraps on x86_64-unknown-linux-gnu, and regressions are running. Assuming no issues show up, OK for mainline?

The remaining macros I will have a closer look at and most will likely need the full treatment moving from #ifdef to the #if model. I plan to do these next. The macros which fit this category for potential header trouble (along with their usage count) are:

2  USE_COLLECT2
3  TARGET_TERMINATE_DW2_EH_FRAME_INFO
3  TARGET_HAVE_CTORS_DTORS
3  REGMODE_NATURAL_SIZE
4  CC_STATUS_MDEP_INIT
4  CC_STATUS_MDEP_INIT
4  MODE_BASE_REG_REG_CLASS
4  REGNO_MODE_OK_FOR_REG_BASE_P
5  MODE_BASE_REG_CLASS
5  XCOFF_DEBUGGING_INFO
6  VMS_DEBUGGING_INFO
6  TARGET_ASM_OUTPUT_ANCHOR
6  EH_FRAME_SECTION_NAME
8  MODE_CODE_BASE_REG_CLASS
9  HARD_REGNO_CALLER_SAVE_MODE
9  HARD_REGNO_CALL_PART_CLOBBERED
9  SDB_DEBUGGING_INFO
9  CC_STATUS_MDEP
9  REGNO_MODE_CODE_OK_FOR_BASE_P
10 SECONDARY_RELOAD_CLASS
10 TARGET_VXWORKS_RTP
14 NO_DOT_IN_LABEL
14 REGNO_MODE_OK_FOR_BASE_P
17 STACK_REGS
19 TARGET_ASM_DESTRUCTOR
20 OBJECT_FORMAT_ELF
20 TARGET_ASM_CONSTRUCTOR
24 NO_DOLLAR_IN_LABEL
26 DBX_DEBUGGING_INFO
30 CPLUSPLUS_CPP_SPEC
42 ASM_OUTPUT_DEF





	* defaults.h (HAVE_PRE_INCREMENT, HAVE_PRE_DECREMENT,
	HAVE_POST_INCREMENT, HAVE_POST_DECREMENT, HAVE_POST_MODIFY_DISP,
	HAVE_POST_MODIFY_REG, HAVE_PRE_MODIFY_DISP, HAVE_PRE_MODIFY_REG,
	USE_LOAD_POST_INCREMENT, USE_LOAD_POST_DECREMENT,
	USE_LOAD_PRE_INCREMENT, USE_LOAD_PRE_DECREMENT,
	USE_STORE_POST_INCREMENT, USE_STORE_POST_DECREMENT,
	USE_STORE_PRE_INCREMENT, USE_STORE_PRE_DECREMENT,
	HARD_FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_IS_FRAME_POINTER,
	HARD_FRAME_POINTER_IS_ARG_POINTER): Relocate from rtl.h.
	* rtl.h: Move default definitions to defaults.h.
	(AUTO_INC_DEC): Adjust defintion check to assumed defaults exist.


Index: defaults.h
===================================================================
*** defaults.h	(revision 215355)
--- defaults.h	(working copy)
*************** see the files COPYING3 and COPYING.RUNTI
*** 1168,1173 ****
--- 1168,1264 ----
  #define DEFAULT_PCC_STRUCT_RETURN 1
  #endif
  
+ #ifndef HAVE_PRE_INCREMENT
+ #define HAVE_PRE_INCREMENT 0
+ #endif
+ 
+ #ifndef HAVE_PRE_DECREMENT
+ #define HAVE_PRE_DECREMENT 0
+ #endif
+ 
+ #ifndef HAVE_POST_INCREMENT
+ #define HAVE_POST_INCREMENT 0
+ #endif
+ 
+ #ifndef HAVE_POST_DECREMENT
+ #define HAVE_POST_DECREMENT 0
+ #endif
+ 
+ #ifndef HAVE_POST_MODIFY_DISP
+ #define HAVE_POST_MODIFY_DISP 0
+ #endif
+ 
+ #ifndef HAVE_POST_MODIFY_REG
+ #define HAVE_POST_MODIFY_REG 0
+ #endif
+ 
+ #ifndef HAVE_PRE_MODIFY_DISP
+ #define HAVE_PRE_MODIFY_DISP 0
+ #endif
+ 
+ #ifndef HAVE_PRE_MODIFY_REG
+ #define HAVE_PRE_MODIFY_REG 0
+ #endif
+ 
+ /* Some architectures do not have complete pre/post increment/decrement
+    instruction sets, or only move some modes efficiently.  These macros
+    allow us to tune autoincrement generation.  */
+ 
+ #ifndef USE_LOAD_POST_INCREMENT
+ #define USE_LOAD_POST_INCREMENT(MODE)   HAVE_POST_INCREMENT
+ #endif
+ 
+ #ifndef USE_LOAD_POST_DECREMENT
+ #define USE_LOAD_POST_DECREMENT(MODE)   HAVE_POST_DECREMENT
+ #endif
+ 
+ #ifndef USE_LOAD_PRE_INCREMENT
+ #define USE_LOAD_PRE_INCREMENT(MODE)    HAVE_PRE_INCREMENT
+ #endif
+ 
+ #ifndef USE_LOAD_PRE_DECREMENT
+ #define USE_LOAD_PRE_DECREMENT(MODE)    HAVE_PRE_DECREMENT
+ #endif
+ 
+ #ifndef USE_STORE_POST_INCREMENT
+ #define USE_STORE_POST_INCREMENT(MODE)  HAVE_POST_INCREMENT
+ #endif
+ 
+ #ifndef USE_STORE_POST_DECREMENT
+ #define USE_STORE_POST_DECREMENT(MODE)  HAVE_POST_DECREMENT
+ #endif
+ 
+ #ifndef USE_STORE_PRE_INCREMENT
+ #define USE_STORE_PRE_INCREMENT(MODE)   HAVE_PRE_INCREMENT
+ #endif
+ 
+ #ifndef USE_STORE_PRE_DECREMENT
+ #define USE_STORE_PRE_DECREMENT(MODE)   HAVE_PRE_DECREMENT
+ #endif
+ 
+ /* If HARD_FRAME_POINTER_REGNUM is defined, then a special dummy reg
+    is used to represent the frame pointer.  This is because the
+    hard frame pointer and the automatic variables are separated by an amount
+    that cannot be determined until after register allocation.  We can assume
+    that in this case ELIMINABLE_REGS will be defined, one action of which
+    will be to eliminate FRAME_POINTER_REGNUM into HARD_FRAME_POINTER_REGNUM.  */
+ #ifndef HARD_FRAME_POINTER_REGNUM
+ #define HARD_FRAME_POINTER_REGNUM FRAME_POINTER_REGNUM
+ #endif
+ 
+ #ifndef HARD_FRAME_POINTER_IS_FRAME_POINTER
+ #define HARD_FRAME_POINTER_IS_FRAME_POINTER \
+   (HARD_FRAME_POINTER_REGNUM == FRAME_POINTER_REGNUM)
+ #endif
+ 
+ #ifndef HARD_FRAME_POINTER_IS_ARG_POINTER
+ #define HARD_FRAME_POINTER_IS_ARG_POINTER \
+   (HARD_FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM)
+ #endif
+ 
+ 
+ 
+ 
  #ifdef GCC_INSN_FLAGS_H
  /* Dependent default target macro definitions
  
Index: rtl.h
===================================================================
*** rtl.h	(revision 215355)
--- rtl.h	(working copy)
*************** do {								        \
*** 2390,2399 ****
  /* Indicate whether the machine has any sort of auto increment addressing.
     If not, we can avoid checking for REG_INC notes.  */
  
! #if (defined (HAVE_PRE_INCREMENT) || defined (HAVE_PRE_DECREMENT) \
!      || defined (HAVE_POST_INCREMENT) || defined (HAVE_POST_DECREMENT) \
!      || defined (HAVE_PRE_MODIFY_DISP) || defined (HAVE_POST_MODIFY_DISP) \
!      || defined (HAVE_PRE_MODIFY_REG) || defined (HAVE_POST_MODIFY_REG))
  #define AUTO_INC_DEC
  #endif
  
--- 2390,2399 ----
  /* Indicate whether the machine has any sort of auto increment addressing.
     If not, we can avoid checking for REG_INC notes.  */
  
! #if (HAVE_PRE_INCREMENT || HAVE_PRE_DECREMENT \
!      || HAVE_POST_INCREMENT || HAVE_POST_DECREMENT \
!      || HAVE_PRE_MODIFY_DISP || HAVE_POST_MODIFY_DISP \
!      || HAVE_PRE_MODIFY_REG || HAVE_POST_MODIFY_REG)
  #define AUTO_INC_DEC
  #endif
  
*************** do {								        \
*** 2408,2482 ****
  #else
  #define FIND_REG_INC_NOTE(INSN, REG) 0
  #endif
- 
- #ifndef HAVE_PRE_INCREMENT
- #define HAVE_PRE_INCREMENT 0
- #endif
- 
- #ifndef HAVE_PRE_DECREMENT
- #define HAVE_PRE_DECREMENT 0
- #endif
- 
- #ifndef HAVE_POST_INCREMENT
- #define HAVE_POST_INCREMENT 0
- #endif
- 
- #ifndef HAVE_POST_DECREMENT
- #define HAVE_POST_DECREMENT 0
- #endif
- 
- #ifndef HAVE_POST_MODIFY_DISP
- #define HAVE_POST_MODIFY_DISP 0
- #endif
- 
- #ifndef HAVE_POST_MODIFY_REG
- #define HAVE_POST_MODIFY_REG 0
- #endif
- 
- #ifndef HAVE_PRE_MODIFY_DISP
- #define HAVE_PRE_MODIFY_DISP 0
- #endif
- 
- #ifndef HAVE_PRE_MODIFY_REG
- #define HAVE_PRE_MODIFY_REG 0
- #endif
- 
- 
- /* Some architectures do not have complete pre/post increment/decrement
-    instruction sets, or only move some modes efficiently.  These macros
-    allow us to tune autoincrement generation.  */
- 
- #ifndef USE_LOAD_POST_INCREMENT
- #define USE_LOAD_POST_INCREMENT(MODE)   HAVE_POST_INCREMENT
- #endif
- 
- #ifndef USE_LOAD_POST_DECREMENT
- #define USE_LOAD_POST_DECREMENT(MODE)   HAVE_POST_DECREMENT
- #endif
- 
- #ifndef USE_LOAD_PRE_INCREMENT
- #define USE_LOAD_PRE_INCREMENT(MODE)    HAVE_PRE_INCREMENT
- #endif
- 
- #ifndef USE_LOAD_PRE_DECREMENT
- #define USE_LOAD_PRE_DECREMENT(MODE)    HAVE_PRE_DECREMENT
- #endif
- 
- #ifndef USE_STORE_POST_INCREMENT
- #define USE_STORE_POST_INCREMENT(MODE)  HAVE_POST_INCREMENT
- #endif
- 
- #ifndef USE_STORE_POST_DECREMENT
- #define USE_STORE_POST_DECREMENT(MODE)  HAVE_POST_DECREMENT
- #endif
- 
- #ifndef USE_STORE_PRE_INCREMENT
- #define USE_STORE_PRE_INCREMENT(MODE)   HAVE_PRE_INCREMENT
- #endif
- 
- #ifndef USE_STORE_PRE_DECREMENT
- #define USE_STORE_PRE_DECREMENT(MODE)   HAVE_PRE_DECREMENT
- #endif
  
  /* Nonzero when we are generating CONCATs.  */
  extern int generating_concat_p;
--- 2408,2413 ----
*************** extern GTY(()) rtx cc0_rtx;
*** 2954,2979 ****
  extern GTY(()) rtx ret_rtx;
  extern GTY(()) rtx simple_return_rtx;
  
- /* If HARD_FRAME_POINTER_REGNUM is defined, then a special dummy reg
-    is used to represent the frame pointer.  This is because the
-    hard frame pointer and the automatic variables are separated by an amount
-    that cannot be determined until after register allocation.  We can assume
-    that in this case ELIMINABLE_REGS will be defined, one action of which
-    will be to eliminate FRAME_POINTER_REGNUM into HARD_FRAME_POINTER_REGNUM.  */
- #ifndef HARD_FRAME_POINTER_REGNUM
- #define HARD_FRAME_POINTER_REGNUM FRAME_POINTER_REGNUM
- #endif
- 
- #ifndef HARD_FRAME_POINTER_IS_FRAME_POINTER
- #define HARD_FRAME_POINTER_IS_FRAME_POINTER \
-   (HARD_FRAME_POINTER_REGNUM == FRAME_POINTER_REGNUM)
- #endif
- 
- #ifndef HARD_FRAME_POINTER_IS_ARG_POINTER
- #define HARD_FRAME_POINTER_IS_ARG_POINTER \
-   (HARD_FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM)
- #endif
- 
  /* Index labels for global_rtl.  */
  enum global_rtl_index
  {
--- 2885,2890 ----

Reply via email to