Skip to content

Fix compiler warnings#611

Draft
castigli wants to merge 1 commit intohw-native-sys:mainfrom
castigli:fix-compilation-warnings
Draft

Fix compiler warnings#611
castigli wants to merge 1 commit intohw-native-sys:mainfrom
castigli:fix-compilation-warnings

Conversation

@castigli
Copy link
Copy Markdown
Contributor

@castigli castigli commented Apr 30, 2026

This PR fixes compiler warnings making it easier to fix errors and reducing noise.
Most of the fixes belong to 4 categories

  • type mismatch
  • deprecated mlir cast style
  • cases not handeld in switch statements
  • unused variables/functions

Perhaps is worth considering adding a "error on warning" in the CI.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a broad set of code cleanups and modernization updates, including transitioning to the latest MLIR casting APIs, removing unused variables, and addressing compiler warnings through explicit casts and [[maybe_unused]] attributes. It also enhances safety by adding llvm_unreachable to incomplete switch blocks and refining sign extension logic. The review feedback identifies opportunities to further clean the code by removing redundant attributes, deleting unused variables rather than suppressing warnings, and using more targeted techniques to handle virtual function hiding.

Comment thread lib/PTO/IR/PTO.cpp
// =============================================================================

static void printLayout(AsmPrinter &printer, Attribute layoutAttr) {
[[maybe_unused]] [[maybe_unused]] static void printLayout(AsmPrinter &printer, Attribute layoutAttr) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The [[maybe_unused]] attribute is specified twice on this line. One is sufficient.

Suggested change
[[maybe_unused]] [[maybe_unused]] static void printLayout(AsmPrinter &printer, Attribute layoutAttr) {
[[maybe_unused]] static void printLayout(AsmPrinter &printer, Attribute layoutAttr) {

Comment on lines 5569 to +5570
auto u32Ty = emitc::OpaqueType::get(ctx, "uint32_t");
auto u64Ty = emitc::OpaqueType::get(ctx, "uint64_t");
[[maybe_unused]] auto u64Ty = emitc::OpaqueType::get(ctx, "uint64_t");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable u64Ty appears to be unused. Instead of suppressing the warning with [[maybe_unused]], it is better to remove the unused variable entirely to keep the code clean.

Suggested change
auto u32Ty = emitc::OpaqueType::get(ctx, "uint32_t");
auto u64Ty = emitc::OpaqueType::get(ctx, "uint64_t");
[[maybe_unused]] auto u64Ty = emitc::OpaqueType::get(ctx, "uint64_t");
auto u32Ty = emitc::OpaqueType::get(ctx, "uint32_t");

Comment on lines +12 to +13
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
// https://discourse.llvm.org/t/matchandrewrite-hiding-virtual-functions/84933/8
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While suppressing -Woverloaded-virtual file-wide reduces noise, it can hide legitimate issues where a virtual function is unintentionally hidden. As suggested in the linked LLVM discourse thread, a more targeted approach is to add using OpConversionPattern<SourceOp>::matchAndRewrite; (or the appropriate base class) within each pattern class that triggers the warning. This resolves the name hiding while keeping the diagnostic active for the rest of the file.

@reedhecre
Copy link
Copy Markdown

Codex Review

该评论由 review 机器人自动更新。

  • PR: Fix compiler warnings #611 Fix compiler warnings
  • Author: castigli
  • Base/Head: main / fix-compilation-warnings
  • Head SHA: 308fc7b37434
  • Trigger: 检测到新的 open PR
  • Generated At: 2026-04-30T14:19:27Z
  • Status: completed

Summary

PR #611 contains 1 correctness issue in EmitC lowering for SCALING reinterpret-casts.

Findings

  1. P2 SCALING reinterpret-casts are hardcoded to `TileType::Vec` lib/PTO/Transforms/PTOToEmitC.cpp:6252

The new switch case added here folds AddressSpace::SCALING into the TileType::Vec path. In this same file, SCALING/fbuf is otherwise modeled as TileType::Scaling (for example in the existing pointer-cast and tile-token mappings), so a memref.reinterpret_cast on a SCALING tile will emit the wrong tile kind. That can generate invalid code or wrong runtime accesses for view/reinterpret-cast lowering on SCALING buffers. This warning fix should add a dedicated TileType::Scaling case instead of mapping SCALING to Vec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants