This is an archive of the discontinued LLVM Phabricator instance.

SHL instruction crash in CodeGen - Fixed
ClosedPublic

Authored by delena on Sep 6 2016, 1:51 AM.

Details

Summary

Shift-left (ISD::SHL) operation crashes on "DAG Legalization" phase.
https://llvm.org/bugs/show_bug.cgi?id=29058.

While node legalization we tried to legalize its operands. If an operand node is replaced during legalization it may kill the user.

Diff Detail

Repository
rL LLVM

Event Timeline

delena updated this revision to Diff 70360.Sep 6 2016, 1:51 AM
delena retitled this revision from to SHL instruction crash in CodeGen - Fixed .
delena updated this object.
delena added reviewers: qcolombet, spatel, RKSimon.
delena set the repository for this revision to rL LLVM.
delena added a subscriber: llvm-commits.
RKSimon edited edge metadata.Sep 7 2016, 4:04 AM

Any chance that the test case can be simplified (i.e. de-bugpointified) a little?

../lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
1073 ↗(On Diff #70360)

If it worth calling Node->getOperand(0) and Node->getOperand(1) only once?

1080 ↗(On Diff #70360)

So are you saying that if SAO == Node->getOperand(1) then its guaranteed to be already legal? Do we need to assert this?

delena marked an inline comment as done.Sep 7 2016, 5:18 AM

Any chance that the test case can be simplified (i.e. de-bugpointified) a little?

I did my best. I worked hard after the bugpoint gave up.

../lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
1080 ↗(On Diff #70360)

No. I say that SAO node will legalized in the next round. Legalization of more than one node together may crash.

RKSimon accepted this revision.Sep 7 2016, 9:35 AM
RKSimon edited edge metadata.

LGTM with a few minors

../lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
1080 ↗(On Diff #70360)

OK, please make that more clear in the comment.

../test/CodeGen/X86/shl-crash-on-legalize.ll
10 ↗(On Diff #70360)

var_366 doesn't appear to be referenced.

31 ↗(On Diff #70360)

Could rename the variables to make it more readable?

This revision is now accepted and ready to land.Sep 7 2016, 9:35 AM
This revision was automatically updated to reflect the committed changes.