This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] fix PR middle-end/44204
- From: Nathan Froyd <froydnj at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 20 May 2010 13:27:07 -0700
- Subject: [PATCH] fix PR middle-end/44204
The patch below fixes PR 44204, a small bit of fallout from the
CALL_EXPR_ARGS removal. We're now calling gimple_call_arg_ptr to get a
pointer to the zeroth argument for folding purposes. But with checking
enabled, such a call will cause an ICE if the gimple_call has no
arguments.
The fix for this is similar to what CALL_EXPR_ARGP does: do the pointer
arithmetic directly, rather than going through something that does
bounds-checking. I updated the comment to provide some context.
Tested on x86_64-unknown-linux-gnu. OK to commit?
-Nathan
PR middle-end/44204
* gimple.h (gimple_call_arg_ptr): Call gimple_ops directly. Update
comment.
Index: gimple.h
===================================================================
--- gimple.h (revision 159635)
+++ gimple.h (working copy)
@@ -2049,14 +2049,19 @@ gimple_call_arg (const_gimple gs, unsign
}
-/* Return a pointer to the argument at position INDEX for call
- statement GS. */
+/* Return a pointer to the argument at position INDEX for call statement
+ GS. We can't use gimple_op_ptr (GS, INDEX + 3) because that will
+ complain if INDEX is zero and the argument count is zero when
+ checking is enabled. Instead, do the pointer arithmetic to advance
+ past the 3 fixed operands. That produces a valid pointer to where
+ the arguments would live, even if dereferencing the pointer might not
+ be valid. */
static inline tree *
gimple_call_arg_ptr (const_gimple gs, unsigned index)
{
GIMPLE_CHECK (gs, GIMPLE_CALL);
- return gimple_op_ptr (gs, index + 3);
+ return gimple_ops (CONST_CAST_GIMPLE (gs)) + 3 + index;
}