This is an archive of the discontinued LLVM Phabricator instance.

Fix PR26410: failing assertion when the X87 stackifier runs on functions containing IRETs
ClosedPublic

Authored by DavidKreitzer on Feb 26 2016, 6:17 AM.

Details

Summary

handleSpecialFP is currently hitting llvm_unreachable("Unknown SpecialFP instruction!"), because the IRET opcodes are marked as "FPForm = SpecialFP" but are unsupported in handleSpecialFP.

I chose to fix this by handling all the return opcodes uniformly in handleSpecialFP, as that seemed like the most robust choice. An alternative would be to change X86InstrControl.td so that the IRETs are not marked "FPForm = SpecialFP" since interrupt handlers cannot actually return x87 values (or any other values for that matter). But that clutters X86InstrControl.td for no good reason.

The code in the new handleReturn function is virtually identical to the original return-handling code in handleSpecialFP. The only differences are in the indentation and the "MachineInstr *MI = I;" at the top.

Diff Detail

Repository
rL LLVM

Event Timeline

DavidKreitzer retitled this revision from to Fix failing assertion when the X87 stackifier runs on functions containing IRETs.
DavidKreitzer updated this object.
DavidKreitzer added reviewers: nadav, qcolombet, aaboud.
DavidKreitzer added a subscriber: llvm-commits.
aaboud edited edge metadata.Feb 29 2016, 12:21 AM

LGTM.
By the way it should solve this Bug:
https://llvm.org/bugs/show_bug.cgi?id=26410

Thanks, Amjad. I took ownership of 26410.

DavidKreitzer retitled this revision from Fix failing assertion when the X87 stackifier runs on functions containing IRETs to Fix PR26410: failing assertion when the X87 stackifier runs on functions containing IRETs.Mar 4 2016, 6:09 AM
DavidKreitzer edited edge metadata.

Ping.

Amjad recommended that I get a second reviewer/approver before committing. I'd appreciate it if one of you could take a look.

qcolombet edited edge metadata.Mar 8 2016, 2:30 PM

Hi David,

The change LGTM, but the tests need a few nitpicks.

Cheers,
-Quentin

test/CodeGen/X86/x86-32-intrcc.ll
83 ↗(On Diff #49176)

Could you check we generate sensible code here?

86 ↗(On Diff #49176)

Please give a name to %[0-9]+ variables.
opt -instnamer can do this for you.
(It is a pain to update test cases with numbered variables.)

test/CodeGen/X86/x86-64-intrcc.ll
90 ↗(On Diff #49176)

Ditto: no %[0-9]+ and sensible testing.

DavidKreitzer edited edge metadata.

Thanks for the review, Quentin. I updated the tests according to your comments.

qcolombet accepted this revision.Mar 9 2016, 10:05 AM
qcolombet edited edge metadata.

Hi David,

LGTM.

Thanks,
-Quentin

This revision is now accepted and ready to land.Mar 9 2016, 10:05 AM
DavidKreitzer edited edge metadata.

Rebased to latest trunk.

This revision was automatically updated to reflect the committed changes.