[clang] [CIR] Propagate type conversion failures in DirectToLLVM (PR #224237)
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 15 17:53:18 PDT 2026
================
@@ -0,0 +1,199 @@
+// RUN: cir-opt %s --split-input-file --cir-to-llvm -verify-diagnostics
+
+// Vector-of-_BitInt conversion is unsupported; propagate its failure to the
+// enclosing operation instead of constructing invalid LLVM operations.
+
+!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
+
+module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
+ // expected-error @below {{failed to legalize operation 'cir.func'}}
----------------
bcardosolopes wrote:
Not crashing is an improvement, but this is all the user gets now, and it doesn't say what's wrong. The motivating type is reachable from valid C, too:
```c
typedef _BitInt(32) v4 __attribute__((ext_vector_type(4)));
v4 add(v4 a, v4 b) { return a + b; }
```
Classic emits `<4 x i32>` for that. With `-fclangir` this becomes "failed to legalize operation 'cir.func'" and nothing else. The vtable path also loses its specific "Unable to get value for vtable symbol" error.
Can the patterns that fail on a type conversion emit an NYI error naming the type, e.g. `op.emitError() << "ClangIR lowering NYI: cannot convert " << type`, instead of a bare `failure()`?
https://github.com/llvm/llvm-project/pull/224237
More information about the cfe-commits
mailing list