[llvm-branch-commits] [llvm] [KeyInstr][LoopRotate] Remap atoms of duplicated instructions (PR #133490)
OCHyams wrote: > LGTM (although the hand-written (check-lines that is) tests are more fun and > easier to read) Agreed. I think I must've lost steam around this part of the stack. Fixed. https://github.com/llvm/llvm-project/pull/133490 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [KeyInstr][LoopRotate] Remap atoms of duplicated instructions (PR #133490)
https://github.com/OCHyams updated
https://github.com/llvm/llvm-project/pull/133490
>From a612a99e2b5540c7fca93dd4dd3fcc07cc1cc9fd Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams
Date: Wed, 26 Mar 2025 16:03:41 +
Subject: [PATCH 1/3] [KeyInstr][LoopRotate] Remap atoms of duplicated
instructions
---
.../Transforms/Utils/LoopRotationUtils.cpp| 3 +
.../KeyInstructions/Generic/loop-rotate.ll| 79 +++
2 files changed, 82 insertions(+)
create mode 100644 llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
index c5c4968ef4dcc..73d074029d810 100644
--- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -657,6 +657,9 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
// Otherwise, create a duplicate of the instruction.
Instruction *C = Inst->clone();
+ if (const DebugLoc &DL = C->getDebugLoc())
+mapAtomInstance(DL, ValueMap);
+
C->insertBefore(LoopEntryBranch->getIterator());
++NumInstrsDuplicated;
diff --git a/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
b/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
new file mode 100644
index 0..2a075b7e0f993
--- /dev/null
+++ b/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
UTC_ARGS: --version 5
+; RUN: opt --passes=loop-rotate %s -S -o - | FileCheck %s
+
+;; Check the duplicated store and br get remapped atoms.
+
+@glob = global i32 0
+
+define void @test1() #0 !dbg !5 {
+; CHECK-LABEL: define void @test1(
+; CHECK-SAME: ) #[[ATTR0:[0-9]+]] !dbg [[DBG5:![0-9]+]] {
+; CHECK-NEXT: [[ENTRY:.*]]:
+; CHECK-NEXT:[[ARRAY:%.*]] = alloca [20 x i32], align 16
+; CHECK-NEXT:store i32 0, ptr @glob, align 16, !dbg [[DBG8:![0-9]+]]
+; CHECK-NEXT:br label %[[FOR_BODY:.*]], !dbg [[DBG9:![0-9]+]]
+; CHECK: [[FOR_BODY]]:
+; CHECK-NEXT:[[I_01:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[INC:%.*]],
%[[FOR_BODY]] ]
+; CHECK-NEXT:[[INC]] = add nsw i32 [[I_01]], 1
+; CHECK-NEXT:store i32 0, ptr [[ARRAY]], align 16
+; CHECK-NEXT:store i32 [[INC]], ptr @glob, align 16, !dbg [[DBG10:![0-9]+]]
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[INC]], 100, !dbg
[[DBG11:![0-9]+]]
+; CHECK-NEXT:br i1 [[CMP]], label %[[FOR_BODY]], label %[[FOR_END:.*]],
!dbg [[DBG12:![0-9]+]]
+; CHECK: [[FOR_END]]:
+; CHECK-NEXT:[[ARRAYIDX_LCSSA:%.*]] = phi ptr [ [[ARRAY]], %[[FOR_BODY]] ]
+; CHECK-NEXT:call void @g(ptr [[ARRAYIDX_LCSSA]])
+; CHECK-NEXT:ret void
+;
+entry:
+ %array = alloca [20 x i32], align 16
+ br label %for.cond
+
+for.cond: ; preds = %for.body, %entry
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+ store i32 %i.0, ptr @glob, align 16, !dbg !11
+ %cmp = icmp slt i32 %i.0, 100, !dbg !12
+ br i1 %cmp, label %for.body, label %for.end, !dbg !13
+
+for.body: ; preds = %for.cond
+ %inc = add nsw i32 %i.0, 1
+ store i32 0, ptr %array, align 16
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ %arrayidx.lcssa = phi ptr [ %array, %for.cond ]
+ call void @g(ptr %arrayidx.lcssa)
+ ret void
+}
+
+declare void @g(ptr)
+
+attributes #0 = { nounwind ssp }
+attributes #1 = { noduplicate }
+
+!llvm.dbg.cu = !{!0}
+!llvm.debugify = !{!2, !3}
+!llvm.module.flags = !{!4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer:
"debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+!1 = !DIFile(filename: "test.ll", directory: "/")
+!2 = !{i32 12}
+!3 = !{i32 0}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: null,
file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition |
DISPFlagOptimized, unit: !0)
+!6 = !DISubroutineType(types: !7)
+!7 = !{}
+!11 = !DILocation(line: 4, column: 1, scope: !5, atomGroup: 1, atomRank: 1)
+!12 = !DILocation(line: 5, column: 1, scope: !5, atomGroup: 2, atomRank: 2)
+!13 = !DILocation(line: 6, column: 1, scope: !5, atomGroup: 2, atomRank: 1)
+;.
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C,
file: [[META1:![0-9]+]], producer: "debugify", isOptimized: true,
runtimeVersion: 0, emissionKind: FullDebug)
+; CHECK: [[META1]] = !DIFile(filename: "test.ll", directory: {{.*}})
+; CHECK: [[DBG5]] = distinct !DISubprogram(name: "test1", linkageName:
"test1", scope: null, file: [[META1]], line: 1, type: [[META6:![0-9]+]],
scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]])
+; CHECK: [[META6]] = !DISubroutineType(types: [[META7:![0-9]+]])
+; CHECK: [[META7]] = !{}
+; CHECK: [[DBG8]] = !DILocation(line: 4, column: 1, scope:
[llvm-branch-commits] [llvm] [KeyInstr][LoopRotate] Remap atoms of duplicated instructions (PR #133490)
https://github.com/jmorse edited https://github.com/llvm/llvm-project/pull/133490 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [KeyInstr][LoopRotate] Remap atoms of duplicated instructions (PR #133490)
https://github.com/jmorse approved this pull request. LGTM (although the hand-written tests are more fun and easier to read) https://github.com/llvm/llvm-project/pull/133490 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [KeyInstr][LoopRotate] Remap atoms of duplicated instructions (PR #133490)
https://github.com/OCHyams created
https://github.com/llvm/llvm-project/pull/133490
None
>From 20a853373f9105f54a973b6d933a8010edaf316a Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams
Date: Wed, 26 Mar 2025 16:03:41 +
Subject: [PATCH] [KeyInstr][LoopRotate] Remap atoms of duplicated instructions
---
.../Transforms/Utils/LoopRotationUtils.cpp| 3 +
.../KeyInstructions/Generic/loop-rotate.ll| 79 +++
2 files changed, 82 insertions(+)
create mode 100644 llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
index b07f3451420c7..750a2a3df5f14 100644
--- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -658,6 +658,9 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
// Otherwise, create a duplicate of the instruction.
Instruction *C = Inst->clone();
+ if (const DebugLoc &DL = C->getDebugLoc())
+mapAtomInstance(DL, ValueMap);
+
C->insertBefore(LoopEntryBranch->getIterator());
++NumInstrsDuplicated;
diff --git a/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
b/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
new file mode 100644
index 0..2a075b7e0f993
--- /dev/null
+++ b/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
UTC_ARGS: --version 5
+; RUN: opt --passes=loop-rotate %s -S -o - | FileCheck %s
+
+;; Check the duplicated store and br get remapped atoms.
+
+@glob = global i32 0
+
+define void @test1() #0 !dbg !5 {
+; CHECK-LABEL: define void @test1(
+; CHECK-SAME: ) #[[ATTR0:[0-9]+]] !dbg [[DBG5:![0-9]+]] {
+; CHECK-NEXT: [[ENTRY:.*]]:
+; CHECK-NEXT:[[ARRAY:%.*]] = alloca [20 x i32], align 16
+; CHECK-NEXT:store i32 0, ptr @glob, align 16, !dbg [[DBG8:![0-9]+]]
+; CHECK-NEXT:br label %[[FOR_BODY:.*]], !dbg [[DBG9:![0-9]+]]
+; CHECK: [[FOR_BODY]]:
+; CHECK-NEXT:[[I_01:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[INC:%.*]],
%[[FOR_BODY]] ]
+; CHECK-NEXT:[[INC]] = add nsw i32 [[I_01]], 1
+; CHECK-NEXT:store i32 0, ptr [[ARRAY]], align 16
+; CHECK-NEXT:store i32 [[INC]], ptr @glob, align 16, !dbg [[DBG10:![0-9]+]]
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[INC]], 100, !dbg
[[DBG11:![0-9]+]]
+; CHECK-NEXT:br i1 [[CMP]], label %[[FOR_BODY]], label %[[FOR_END:.*]],
!dbg [[DBG12:![0-9]+]]
+; CHECK: [[FOR_END]]:
+; CHECK-NEXT:[[ARRAYIDX_LCSSA:%.*]] = phi ptr [ [[ARRAY]], %[[FOR_BODY]] ]
+; CHECK-NEXT:call void @g(ptr [[ARRAYIDX_LCSSA]])
+; CHECK-NEXT:ret void
+;
+entry:
+ %array = alloca [20 x i32], align 16
+ br label %for.cond
+
+for.cond: ; preds = %for.body, %entry
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+ store i32 %i.0, ptr @glob, align 16, !dbg !11
+ %cmp = icmp slt i32 %i.0, 100, !dbg !12
+ br i1 %cmp, label %for.body, label %for.end, !dbg !13
+
+for.body: ; preds = %for.cond
+ %inc = add nsw i32 %i.0, 1
+ store i32 0, ptr %array, align 16
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ %arrayidx.lcssa = phi ptr [ %array, %for.cond ]
+ call void @g(ptr %arrayidx.lcssa)
+ ret void
+}
+
+declare void @g(ptr)
+
+attributes #0 = { nounwind ssp }
+attributes #1 = { noduplicate }
+
+!llvm.dbg.cu = !{!0}
+!llvm.debugify = !{!2, !3}
+!llvm.module.flags = !{!4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer:
"debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+!1 = !DIFile(filename: "test.ll", directory: "/")
+!2 = !{i32 12}
+!3 = !{i32 0}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: null,
file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition |
DISPFlagOptimized, unit: !0)
+!6 = !DISubroutineType(types: !7)
+!7 = !{}
+!11 = !DILocation(line: 4, column: 1, scope: !5, atomGroup: 1, atomRank: 1)
+!12 = !DILocation(line: 5, column: 1, scope: !5, atomGroup: 2, atomRank: 2)
+!13 = !DILocation(line: 6, column: 1, scope: !5, atomGroup: 2, atomRank: 1)
+;.
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C,
file: [[META1:![0-9]+]], producer: "debugify", isOptimized: true,
runtimeVersion: 0, emissionKind: FullDebug)
+; CHECK: [[META1]] = !DIFile(filename: "test.ll", directory: {{.*}})
+; CHECK: [[DBG5]] = distinct !DISubprogram(name: "test1", linkageName:
"test1", scope: null, file: [[META1]], line: 1, type: [[META6:![0-9]+]],
scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]])
+; CHECK: [[META6]] = !DISubroutineType(types: [[META7:![0-9]+]])
+; CHECK: [[META7]] = !{}
+; CHECK: [[DBG8]] = !DILocation(line: 4, column: 1, scope:
[llvm-branch-commits] [llvm] [KeyInstr][LoopRotate] Remap atoms of duplicated instructions (PR #133490)
llvmbot wrote:
@llvm/pr-subscribers-llvm-transforms
Author: Orlando Cazalet-Hyams (OCHyams)
Changes
---
Full diff: https://github.com/llvm/llvm-project/pull/133490.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Utils/LoopRotationUtils.cpp (+3)
- (added) llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll (+79)
``diff
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
index b07f3451420c7..750a2a3df5f14 100644
--- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -658,6 +658,9 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
// Otherwise, create a duplicate of the instruction.
Instruction *C = Inst->clone();
+ if (const DebugLoc &DL = C->getDebugLoc())
+mapAtomInstance(DL, ValueMap);
+
C->insertBefore(LoopEntryBranch->getIterator());
++NumInstrsDuplicated;
diff --git a/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
b/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
new file mode 100644
index 0..2a075b7e0f993
--- /dev/null
+++ b/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
UTC_ARGS: --version 5
+; RUN: opt --passes=loop-rotate %s -S -o - | FileCheck %s
+
+;; Check the duplicated store and br get remapped atoms.
+
+@glob = global i32 0
+
+define void @test1() #0 !dbg !5 {
+; CHECK-LABEL: define void @test1(
+; CHECK-SAME: ) #[[ATTR0:[0-9]+]] !dbg [[DBG5:![0-9]+]] {
+; CHECK-NEXT: [[ENTRY:.*]]:
+; CHECK-NEXT:[[ARRAY:%.*]] = alloca [20 x i32], align 16
+; CHECK-NEXT:store i32 0, ptr @glob, align 16, !dbg [[DBG8:![0-9]+]]
+; CHECK-NEXT:br label %[[FOR_BODY:.*]], !dbg [[DBG9:![0-9]+]]
+; CHECK: [[FOR_BODY]]:
+; CHECK-NEXT:[[I_01:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[INC:%.*]],
%[[FOR_BODY]] ]
+; CHECK-NEXT:[[INC]] = add nsw i32 [[I_01]], 1
+; CHECK-NEXT:store i32 0, ptr [[ARRAY]], align 16
+; CHECK-NEXT:store i32 [[INC]], ptr @glob, align 16, !dbg [[DBG10:![0-9]+]]
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[INC]], 100, !dbg
[[DBG11:![0-9]+]]
+; CHECK-NEXT:br i1 [[CMP]], label %[[FOR_BODY]], label %[[FOR_END:.*]],
!dbg [[DBG12:![0-9]+]]
+; CHECK: [[FOR_END]]:
+; CHECK-NEXT:[[ARRAYIDX_LCSSA:%.*]] = phi ptr [ [[ARRAY]], %[[FOR_BODY]] ]
+; CHECK-NEXT:call void @g(ptr [[ARRAYIDX_LCSSA]])
+; CHECK-NEXT:ret void
+;
+entry:
+ %array = alloca [20 x i32], align 16
+ br label %for.cond
+
+for.cond: ; preds = %for.body, %entry
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+ store i32 %i.0, ptr @glob, align 16, !dbg !11
+ %cmp = icmp slt i32 %i.0, 100, !dbg !12
+ br i1 %cmp, label %for.body, label %for.end, !dbg !13
+
+for.body: ; preds = %for.cond
+ %inc = add nsw i32 %i.0, 1
+ store i32 0, ptr %array, align 16
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ %arrayidx.lcssa = phi ptr [ %array, %for.cond ]
+ call void @g(ptr %arrayidx.lcssa)
+ ret void
+}
+
+declare void @g(ptr)
+
+attributes #0 = { nounwind ssp }
+attributes #1 = { noduplicate }
+
+!llvm.dbg.cu = !{!0}
+!llvm.debugify = !{!2, !3}
+!llvm.module.flags = !{!4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer:
"debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+!1 = !DIFile(filename: "test.ll", directory: "/")
+!2 = !{i32 12}
+!3 = !{i32 0}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: null,
file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition |
DISPFlagOptimized, unit: !0)
+!6 = !DISubroutineType(types: !7)
+!7 = !{}
+!11 = !DILocation(line: 4, column: 1, scope: !5, atomGroup: 1, atomRank: 1)
+!12 = !DILocation(line: 5, column: 1, scope: !5, atomGroup: 2, atomRank: 2)
+!13 = !DILocation(line: 6, column: 1, scope: !5, atomGroup: 2, atomRank: 1)
+;.
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C,
file: [[META1:![0-9]+]], producer: "debugify", isOptimized: true,
runtimeVersion: 0, emissionKind: FullDebug)
+; CHECK: [[META1]] = !DIFile(filename: "test.ll", directory: {{.*}})
+; CHECK: [[DBG5]] = distinct !DISubprogram(name: "test1", linkageName:
"test1", scope: null, file: [[META1]], line: 1, type: [[META6:![0-9]+]],
scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]])
+; CHECK: [[META6]] = !DISubroutineType(types: [[META7:![0-9]+]])
+; CHECK: [[META7]] = !{}
+; CHECK: [[DBG8]] = !DILocation(line: 4, column: 1, scope: [[DBG5]],
atomGroup: 3, atomRank: 1)
+; CHECK: [[DBG9]] = !DILocation(line: 6, column: 1, scope: [[DBG5]],
atomGroup: 4, atomRank: 1)
+; CHECK: [[DBG10]] = !DILocation(line: 4, column: 1, scope
[llvm-branch-commits] [llvm] [KeyInstr][LoopRotate] Remap atoms of duplicated instructions (PR #133490)
https://github.com/OCHyams ready_for_review https://github.com/llvm/llvm-project/pull/133490 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [KeyInstr][LoopRotate] Remap atoms of duplicated instructions (PR #133490)
llvmbot wrote:
@llvm/pr-subscribers-debuginfo
Author: Orlando Cazalet-Hyams (OCHyams)
Changes
---
Full diff: https://github.com/llvm/llvm-project/pull/133490.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Utils/LoopRotationUtils.cpp (+3)
- (added) llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll (+79)
``diff
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
index b07f3451420c7..750a2a3df5f14 100644
--- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -658,6 +658,9 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
// Otherwise, create a duplicate of the instruction.
Instruction *C = Inst->clone();
+ if (const DebugLoc &DL = C->getDebugLoc())
+mapAtomInstance(DL, ValueMap);
+
C->insertBefore(LoopEntryBranch->getIterator());
++NumInstrsDuplicated;
diff --git a/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
b/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
new file mode 100644
index 0..2a075b7e0f993
--- /dev/null
+++ b/llvm/test/DebugInfo/KeyInstructions/Generic/loop-rotate.ll
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
UTC_ARGS: --version 5
+; RUN: opt --passes=loop-rotate %s -S -o - | FileCheck %s
+
+;; Check the duplicated store and br get remapped atoms.
+
+@glob = global i32 0
+
+define void @test1() #0 !dbg !5 {
+; CHECK-LABEL: define void @test1(
+; CHECK-SAME: ) #[[ATTR0:[0-9]+]] !dbg [[DBG5:![0-9]+]] {
+; CHECK-NEXT: [[ENTRY:.*]]:
+; CHECK-NEXT:[[ARRAY:%.*]] = alloca [20 x i32], align 16
+; CHECK-NEXT:store i32 0, ptr @glob, align 16, !dbg [[DBG8:![0-9]+]]
+; CHECK-NEXT:br label %[[FOR_BODY:.*]], !dbg [[DBG9:![0-9]+]]
+; CHECK: [[FOR_BODY]]:
+; CHECK-NEXT:[[I_01:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[INC:%.*]],
%[[FOR_BODY]] ]
+; CHECK-NEXT:[[INC]] = add nsw i32 [[I_01]], 1
+; CHECK-NEXT:store i32 0, ptr [[ARRAY]], align 16
+; CHECK-NEXT:store i32 [[INC]], ptr @glob, align 16, !dbg [[DBG10:![0-9]+]]
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[INC]], 100, !dbg
[[DBG11:![0-9]+]]
+; CHECK-NEXT:br i1 [[CMP]], label %[[FOR_BODY]], label %[[FOR_END:.*]],
!dbg [[DBG12:![0-9]+]]
+; CHECK: [[FOR_END]]:
+; CHECK-NEXT:[[ARRAYIDX_LCSSA:%.*]] = phi ptr [ [[ARRAY]], %[[FOR_BODY]] ]
+; CHECK-NEXT:call void @g(ptr [[ARRAYIDX_LCSSA]])
+; CHECK-NEXT:ret void
+;
+entry:
+ %array = alloca [20 x i32], align 16
+ br label %for.cond
+
+for.cond: ; preds = %for.body, %entry
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+ store i32 %i.0, ptr @glob, align 16, !dbg !11
+ %cmp = icmp slt i32 %i.0, 100, !dbg !12
+ br i1 %cmp, label %for.body, label %for.end, !dbg !13
+
+for.body: ; preds = %for.cond
+ %inc = add nsw i32 %i.0, 1
+ store i32 0, ptr %array, align 16
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ %arrayidx.lcssa = phi ptr [ %array, %for.cond ]
+ call void @g(ptr %arrayidx.lcssa)
+ ret void
+}
+
+declare void @g(ptr)
+
+attributes #0 = { nounwind ssp }
+attributes #1 = { noduplicate }
+
+!llvm.dbg.cu = !{!0}
+!llvm.debugify = !{!2, !3}
+!llvm.module.flags = !{!4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer:
"debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+!1 = !DIFile(filename: "test.ll", directory: "/")
+!2 = !{i32 12}
+!3 = !{i32 0}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: null,
file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition |
DISPFlagOptimized, unit: !0)
+!6 = !DISubroutineType(types: !7)
+!7 = !{}
+!11 = !DILocation(line: 4, column: 1, scope: !5, atomGroup: 1, atomRank: 1)
+!12 = !DILocation(line: 5, column: 1, scope: !5, atomGroup: 2, atomRank: 2)
+!13 = !DILocation(line: 6, column: 1, scope: !5, atomGroup: 2, atomRank: 1)
+;.
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C,
file: [[META1:![0-9]+]], producer: "debugify", isOptimized: true,
runtimeVersion: 0, emissionKind: FullDebug)
+; CHECK: [[META1]] = !DIFile(filename: "test.ll", directory: {{.*}})
+; CHECK: [[DBG5]] = distinct !DISubprogram(name: "test1", linkageName:
"test1", scope: null, file: [[META1]], line: 1, type: [[META6:![0-9]+]],
scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]])
+; CHECK: [[META6]] = !DISubroutineType(types: [[META7:![0-9]+]])
+; CHECK: [[META7]] = !{}
+; CHECK: [[DBG8]] = !DILocation(line: 4, column: 1, scope: [[DBG5]],
atomGroup: 3, atomRank: 1)
+; CHECK: [[DBG9]] = !DILocation(line: 6, column: 1, scope: [[DBG5]],
atomGroup: 4, atomRank: 1)
+; CHECK: [[DBG10]] = !DILocation(line: 4, column: 1, scope: [[DB
[llvm-branch-commits] [llvm] [KeyInstr][LoopRotate] Remap atoms of duplicated instructions (PR #133490)
OCHyams wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/133490?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#133492** https://app.graphite.dev/github/pr/llvm/llvm-project/133492?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133491** https://app.graphite.dev/github/pr/llvm/llvm-project/133491?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133490** https://app.graphite.dev/github/pr/llvm/llvm-project/133490?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/133490?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#133489** https://app.graphite.dev/github/pr/llvm/llvm-project/133489?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133488** https://app.graphite.dev/github/pr/llvm/llvm-project/133488?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133487** https://app.graphite.dev/github/pr/llvm/llvm-project/133487?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133486** https://app.graphite.dev/github/pr/llvm/llvm-project/133486?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133485** https://app.graphite.dev/github/pr/llvm/llvm-project/133485?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133484** https://app.graphite.dev/github/pr/llvm/llvm-project/133484?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133483** https://app.graphite.dev/github/pr/llvm/llvm-project/133483?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133482** https://app.graphite.dev/github/pr/llvm/llvm-project/133482?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133481** https://app.graphite.dev/github/pr/llvm/llvm-project/133481?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133480** https://app.graphite.dev/github/pr/llvm/llvm-project/133480?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133479** https://app.graphite.dev/github/pr/llvm/llvm-project/133479?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133478** https://app.graphite.dev/github/pr/llvm/llvm-project/133478?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#133477** https://app.graphite.dev/github/pr/llvm/llvm-project/133477?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/133490 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
