[PATCH] GVN: Don't crash on an unreachable predecessor
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri Nov 28 17:24:43 PST 2014
Don't crash when a PHI node comes from an unreachable predecessor.
Fixes (?) PR21625 [1].
I'm not really a memdep expert, so I'm not sure whether this counts
as a fix or if this just papers over a problem that will show up
some other way.
In the attached testcase, bb1 hits `PredTranslationFailure` twice,
causing the old assertion to fire. My proposed fix is to weaken
the assertion when the basic block has no predecessors:
- assert(I->getResult().isNonLocal() &&
+ assert((I->getResult().isNonLocal() ||
+ (I->getResult().isUnknown() && pred_begin(BB) == pred_end(BB))) &&
This approximates the logic for the entry block, which skips this
logic entirely with an early return:
// If this is the magic first block, return this as a clobber of the whole
// incoming value. Since we can't phi translate to one of the predecessors,
// we have to bail out.
if (SkipFirstBlock)
return true;
Thoughts?
[1]: http://llvm.org/bugs/show_bug.cgi?id=21625
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-GVN-Don-t-crash-on-an-unreachable-predecessor.patch
Type: application/octet-stream
Size: 2041 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141128/1544f967/attachment.obj>
More information about the llvm-commits
mailing list