[all-commits] [llvm/llvm-project] 178457: [mlir][LLVMIR] Fix loop follow-up metadata import ...

ArdenYang via All-commits all-commits at lists.llvm.org
Sun Sep 20 23:58:53 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1784573db1506040f89bc476fc490ce104206380
      https://github.com/llvm/llvm-project/commit/1784573db1506040f89bc476fc490ce104206380
  Author: ArdenYang <ardenyang0125 at gmail.com>
  Date:   2026-09-21 (Mon, 21 Sep 2026)

  Changed paths:
    M mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp
    M mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp
    M mlir/test/Target/LLVMIR/Import/import-failure.ll
    M mlir/test/Target/LLVMIR/Import/metadata-loop.ll
    M mlir/test/Target/LLVMIR/loop-metadata.mlir

  Log Message:
  -----------
  [mlir][LLVMIR] Fix loop follow-up metadata import and export (#223376)

## Problem

MLIR currently exports loop follow-up metadata by wrapping its
properties in an additional self-referencing loop ID:

```llvm
!1 = !{!"llvm.loop.unroll.followup_unrolled", !2}
!2 = distinct !{!2, !3}
!3 = !{!"llvm.loop.mustprogress"}
```

LLVM expects the properties directly after the follow-up name:

```llvm
!1 = !{!"llvm.loop.unroll.followup_unrolled", !3}
!3 = !{!"llvm.loop.mustprogress"}
```

`makeFollowupLoopID` copies the follow-up operands without unwrapping a
nested loop ID. Consequently, properties such as
`llvm.loop.mustprogress` inside the extra wrapper are not recognized as
properties of the resulting loop.

## Changes

- Export follow-up properties directly, excluding the temporary loop
ID's self-reference.
- Update import to read direct property lists.
- Preserve explicitly empty follow-ups, multiple properties, nested
follow-ups, and debug locations.
- Diagnose malformed follow-up metadata and detect cycles to prevent
infinite recursion.

An explicitly empty follow-up is different from an absent follow-up: it
specifies an empty configuration instead of leaving the transformation
to use its default follow-up attributes. Import therefore preserves it
as a non-null, empty `LoopAnnotationAttr`.

This patch corrects MLIR's representation of existing LLVM follow-up
metadata. It does not change LLVM's transformation policies or introduce
automatic attribute inheritance.

## Testing

Built `mlir-translate`, `FileCheck`, `count`, and `not` on Linux using a
Release build with assertions enabled.

All three targeted regression tests passed:

- `mlir/test/Target/LLVMIR/loop-metadata.mlir`
- `mlir/test/Target/LLVMIR/Import/metadata-loop.ll`
- `mlir/test/Target/LLVMIR/Import/import-failure.ll`

`git diff --check` also passed. The full MLIR test suite was not run.

Assisted-by: OpenAI Codex

---------

Co-authored-by: yangzihan <yangzihan at sunmmio.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list