I had a look into this again for the following small C program: struct rgb { char r; };
char read_bug (const __flash struct rgb *s) { struct rgb t = *s; return t.r; } char read_ok (const __flash struct rgb *s) { return s->r; } compiled as > avr-gcc flash-move.c -S -Os -dp -fdump-rtl-expand-details and with the patch applied to tree-pretty-print.c With that patch .expand dump reads: read_bug (const struct rgb * s) { char t$r; # BLOCK 2 freq:10000 # PRED: ENTRY [100.0%] (fallthru,exec) t$r_4 = s_1(D){address-space-1 ->}r; return t$r_4; # SUCC: EXIT [100.0%] } ;; Generating RTL for gimple basic block 2 ;; return t$r_4; (insn 6 5 7 (set (reg:QI 46) (mem:QI (reg/v/f:HI 44 [ s ]) [0 s_1(D){address-space-1 ->}r+0 S1 A8])) flash-move.c:7 -1 (nil)) ... which is wrong because in insn 6 there is no "AS1" in the memory attributes. Just compare with the respective dump of insn 6 of read_ok, which is correct: (insn 6 5 7 (set (reg:QI 46) (mem:QI (reg/v/f:HI 44 [ s ]) [0 s_1(D){address-space-1 ->}r+0 S1 A8 AS1])) flash-move.c:12 -1 (nil)) Thus, the problem appears to be at a completely different place. Or the changes to tree-pretty-print just serve to confuse myself... Johann
Index: tree-pretty-print.c =================================================================== --- tree-pretty-print.c (revision 183939) +++ tree-pretty-print.c (working copy) @@ -603,6 +603,7 @@ dump_generic_node (pretty_printer *buffe tree op0, op1; const char *str; bool is_expr; + addr_space_t as; if (node == NULL_TREE) return spc; @@ -837,7 +838,16 @@ dump_generic_node (pretty_printer *buffe { if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR) { - pp_string (buffer, "*"); + as = TYPE_ADDR_SPACE (TREE_TYPE (node)); + if (!ADDR_SPACE_GENERIC_P (as)) + { + pp_string (buffer, "<address-space-"); + pp_decimal_int (buffer, as); + pp_character (buffer, ' '); + } + pp_string (buffer, "*"); + if (!ADDR_SPACE_GENERIC_P (as)) + pp_character (buffer, '>'); dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); } @@ -1181,6 +1191,7 @@ dump_generic_node (pretty_printer *buffe case COMPONENT_REF: op0 = TREE_OPERAND (node, 0); str = "."; + as = ADDR_SPACE_GENERIC; if (op0 && (TREE_CODE (op0) == INDIRECT_REF || (TREE_CODE (op0) == MEM_REF @@ -1206,6 +1217,7 @@ dump_generic_node (pretty_printer *buffe (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))))) { op0 = TREE_OPERAND (op0, 0); + as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op0))); str = "->"; } if (op_prio (op0) < op_prio (node)) @@ -1213,7 +1225,15 @@ dump_generic_node (pretty_printer *buffe dump_generic_node (buffer, op0, spc, flags, false); if (op_prio (op0) < op_prio (node)) pp_character (buffer, ')'); + if (!ADDR_SPACE_GENERIC_P (as)) + { + pp_string (buffer, "{address-space-"); + pp_decimal_int (buffer, as); + pp_character (buffer, ' '); + } pp_string (buffer, str); + if (!ADDR_SPACE_GENERIC_P (as)) + pp_character (buffer, '}'); dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); op0 = component_ref_field_offset (node); if (op0 && TREE_CODE (op0) != INTEGER_CST) @@ -1670,7 +1690,19 @@ dump_generic_node (pretty_printer *buffe || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL)) ; /* Do not output '&' for strings and function pointers. */ else - pp_string (buffer, op_symbol (node)); + { + addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (node)); + + if (!ADDR_SPACE_GENERIC_P (as)) + { + pp_string (buffer, "<address-space-"); + pp_decimal_int (buffer, as); + pp_character (buffer, ' '); + } + pp_string (buffer, op_symbol (node)); + if (!ADDR_SPACE_GENERIC_P (as)) + pp_character (buffer, '>'); + } if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node)) {
struct rgb { char r; }; char read_bug (const __flash struct rgb *s) { struct rgb t = *s; return t.r; } char read_ok (const __flash struct rgb *s) { return s->r; }
;; Function read_bug (read_bug, funcdef_no=0, decl_uid=1320, cgraph_uid=0) read_bug (const struct rgb * s) { char t$r; # BLOCK 2 freq:10000 # PRED: ENTRY [100.0%] (fallthru,exec) t$r_4 = s_1(D){address-space-1 ->}r; return t$r_4; # SUCC: EXIT [100.0%] } Partition map Partition 1 (s_1(D) - 1 ) Partition 3 (.MEM_3(D) - 3 ) Partition 4 (t$r_4 - 4 ) Partition 5 (.MEM_5 - 5 ) Partition map Partition 0 (s_1(D) - 1 ) Live on entry to BB2 : s_1(D) Conflict graph: After sorting: Coalesce List: Partition map Partition 0 (s_1(D) - 1 ) After Coalescing: Partition map Partition 0 (s_1(D) - 1 ) Partition 1 (t$r_4 - 4 ) Replacing Expressions t$r_4 replace with --> t$r_4 = s_1(D){address-space-1 ->}r; read_bug (const struct rgb * s) { char t$r; # BLOCK 2 freq:10000 # PRED: ENTRY [100.0%] (fallthru,exec) t$r_4 = s_1(D){address-space-1 ->}r; return t$r_4; # SUCC: EXIT [100.0%] } ;; Generating RTL for gimple basic block 2 ;; return t$r_4; (insn 6 5 7 (set (reg:QI 46) (mem:QI (reg/v/f:HI 44 [ s ]) [0 s_1(D){address-space-1 ->}r+0 S1 A8])) flash-move.c:7 -1 (nil)) (insn 7 6 8 (set (reg:QI 43 [ <retval> ]) (reg:QI 46)) flash-move.c:7 -1 (nil)) (jump_insn 8 7 9 (set (pc) (label_ref 0)) flash-move.c:7 -1 (nil)) (barrier 9 8 0) ;; ;; Full RTL generated for this function: ;; (note 1 0 4 NOTE_INSN_DELETED) (note 4 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK) (insn 2 4 3 2 (set (reg/v/f:HI 44 [ s ]) (reg:HI 24 r24 [ s ])) flash-move.c:4 -1 (nil)) (note 3 2 5 2 NOTE_INSN_FUNCTION_BEG) (note 5 3 6 3 [bb 3] NOTE_INSN_BASIC_BLOCK) (insn 6 5 7 3 (set (reg:QI 46) (mem:QI (reg/v/f:HI 44 [ s ]) [0 s_1(D){address-space-1 ->}r+0 S1 A8])) flash-move.c:7 -1 (nil)) (insn 7 6 8 3 (set (reg:QI 43 [ <retval> ]) (reg:QI 46)) flash-move.c:7 -1 (nil)) (jump_insn 8 7 9 3 (set (pc) (label_ref 10)) flash-move.c:7 -1 (nil) -> 10) (barrier 9 8 15) (note 15 9 12 4 [bb 4] NOTE_INSN_BASIC_BLOCK) (insn 12 15 13 4 (clobber (reg/i:QI 24 r24)) flash-move.c:8 -1 (nil)) (insn 13 12 10 4 (clobber (reg:QI 43 [ <retval> ])) flash-move.c:8 -1 (nil)) (code_label 10 13 16 5 1 "" [1 uses]) (note 16 10 11 5 [bb 5] NOTE_INSN_BASIC_BLOCK) (insn 11 16 14 5 (set (reg/i:QI 24 r24) (reg:QI 43 [ <retval> ])) flash-move.c:8 -1 (nil)) (insn 14 11 0 5 (use (reg/i:QI 24 r24)) flash-move.c:8 -1 (nil)) ;; Function read_ok (read_ok, funcdef_no=1, decl_uid=1324, cgraph_uid=1) read_ok (const struct rgb * s) { char D.1327; # BLOCK 2 freq:10000 # PRED: ENTRY [100.0%] (fallthru,exec) D.1327_2 = s_1(D){address-space-1 ->}r; return D.1327_2; # SUCC: EXIT [100.0%] } Partition map Partition 1 (s_1(D) - 1 ) Partition 2 (D.1327_2 - 2 ) Partition 3 (.MEM_3(D) - 3 ) Partition map Partition 0 (s_1(D) - 1 ) Live on entry to BB2 : s_1(D) Conflict graph: After sorting: Coalesce List: Partition map Partition 0 (s_1(D) - 1 ) After Coalescing: Partition map Partition 0 (s_1(D) - 1 ) Partition 1 (D.1327_2 - 2 ) Replacing Expressions D.1327_2 replace with --> D.1327_2 = s_1(D){address-space-1 ->}r; read_ok (const struct rgb * s) { char D.1327; # BLOCK 2 freq:10000 # PRED: ENTRY [100.0%] (fallthru,exec) D.1327_2 = s_1(D){address-space-1 ->}r; return D.1327_2; # SUCC: EXIT [100.0%] } ;; Generating RTL for gimple basic block 2 ;; return D.1327_2; (insn 6 5 7 (set (reg:QI 46) (mem:QI (reg/v/f:HI 44 [ s ]) [0 s_1(D){address-space-1 ->}r+0 S1 A8 AS1])) flash-move.c:12 -1 (nil)) (insn 7 6 8 (set (reg:QI 43 [ <retval> ]) (reg:QI 46)) flash-move.c:12 -1 (nil)) (jump_insn 8 7 9 (set (pc) (label_ref 0)) flash-move.c:12 -1 (nil)) (barrier 9 8 0) ;; ;; Full RTL generated for this function: ;; (note 1 0 4 NOTE_INSN_DELETED) (note 4 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK) (insn 2 4 3 2 (set (reg/v/f:HI 44 [ s ]) (reg:HI 24 r24 [ s ])) flash-move.c:11 -1 (nil)) (note 3 2 5 2 NOTE_INSN_FUNCTION_BEG) (note 5 3 6 3 [bb 3] NOTE_INSN_BASIC_BLOCK) (insn 6 5 7 3 (set (reg:QI 46) (mem:QI (reg/v/f:HI 44 [ s ]) [0 s_1(D){address-space-1 ->}r+0 S1 A8 AS1])) flash-move.c:12 -1 (nil)) (insn 7 6 8 3 (set (reg:QI 43 [ <retval> ]) (reg:QI 46)) flash-move.c:12 -1 (nil)) (jump_insn 8 7 9 3 (set (pc) (label_ref 10)) flash-move.c:12 -1 (nil) -> 10) (barrier 9 8 15) (note 15 9 12 4 [bb 4] NOTE_INSN_BASIC_BLOCK) (insn 12 15 13 4 (clobber (reg/i:QI 24 r24)) flash-move.c:13 -1 (nil)) (insn 13 12 10 4 (clobber (reg:QI 43 [ <retval> ])) flash-move.c:13 -1 (nil)) (code_label 10 13 16 5 2 "" [1 uses]) (note 16 10 11 5 [bb 5] NOTE_INSN_BASIC_BLOCK) (insn 11 16 14 5 (set (reg/i:QI 24 r24) (reg:QI 43 [ <retval> ])) flash-move.c:13 -1 (nil)) (insn 14 11 0 5 (use (reg/i:QI 24 r24)) flash-move.c:13 -1 (nil))