This is an archive of the discontinued LLVM Phabricator instance.

Fix PR34170: Crash on inline asm with 64bit output in 32bit GPR
ClosedPublic

Authored by thopre on Apr 6 2018, 8:48 AM.

Details

Summary

Add support for inline assembly with output operand that do not naturally go in the register class it is constrained to (eg. double in a 32-bit GPR as in the PR).

Diff Detail

Event Timeline

thopre created this revision.Apr 6 2018, 8:48 AM
thopre updated this revision to Diff 141360.Apr 6 2018, 8:48 AM

Fix code style issue

efriedma edited reviewers, added: efriedma; removed: lattner.Apr 17 2018, 10:55 AM
efriedma added a subscriber: efriedma.

Could you separate the "add support for matching input" part into a separate patch? I'm having trouble following what exactly you're trying to do.

thopre updated this revision to Diff 152299.Jun 21 2018, 7:50 AM

Split the matching input handling into a separate patch.

thopre edited the summary of this revision. (Show Details)Jun 21 2018, 7:58 AM

Could you separate the "add support for matching input" part into a separate patch? I'm having trouble following what exactly you're trying to do.

Done. Sorry for the delay, was in extended leave away from computer.

Could you separate the "add support for matching input" part into a separate patch? I'm having trouble following what exactly you're trying to do.

Done. Sorry for the delay, was in extended leave away from computer.

Ping?

Best regards,

Thomas

efriedma added inline comments.Jul 5 2018, 3:10 PM
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
7733

Is this change necessary? getCopyFromRegs should do the appropriate int->float bitcast, I think.

test/CodeGen/ARM/pr34170.ll
1 ↗(On Diff #152299)

Please pick a different filename for this file. And I'd like to see tests for float and double inputs and outputs, in both soft-float and hard-float modes.

Hi Eli,

Again my apologies for the delay, my mail filter put the notification for your comments in the wrong folder. Should be fixed now and I'll keep an eye on phabricator directly to make sure it is. I've replied to your comments inline, will add the float testcase that you asked shortly.

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
7733

It's not about int->float but in this case about i32 (ResultType) -> i64 (Val). It's much in the same spirit as what happens in GetRegistersForValue for input operands. As you can see here we only record the type for output but don't do the bitcase since it must be done *after* the asm call (as opposed to inputs where it must be done before).

test/CodeGen/ARM/pr34170.ll
1 ↗(On Diff #152299)

So as not to repeat the same mistake what is the rule on using the PR number for the test? I can see quite a few tests with the same sort of name, some with very close PR number. Would inline-asm-convert-crash.ll be ok?

efriedma added inline comments.Jul 19 2018, 2:21 PM
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
7733

Oh, right, getCopyFromRegs doesn't do the bitcast because it thinks the destination type is i64.

I'm not really convinced going through i64 is the right approach here (it only does the right thing on ARM because i64 isn't legal), but I guess it's okay given the existing precedent.

test/CodeGen/ARM/pr34170.ll
1 ↗(On Diff #152299)

Sometimes people use the PR number because there isn't any good alternative, but best practice is to describe what the file is testing, not why you're adding the test. So something like inline-asm-float-gpr.ll. (You can put a reference to the bug as a comment in the test if you think it's helpful.)

thopre updated this revision to Diff 156995.Jul 24 2018, 3:53 AM

Rename testcase and test both soft and hard float ABI

This revision is now accepted and ready to land.Jul 24 2018, 10:52 AM
thopre closed this revision.Aug 3 2018, 2:24 AM

Fixed in trunk