The constraint was checking that the type is not an LLVM structure or array
type, but was not checking that it is an LLVM-compatible type, making it accept
incorrect types. As a result, some LLVM dialect ops could process values that
are not compatible with the LLVM dialect leading to further issues with
conversions and translations that assume all values are LLVM-compatible. Make
LLVM_AnyNonAggregate only accept LLVM-compatible types.
Reviewed By: cota, akuegel
Differential Revision: https://reviews.llvm.org/D107889
// Type constraint accepting any LLVM non-aggregate type, i.e. not structure or
// array.
-def LLVM_AnyNonAggregate : Type<Neg<LLVM_AnyAggregate.predicate>,
- "LLVM non-aggregate type">;
+def LLVM_AnyNonAggregate : Type<And<[LLVM_Type.predicate,
+ Neg<LLVM_AnyAggregate.predicate>]>,
+ "LLVM-compatible non-aggregate type">;
// Type constraint accepting any LLVM vector type.
def LLVM_AnyVector : Type<CPred<"::mlir::LLVM::isCompatibleVectorType($_self)">,
}
llvm.func @callee() -> !llvm.struct<(i32, f32)>
+
+// -----
+
+func @bitcast(%arg0: vector<2x3xf32>) {
+ // expected-error @below {{op operand #0 must be LLVM-compatible non-aggregate type}}
+ llvm.bitcast %arg0 : vector<2x3xf32> to vector<2x3xi32>
+ return
+}