This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel][InlineAsm] Extend input operands when register class size does not match type
AbandonedPublic

Authored by gargaroff on Jul 8 2020, 5:51 AM.

Details

Reviewers
arsenm
kschwarz
Summary

The InlineAsmLowering was blindly copying the input operands to the selected register class without checking if their sizes match. This resulted in illegal COPYs. Use G_ANYEXT to extend the input operand to fit the selected register class. G_ANYEXT ist used since the inline assembler is not allowed to assume anything about the upper bits of the input operands.

Diff Detail

Event Timeline

gargaroff created this revision.Jul 8 2020, 5:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2020, 5:51 AM
gargaroff updated this revision to Diff 276394.Jul 8 2020, 5:52 AM

Forgot to commit final changes before diff

arsenm added inline comments.Jul 8 2020, 1:09 PM
llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp
537–539

Scratch reg and InputReg are the same thing. You can just use the type as the DstOp to buildAnyExt.

This may also be a problem for non-scalar sources. What if you have <2 x i4>?

A similar issue (for tied input operands) is handled in https://reviews.llvm.org/D83384
The function introduced there should be extended to handle the vector case.

A similar issue (for tied input operands) is handled in https://reviews.llvm.org/D83384
The function introduced there should be extended to handle the vector case.

In that case I'll hold off on this patch until the one you linked is landed. If that one will introduce the extension handling already, I'll abandon this patch.

gargaroff abandoned this revision.Jul 15 2020, 12:28 AM

I'll abandon this patch since this was committed in https://reviews.llvm.org/rGfd85b40aee4aa4cfcecaf2bfaf86e1de4c78ab0c