This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Great example of why "everything is a tree" sucks
- From: Jeff Law <law at redhat dot com>
- To: GCC <gcc at gcc dot gnu dot org>
- Date: Tue, 12 Nov 2013 12:59:47 -0700
- Subject: Great example of why "everything is a tree" sucks
- Authentication-results: sourceware.org; auth=none
[rant]
So I lost something like 3 hrs last night due to writing a hunk of code
like this
if (INTEGRAL_TYPE_P (gimple_assign_lhs (stmt)))
With everything being a tree, the fact that I passed an SSA_NAME to
INTEGRAL_TYPE_P rather than a tree type wasn't caught at compile time.
Because this was guarding an optimization, it wasn't caught during a
bootstrap -- in the particular context in which this occurred, a false
result is always safe.
It was only caught by a failure to optimize a particular test that I had
tweaked with an earlier variant of the patch I was testing. So it
wasn't until regression testing had completed and I looked at the
results that there was any indication something was amiss.
Could we fix this by adding more checking around INTEGRAL_TYPE_P? Sure
and we'd probably trip the checker building the stage1 runtime or surely
during the stage2 build for this particular instance. But fundamentally
that's papering over the problem that I should not be able to do
something stupid like that in the first place!
We're using a language that has a type system that can easily express
that what I wrote as utterly stupid and wrong. But our "everything is
tree" model gets in the damn way.
In a lot of ways the arguments against fixing this problem remind me of
the nonsense we had to go through to stop shoving random pointers &
integers into trees 18 years ago. If a field is a tree, then shoving an
rtx or some 32 bit integer into the field is just stupid. We all take
that for granted now, but it was fairly standard practice a long time
ago. Fixing that was a necessary prerequisite for many of the things we
now take for granted -- function as trees, inlining with trees, garbage
collection, ssa, gimple, etc.
It's time to move on and do something sensible with the core parts of
our ILs so that we're all more effective in the long run.
[/rant]
Jeff