diff mbox series

[Ada] Robustify implementation of pragma Inspection_Point

Message ID 4045644.exW6arL5Zr@polaris
State New
Headers show
Series [Ada] Robustify implementation of pragma Inspection_Point | expand

Commit Message

Eric Botcazou Oct. 22, 2018, 10:45 a.m. UTC
This avoids spurious errors on x86 when the register pressure is too high, for 
example on ACATS cxh3002:
cxh3002.adb: In function 'CXH3002':
cxh3002.adb:103:5: error: unsupported size for integer register

Tested on x86_64-suse-linux, applied on mainline, 8 and 7 branches.


2018-10-22  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (Pragma_to_gnu) <Pragma_Inspection_Point>: Use
	a simple memory constraint in all cases.
diff mbox series

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 265367)
+++ gcc-interface/trans.c	(working copy)
@@ -1285,32 +1285,18 @@  Pragma_to_gnu (Node_Id gnat_node)
 	{
 	  Node_Id gnat_expr = Expression (gnat_temp);
 	  tree gnu_expr = gnat_to_gnu (gnat_expr);
-	  int use_address;
-	  machine_mode mode;
-	  scalar_int_mode int_mode;
 	  tree asm_constraint = NULL_TREE;
 #ifdef ASM_COMMENT_START
 	  char *comment;
 #endif
-
-	  if (TREE_CODE (gnu_expr) == UNCONSTRAINED_ARRAY_REF)
-	    gnu_expr = TREE_OPERAND (gnu_expr, 0);
-
-	  /* Use the value only if it fits into a normal register,
-	     otherwise use the address.  */
-	  mode = TYPE_MODE (TREE_TYPE (gnu_expr));
-	  use_address = (!is_a <scalar_int_mode> (mode, &int_mode)
-			 || GET_MODE_SIZE (int_mode) > UNITS_PER_WORD);
-
-	  if (use_address)
-	    gnu_expr = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_expr);
+	  gnu_expr = maybe_unconstrained_array (gnu_expr);
+	  gnat_mark_addressable (gnu_expr);
 
 #ifdef ASM_COMMENT_START
 	  comment = concat (ASM_COMMENT_START,
 			    " inspection point: ",
 			    Get_Name_String (Chars (gnat_expr)),
-			    use_address ? " address" : "",
-			    " is in %0",
+			    " is at %0",
 			    NULL);
 	  asm_constraint = build_string (strlen (comment), comment);
 	  free (comment);
@@ -1320,8 +1306,8 @@  Pragma_to_gnu (Node_Id gnat_node)
 			     NULL_TREE,
 			     tree_cons
 			     (build_tree_list (NULL_TREE,
-					       build_string (1, "g")),
-			      gnu_expr, NULL_TREE),
+					       build_string (1, "m")),
+					       gnu_expr, NULL_TREE),
 			     NULL_TREE, NULL_TREE);
 	  ASM_VOLATILE_P (gnu_expr) = 1;
 	  set_expr_location_from_node (gnu_expr, gnat_node);