Codecheck b3 magic numbers - #1491
Draft
KurrinQu wants to merge 6 commits into
Draft
Conversation
Co-authored-by: andodo<sunkexin3@huawei.com>
# message auto-generated for no-merge-commit merge:
!72 merge cleancode-260908 into master
Cleancode - huge method.
Created-by: andodo
Commit-by: andodo
Merged-by: cann-robot
Description:
<!-- 感谢您的合入申请! -->
### 当前PR是否有AI参与:
[x] 否
[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :
### PR功能描述 / 为什么需要这个合入**:
<!-- 本 PR 做了什么,为什么需要 / What does this PR do and why -->
超大函数 huge method
- modified: include/PTO/Transforms/InsertSync/InsertSyncAnalysis.h
- modified: lib/PTO/IR/VPTOAddressSemantics.cpp
- modified: lib/PTO/Transforms/BufidSync/BufidSyncAnalysis.h
- modified: lib/PTO/Transforms/BufidSync/BufidSyncCodegen.cpp
- modified: lib/PTO/Transforms/BufidSync/BufidSyncCodegen.h
- modified: lib/PTO/Transforms/BufidSync/BufidSyncPass.cpp
- modified: lib/PTO/Transforms/CppPostprocess.cpp
- modified: lib/PTO/Transforms/InferPTOMemScope.cpp
- modified: lib/PTO/Transforms/InsertSync/InsertSyncAnalysis.cpp
- modified: lib/PTO/Transforms/PTOA5NormalizeTMovPass.cpp
- modified: lib/PTO/Transforms/PTOCanonicalizeIR.cpp
- modified: lib/PTO/Transforms/PTOInstantiateAndInlineOpLib.cpp
- modified: lib/PTO/Transforms/PTONormalizeUncoveredTileSections.cpp
- modified: lib/PTO/Transforms/PTOPrintAddressAnalysis.cpp
- modified: lib/PTO/Transforms/VMILayoutSupport.cpp
- modified: lib/PTO/Transforms/VPTOGuardedLICM.cpp
- modified: lib/PTO/Transforms/VPTOPtrNormalize.cpp
- modified: tools/ptoas/ObjectEmission.cpp
See merge request: cann/pto-as!72
Co-authored-by: lishengtao<2510737554@qq.com> Co-authored-by: TaoTao-real<TaoTao-real@users.noreply.github.com> # message auto-generated for no-merge-commit merge: !18 merge codex/codecheck-new-repo-20260904 into master refactor: migrate PTO IR codecheck fixes to the new repository Created-by: taotao_real Commit-by: lishengtao;TaoTao-real Merged-by: cann-robot Description: ## Summary Migrate the existing PTO IR codecheck remediation to the new cann/pto-as repository, based on master da2a63b (LLVM 19), and address additional findings from the 2026-09-04 scan. - Preserve the single translation unit while splitting the original PTO.cpp implementation. - Add divisor guards and remove side-effecting assertions. - Extract focused helpers for PTO type, TDivS, TGather, TScatter and communication collective parsing; share mask/axis and collective parser/printer logic. - Replace namespace-wide using directives with explicit names and make the zero-divisor check explicit. - Add eight malformed-input regression cases and generic-IR checks for gather operand ordering. ## Motivation and remaining scope The previous repository was renamed to cann/pto-as_back. This PR targets the new repository (project 10737902). Previous MR: https://gitcode.com/cann/pto-as_back/merge_requests/178 GitHub counterpart (not yet synchronized with this latest follow-up): hw-native-sys#1434 The latest supplied scan contains 236 unresolved findings: 3 severe and 233 structural findings. This follow-up addresses the three severe sites and a subset of parser complexity/duplication findings; it does NOT claim all structural findings are fixed. Removal counts require the external rescan. The previous /compile run reported codecheck FAILED even though both architecture compile jobs and the other checks succeeded. ## Validation at d80075093 - git diff --check: PASS. - LLVM 19.1.7 PTOIR target build: PASS. - Differential parser/verifier run across all 674 test/lit/pto input files: identical output, diagnostics and exit status to the pre-follow-up baseline. This is parser-only validation, not execution of every lit RUN pipeline. - Eight new malformed-input cases with --verify-diagnostics: PASS. - Generic-IR FileCheck for all three gather forms and operand segment order: PASS. - Full local ptoas suite unavailable with this LLVM build (missing Bisheng SimtEntry support); external CI and fresh codecheck results remain pending. ## Risk / Rollback No intended IR syntax, diagnostics, operand ordering or codegen changes. Review parser extraction and explicit imported names. Revert d80075093 to roll back this follow-up; the three earlier migration commits remain separate. See merge request: cann/pto-as!18
… enum class, data clumps) Mechanical remediation findings from the static-analysis report: - G.FMT.11 (20): add braces around single-statement if/for bodies in LoweringSyncToPipe, LowerPTOToUBufOps, PTOA5NormalizeTMovPass, PTOMaterializeTileOpSections, PTONarrowVPTOLoopCounters, PTOPlanMemoryModern, PTOResolveReservedBuffersPass - G.INC.07 (3): put each file's own header first in RemoveRedundantSync, SyncCommon, SyncEventIdAllocation - G.INC.08 (2): move the GEN_PASS_DEF include block above `using namespace mlir;` in InsertTemplateAttributes and LowerPTOToUBufOps - G.ENU.01 (1): convert TileArgumentEffect to enum class in PTOMaterializeTileOpSections - data clumps (7) in LowerPTOToUBufOps: delete the unused vadd/vsub/vmul/vdiv wrappers and factor the shared tile-address prologue of lowerBinaryOpCommon/lowerXorOpCommon/lowerShiftOpCommon into one lowerTilePtrs helper The G.PRE.02 finding was in PTOPlanMemory.cpp, removed in the previous commit. No behavior change; full check-pto suite (1845 tests) passes. Co-Authored-By: Claude Code <noreply@anthropic.com>
…ants G.CNS.02 (30 findings): use mlir::pto::kValueN constants from PTO/Support/CodeConstants.h for integer widths, SmallVector inline capacities, and pattern benefits, instead of bare literals: - LowerPTOToUBufOps: vgather byte-stride 8, i16/i32 width checks - PTOConvertSCFToCFWithLoopHintsPass: SmallVector capacities, benefit 2 - PTOExpandSoftLib: i16/i32 width checks - PTOInstantiateAndInlineOpLib: SmallVector capacities - PTOMaterializeImplicitTmp: i8 width check - PTOMaterializeTileOpSections: SmallVector capacities, trace depth 64, and valid-shape pair/rank counts (kValidShapeArgsPerTile, kValidShapeRank) - PTONarrowVPTOLoopCounters: i16 width threshold - PTOPrintAddressAnalysis: report buffer size (kValue1024, new) - PTOResolveBufferSelect: kFractalSlayoutRowMajor for the sl==2 branch No behavior change; full check-pto suite (1845 tests) passes. Co-Authored-By: Claude Code <noreply@anthropic.com>
Address review finding on !26 (cross-layer-sync): three design docs still referenced the removed files/flag. - largest-first-fit-four-gates-memplan-design: add a status note that the legacy memplan and --plan-memory-impl are removed and PTOPlanMemoryModern is the only implementation; describe --plan-memory-order-by-size as explicit opt-in (default false, matching the default pipeline); strike the two legacy-scoped non-goals; reword the remaining historical mentions - implicit-tmp-materialization-design: drop the --plan-memory-impl=legacy/modern RUN examples, cover the default path and --plan-memory-order-by-size instead; drop dual-planner wording - multi-buffer-explicit-design: point the N-way multi-slot planning row at PTOPlanMemoryModern.cpp (PTOPlanMemory.cpp/.h removed) Co-Authored-By: Claude Code <noreply@anthropic.com>
Name the bare numeric literals whose semantics were confirmed against the pto-isa definitions (pto/common/type.hpp, docs/isa/*.md) or that already had named constants elsewhere in the tree: - PTOResolveBufferSelect: add kBLayout*/kSlayout* constants mirroring the pto-isa layout enums and use them for the bl/sl comparisons; fix the previously misnamed kFractalSlayoutRowMajor (value 2 is SLayout::ColMajor, not RowMajor); add kDim0/kDim1 for tile row/col dimension indices - PTOMaterializeTileOpSections: kDim0/kDim1 for valid-shape indices - PTOMaterializeImplicitTmp: name the TCI tmp sizes (768B/1792B minimum per docs/isa/TCI.md), the TTRANS row-stride/block constants (docs/isa/TTRANS.md), and the TCVT sizing constants (docs/isa/ TCVT.md); share kRepeatMax = 255 across the repeat-limit checks - LowerPTOToUBufOps: drop the local duplicate of the file-level kRepeatMax in the vgatherb path No behavior change; full check-pto suite passes (1867/1868, 1 unsupported). Co-Authored-By: Claude Code <noreply@anthropic.com>
KurrinQu
force-pushed
the
codecheck-b3-magic-numbers
branch
from
September 9, 2026 05:19
48d1bde to
02727f5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.