This is the authoritative PR review checklist for rocMLIR. Reviewers -- human and automated -- categorize findings against the Critical / Major / Minor tiers below; a Critical finding here is one of the bullets in the "Critical" section, a Major finding is one of the bullets in "Major", etc.
When you contribute, run git clang-format --diff origin/develop
(or upstream/develop if you've forked and named the ROCm/rocMLIR
remote upstream) and self-review your diff against this checklist.
When you review, cite the specific bullet so the author can look up
the rationale.
- LLVM Coding Standards -- the authoritative style guide; everything below derives from or extends it.
- MLIR Developer Guide
-- the one naming-convention deviation (
camelBackfor variables, parameters, and class members instead of LLVM's traditionalCapitalized) lives there. .clang-format(LLVM base style) and.clang-tidyat the repo root -- machine-enforced subset; the premergeclang-formatjob runsgit clang-format --diff origin/develop(CI's checkout always names theROCm/rocMLIRremoteorigin) and fails on any non-empty diff.- Python helpers follow
yapfandflake8; format withyapf -i <files>and lint withflake8 <files>before committing.
- Unreleased hardware codenames, unannounced chip IDs, or NDA features in code, comments, commits, or docs.
- C++ exceptions (
throw,try/catch); useLogicalResult/emitOpError/signalPassFailureinstead. - RTTI (
dynamic_cast,typeid); use LLVM'sisa/cast/dyn_cast. - Magic sentinel values (
-1,nullptr) to signal failure; useFailureOr<>instead. #include <iostream>; use LLVM'sraw_ostream.using namespace stdat file scope or in headers.- Static constructors/destructors (global objects with non-trivial ctors/dtors).
- Committed temp/generated files: build artifacts,
*.pyc, editor swap files, secrets, profiler output, tuning DBs that don't belong in the repo. - Breaking IR or C-API changes without documentation or a coordinated MIGraphX update.
- DRY/YAGNI/KISS violations: redundant code, dead code, unnecessarily complex algorithms, opportunities to use existing upstream LLVM/MLIR utilities instead of custom code.
- Raw
new/delete; use MLIR allocation utilities,std::unique_ptr, or arena ownership. - Inheritance where composition would do; CRTP only where MLIR/LLVM requires it.
std::string/std::vectorfor non-owning parameters whereStringRef/ArrayRef/MutableArrayRefwould suffice.std::vectorfor small local collections whereSmallVectoris preferred.std::map/std::unordered_mapwherellvm::DenseMapis preferred.- Missing
assertwith descriptive message on non-trivial preconditions; usellvm_unreachablefor impossible paths (notassert(false)). - C-style casts; use
static_cast/const_cast. - Visibility leaks: file-local helpers without
staticor anonymous namespace. default:label in a switch over an enum that already covers every case (defeats-Wswitch).std::sortinstead ofllvm::sort-- LLVM coding standard.llvm::sortwrapsstd::sortand, underEXPENSIVE_CHECKSbuilds, deterministically shuffles the input first to surface order-dependent bugs that would otherwise hide behind a libc++/libstdc++ implementation that happens to preserve input order. (Note: neither call is stable; if equal elements must keep their relative order, the fix isllvm::stable_sort, notllvm::sort. Don't suggestllvm::sortas a "stability" fix.)- Naming: classes not
CamelCase, functions/vars notcamelBack. - New op without
hasVerifier = 1and averify()implementation. - New pass or op without positive E2E coverage and both positive and negative Lit tests with FileCheck.
- New optimization without a FileCheck test asserting the expected IR is produced.
LogicalResultreturned but ignored (not checked withfailed(...)).librockcompiler_deps.cmakenot updated when dependencies change.- License header missing on a new
.cpp/.h/.pyfile (SPDXApache-2.0 WITH LLVM-exception; LLVM Project convention is no per-file copyright -- see the License-header reference below for the exact template). external/changes mixed into the same commit as rocMLIR changes (must be separate, prefixed[EXTERNAL]).TODOwithout an issue reference (TODO(#issue-number)).- Architecture coverage: a new op/pass that should work on multiple GPU archs (gfx90a, gfx942, gfx950) is implemented for only one.
- Data type coverage: an op that should support multiple dtypes
(f16/bf16/f32/f8/i8/i4) silently falls through for unhandled dtypes
instead of returning
emitOpError. - Fusion-related changes that lack tests in
mlir/test/fusion/ormlir/test/fusion/pr-e2e/. - Custom CMake targets that bypass
add_rocmlir_dialect_library/add_rocmlir_conversion_library/add_rocmlir_tool/add_rocmlir_unittest. - Downstream MIGraphX impact: changes to public IR, C API, or
librockcompilerthat need coordinated updates and aren't called out in the PR description.
- Include order wrong: should be main module header, then local/private, then MLIR/LLVM, then stdlib (each group sorted lexicographically).
- Header lacks self-contained guards.
- Comments not English prose with proper capitalization; missing
///Doxygen on public APIs. - Missing early returns;
elseafterreturn. - Postincrement (
i++) where preincrement (++i) would do. for (auto it = c.begin(); it != c.end(); ++it)re-evaluatingend(); prefer range-based for.- Braces around single-statement bodies (omit them); missing braces around multi-statement bodies.
autowhere the type isn't obvious; missingauto &/auto *causing copies.inlineon a function defined inside the class body (already implicit).- Spaces before parentheses in function calls (allowed only in control flow).
- File missing trailing newline; trailing whitespace.
LLVM_DEBUGblock missing#define DEBUG_TYPE "rock-..."at the top of the file.- Lit test missing
// RUN:line,-verify-diagnostics, orFileCheckprefix coverage. - New
.tomlE2E config not registered inmlir/test/e2e/CMakeLists.txt.
C++/header files (.cpp, .h):
//===- FileName.cpp - Brief description ----------------------------------===//
//
// Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
Python files (.py):
# Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Checklist on every new file:
- Header is present.
- License attribution line is exactly
Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.(no per-file copyright -- by LLVM Project convention the repository-root license file is the single source; in this repo that file isLICENSE, in the upstream LLVM monorepo it isLICENSE.TXT). - SPDX identifier is exactly
Apache-2.0 WITH LLVM-exception.