+2010-01-20 Jakub Jelinek <jakub@redhat.com>
+
+ * var-tracking.c (check_value_val): Add a compile time assertion.
+ (dv_is_decl_p): Simplify.
+ (dv_as_decl, dv_as_value, dv_from_decl, dv_from_value): Only use
+ gcc_assert if ENABLE_CHECKING.
+
2010-01-20 Alexandre Oliva <aoliva@redhat.com>
PR debug/42782
#include "cselib.h"
#include "target.h"
+/* var-tracking.c assumes that tree code with the same value as VALUE rtx code
+ has no chance to appear in REG_EXPR/MEM_EXPRs and isn't a decl.
+ Currently the value is the same as IDENTIFIER_NODE, which has such
+ a property. If this compile time assertion ever fails, make sure that
+ the new tree code that equals (int) VALUE has the same property. */
+extern char check_value_val[(int) VALUE == (int) IDENTIFIER_NODE ? 1 : -1];
+
/* Type of micro operation. */
enum micro_operation_type
{
static inline bool
dv_is_decl_p (decl_or_value dv)
{
- if (!dv)
- return true;
-
- /* Make sure relevant codes don't overlap. */
- switch ((int)TREE_CODE ((tree)dv))
- {
- case (int)VAR_DECL:
- case (int)PARM_DECL:
- case (int)RESULT_DECL:
- case (int)FUNCTION_DECL:
- case (int)DEBUG_EXPR_DECL:
- case (int)COMPONENT_REF:
- return true;
-
- case (int)VALUE:
- return false;
-
- default:
- gcc_unreachable ();
- }
+ return !dv || (int) TREE_CODE ((tree) dv) != (int) VALUE;
}
/* Return true if a decl_or_value is a VALUE rtl. */
static inline tree
dv_as_decl (decl_or_value dv)
{
+#ifdef ENABLE_CHECKING
gcc_assert (dv_is_decl_p (dv));
+#endif
return (tree) dv;
}
static inline rtx
dv_as_value (decl_or_value dv)
{
+#ifdef ENABLE_CHECKING
gcc_assert (dv_is_value_p (dv));
+#endif
return (rtx)dv;
}
{
decl_or_value dv;
dv = decl;
+#ifdef ENABLE_CHECKING
gcc_assert (dv_is_decl_p (dv));
+#endif
return dv;
}
{
decl_or_value dv;
dv = value;
+#ifdef ENABLE_CHECKING
gcc_assert (dv_is_value_p (dv));
+#endif
return dv;
}