This is an archive of the discontinued LLVM Phabricator instance.

[MergeICmp] Fix a bug in MergeICmp that can lead to a block being processed more than once.
ClosedPublic

Authored by trentxintong on Feb 27 2018, 9:36 AM.

Details

Summary

Fix a bug in MergeICmp that can lead to a BCECmp block being processed more than once and eventually lead to a broken LLVM module.
The problem is that if the non-constant value is not produced by the last block, the producer will be processed once when the its parent block
is processed and second time when the last block is processed.

We end up having 2 same BCECmpBlock in the merge queue. And eventually lead to a broken LLVM module.

Diff Detail

Event Timeline

trentxintong created this revision.Feb 27 2018, 9:36 AM
trentxintong retitled this revision from [MergeICmp] Fix a bug in MergeICmp that can lead to a BCECmp block being processed more than once and eventually lead to a broken LLVM module. to [MergeICmp] Fix a bug in MergeICmp that can lead to a block being processed more than once..Feb 27 2018, 9:38 AM
trentxintong added a reviewer: davide.
trentxintong edited the summary of this revision. (Show Details)
courbet accepted this revision.Feb 28 2018, 1:06 AM

Thanks for the fix !

lib/Transforms/Scalar/MergeICmps.cpp
581

Can you add a debug line:

DEBUG(dbgs() << "skip: non-constant value not from cmp\n");

This revision is now accepted and ready to land.Feb 28 2018, 1:06 AM
This revision was automatically updated to reflect the committed changes.