This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Fix bug in inline asm reserved register detection
Needs ReviewPublic

Authored by vhscampos on May 11 2020, 7:26 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

In the case where inline asm's input operands are assigned values,
targets may opt to emit an error when a reserved register is used for
such operands. This is the case for Arm.

The current code, however, emits an error even when the reserved
register, when used as an input operand, is only read from. This is a
bug.

This patch adds additional checks to emit error only when a reserved
register used as an input operand is actually written to. The criteria
used is to check whether or not the input operand value, which is the
value to be loaded into the input, is undef. When this is the case, the
assignment is optimized away and therefore the reserved register ends up
not being written to.

Diff Detail

Event Timeline

vhscampos created this revision.May 11 2020, 7:26 AM

We can't reasonably check whether the argument is undef; among other issues, it completely destroys the meaning of "undef", and the argument probably won't be undef at -O0.

If we want to do something here, we need to resolve it in clang somehow, so we aren't passing an argument at all.

(I think gcc prints an error for this case?)

Thanks @efriedma for the clarification. It seems that the handling of input operands must be moved to clang then.

(Yes, gcc prints an error in this case.)

I am opening another review to remove the handling of inputs operands for the time being.