tengwu wrote:

> What exactly is the rule for the cases the backend rejects? I don't think 
> your proposed rule rejecting pointer inputs catches all the relevant cases.

You're right, the issue is not specific to pointer inputs. Pointer input was 
only the case I first noticed, but the same lowering path is used for integer 
inputs as well.

The rule I’m trying to enforce is:

For a tied operand where the output constraint allows a register, if the output 
type is non-scalar/AD_Other, Clang may promote the input value and lower the 
output as a register result. For an 'r' constraint, that means the value is 
bound to a general-purpose register. We should only allow that path when the 
non-scalar output can be represented as an integer value that fits in a 
general-purpose register for the target.

So the check should be based on the output operand, not on whether the input is 
a pointer:

```cpp
OutputDomain == AD_Other &&
output size is not representable by an integer type fitting in a GPR
```

This catches the broader class of failures: integer or pointer inputs tied to 
oversized struct/union/array/class/vector/complex register outputs. It also 
keeps GPR-sized aggregates accepted, e.g. a 32-bit aggregate on i386 or a 
64-bit aggregate on x86_64.

I updated the patch accordingly and added tests for integer inputs tied to the 
different AD_Other output kinds.

https://github.com/llvm/llvm-project/pull/206230
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to