E8010
E8010 — Anmlir!block whosedialectslist does not match its body: the body uses an operation of a dialect that the list does not name, or the list names something that is not a dialect. The list is what the block says it uses, so it must be right.
What the compiler reports
E8010{{.*}}vx:[[@LINE+1]]:{{.*}}uses `%r = math.ctpop %a : i32`, but its `dialects` list does not name `math`
The fragments the test suite holds the compiler to. An ellipsis marks text the test does not constrain; the emitted message also carries a source location.
A program that triggers it
//
// Part of the Vx Project, under the Apache License v2.0 with LLVM Exceptions.
// See LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//
// The `dialects` list of an `mlir!` block names the dialects that its operations come from, and
// only real dialects. This program used to compile and print 824.
// The block uses `math.ctpop`, but its list names only `linalg`.
fn count_ones(x : i32) -> i32 {
return mlir!(inputs : (%a = x : i32), returns : i32, dialects : ["linalg"]) {
%r = math.ctpop %a : i32
macro.yield %r : i32
};
}
// The list names a dialect that does not exist, and not `math`.
fn count_zeros(x : i32) -> i32 {
return mlir!(inputs : (%a = x : i32), returns : i32, dialects : ["no_such_dialect"]) {
%r = math.ctlz %a : i32
macro.yield %r : i32
};
}
fn main() -> i32 {
print(count_ones(255));
print(count_zeros(255));
return 0;
}
From tests/frontend/fail/mlir_block_uses_only_the_dialects_it_names.vx, which asserts this diagnostic on every commit.
Related
Contracts and verificationThe chapter covering the rule this code enforces.
All diagnosticsEvery code the compiler can emit, grouped by stage.
E8009A loop invariant that the prover cannot show to hold in the next pass, after the loop body or after a
continue
E8011A pointer clause that is not well formed: valid(p, n), initialized(p, n) or !overlaps(p, q, n), where p and q are raw pointer parameters, and each clause is a requires or an ensures of its own. In an ensures, return can be the pointer. The fact of an assume is one such clause. A call through a function value or a trait would not prove a requires, so a safe function with one cannot be a function value, and a safe method of a trait impl cannot have one. A frees clause is an ensures of its own, ensures frees(p) or ensures !frees(p) for a parameter p, and a method of a trait impl cannot add a !frees that the trait method does not have. An extern function can also ensure a clause about numbers that names only its integer parameters and return.