[SelDAGBuilder] Do not require simple VTs for constraints.
authorFlorian Hahn <flo@fhahn.com>
Thu, 19 Nov 2020 09:31:54 +0000 (09:31 +0000)
committerFlorian Hahn <flo@fhahn.com>
Thu, 19 Nov 2020 09:31:54 +0000 (09:31 +0000)
commit1983acce7c4da01d8fb33b3b3465619f973edd49
tree70d99c19abc313328faa4fd535d4efa2674edb90
parent515105f46b7e0037fe49a6fa8e469823c3f8433e
[SelDAGBuilder] Do not require simple VTs for constraints.

In some cases, the values passed to `asm sideeffect` calls cannot be
mapped directly to simple MVTs. Currently, we crash in the backend if
that happens. An example can be found in the @test_vector_too_large_r_m
test case, where we pass <9 x float> vectors. In practice, this can
happen in cases like the simple C example below.

using vec = float __attribute__((ext_vector_type(9)));
void f1 (vec m) {
  asm volatile("" : "+r,m"(m) : : "memory");
}

One case that use "+r,m" constraints for arbitrary data types in
practice is google-benchmark's DoNotOptimize.

This patch updates visitInlineAsm so that it use MVT::Other for
constraints with complex VTs. It looks like the rest of the backend
correctly deals with that and properly legalizes the type.

And we still report an error if there are no registers to satisfy the
constraint.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D91710
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/AArch64/arm64-inline-asm.ll
llvm/test/CodeGen/AArch64/inlineasm-illegal-type.ll