This is an archive of the discontinued LLVM Phabricator instance.

[Target/X86] Fix crash in assignTopologicalOrder()
ClosedPublic

Authored by davide on May 9 2015, 2:26 PM.

Details

Reviewers
davide
bkramer
Summary

Disclaimer: I'm not really familiar with the lowering code, and it looks pretty scary. If this doesn't make sense, I apologize in advance.

It seems that call to ReplaceAllUsesWith() when we're turning SHL -> AND is not really required and causes problems with the testcase below. It ends up producing an incorrect DAG, with a cycle in, so a topological order can't be assigned.

In particular this issue shows up if getConstant() gets an existing node in the graph rather than generating a new one, which is then incorrectly deleted causing the issue.

As an added note, In the test, {2, 127} can be changed to {4, 63} or {8, 31} and the issue remain.

%mul = mul i8 %trunc, 2
%and = and i8 %trunc, 127

Diff Detail

Event Timeline

davide updated this revision to Diff 25421.May 9 2015, 2:26 PM
davide retitled this revision from to [Target/X86] Fix crash in assignTopologicalOrder().
davide updated this object.
davide edited the test plan for this revision. (Show Details)
davide added a reviewer: bkramer.
davide set the repository for this revision to rL LLVM.
davide added a subscriber: Unknown Object (MLST).
bkramer edited edge metadata.May 20 2015, 12:36 PM

This isn't the right fix. The resulting code from the test case now looks like this

movb	a(%rip), %cl
andb	$127, %cl
setne	%al
testb	%cl, %cl
setne	b(%rip)

There should only be one testb, no andb. I think we just have to remove the dead node after replacing all nodes, I'll commit a fix for that.

davide accepted this revision.May 20 2015, 1:17 PM
davide added a reviewer: davide.

r237828

This revision is now accepted and ready to land.May 20 2015, 1:17 PM
davide closed this revision.May 20 2015, 1:17 PM