[llvm] [CodeGen] Ignore `ANNOTATION_LABEL` in scheduler (PR #190499)
Trung Nguyen via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 5 19:35:13 PDT 2026
https://github.com/trungnt2910 updated https://github.com/llvm/llvm-project/pull/190499
>From 3b3141a8e6c8cfc92d5db8c67d228cea2c123ab5 Mon Sep 17 00:00:00 2001
From: Trung Nguyen <trungnt282910 at gmail.com>
Date: Sun, 5 Apr 2026 11:48:43 +1000
Subject: [PATCH] [CodeGen] Ignore `ANNOTATION_LABEL` in scheduler
This fixes a crash in `clang` for `armv7` targets when optimizations are
enabled.
Fixes #190497
---
.../SelectionDAG/ScheduleDAGRRList.cpp | 1 +
llvm/test/CodeGen/ARM/pr190497.ll | 39 +++++++++++++++++++
2 files changed, 40 insertions(+)
create mode 100644 llvm/test/CodeGen/ARM/pr190497.ll
diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
index 12fc26d949581..bc747d250afae 100644
--- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
@@ -712,6 +712,7 @@ void ScheduleDAGRRList::EmitNode(SUnit *SU) {
case ISD::CopyToReg:
case ISD::CopyFromReg:
case ISD::EH_LABEL:
+ case ISD::ANNOTATION_LABEL:
// Noops don't affect the scoreboard state. Copies are likely to be
// removed.
return;
diff --git a/llvm/test/CodeGen/ARM/pr190497.ll b/llvm/test/CodeGen/ARM/pr190497.ll
new file mode 100644
index 0000000000000..e430f773338f5
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/pr190497.ll
@@ -0,0 +1,39 @@
+; RUN: llc -mtriple=thumbv7-windows-msvc -O1 < %s | FileCheck %s
+
+; We used to crash on ARM with optimizations on.
+
+; C source:
+; void foo(void) {
+; __annotation(L"annotation");
+; }
+
+define void @foo() !dbg !8 {
+entry:
+; CHECK-LABEL: foo:
+; CHECK: {{.*}}annotation0:
+; CHECK: bx lr
+ call void @llvm.codeview.annotation(metadata !12), !dbg !13
+ ret void, !dbg !14
+}
+
+declare void @llvm.codeview.annotation(metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "pr190497.c", directory: ".")
+!2 = !{i32 2, !"CodeView", i32 1}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !9, unit: !0)
+!9 = !DISubroutineType(types: !10)
+!10 = !{null}
+!12 = !{!"annotation"}
+!13 = !DILocation(line: 2, scope: !8)
+!14 = !DILocation(line: 3, scope: !8)
+
+; CHECK: .short 4121 @ Record kind: S_ANNOTATION
+; CHECK-NEXT: .secrel32 {{.*}}annotation0
+; CHECK-NEXT: .secidx {{.*}}annotation0
+; CHECK-NEXT: .short 1
+; CHECK-NEXT: .asciz "annotation"
More information about the llvm-commits
mailing list