[llvm] 2ccc678 - [AArch64] Fix position of nop inserted for +fix-cortex-a53-835769 under debug. (#224830)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 00:42:39 PDT 2026
Author: David Green
Date: 2026-09-22T08:42:33+01:00
New Revision: 2ccc678a64ecd52eace68e363f4d47935a56fb57
URL: https://github.com/llvm/llvm-project/commit/2ccc678a64ecd52eace68e363f4d47935a56fb57
DIFF: https://github.com/llvm/llvm-project/commit/2ccc678a64ecd52eace68e363f4d47935a56fb57.diff
LOG: [AArch64] Fix position of nop inserted for +fix-cortex-a53-835769 under debug. (#224830)
Make sure that the position of the nop added for +fix-cortex-a53-835769
is not dependant on debug instructions at the start of the block.
Fixes #224661
Added:
llvm/test/CodeGen/AArch64/aarch64-fix-cortex-a53-835769-debug.ll
Modified:
llvm/lib/Target/AArch64/AArch64A53Fix835769.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64A53Fix835769.cpp b/llvm/lib/Target/AArch64/AArch64A53Fix835769.cpp
index b5709b74f1eaf..bead303cc4c6d 100644
--- a/llvm/lib/Target/AArch64/AArch64A53Fix835769.cpp
+++ b/llvm/lib/Target/AArch64/AArch64A53Fix835769.cpp
@@ -192,7 +192,7 @@ static void insertNopBeforeInstruction(MachineBasicBlock &MBB, MachineInstr* MI,
const TargetInstrInfo *TII) {
// If we are the first instruction of the block, put the NOP at the end of
// the previous fallthrough block
- if (MI == &MBB.front()) {
+ if (MI == MBB.getFirstNonDebugInstr()) {
MachineInstr *I = getLastNonPseudo(MBB, TII);
assert(I && "Expected instruction");
DebugLoc DL = I->getDebugLoc();
diff --git a/llvm/test/CodeGen/AArch64/aarch64-fix-cortex-a53-835769-debug.ll b/llvm/test/CodeGen/AArch64/aarch64-fix-cortex-a53-835769-debug.ll
new file mode 100644
index 0000000000000..1a646960a3cc0
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/aarch64-fix-cortex-a53-835769-debug.ll
@@ -0,0 +1,56 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc < %s -mtriple aarch64 -mattr=+fix-cortex-a53-835769 | FileCheck %s
+
+declare void @llvm.dbg.label(metadata)
+
+define i64 @a53_debug_front(i64 %a, i64 %b, ptr nocapture readonly %c) nounwind readonly !dbg !4 {
+; CHECK-LABEL: a53_debug_front:
+; CHECK: .Lfunc_begin0:
+; CHECK-NEXT: .cfi_sections .debug_frame
+; CHECK-NEXT: .cfi_startproc
+; CHECK-NEXT: // %bb.0: // %entry
+; CHECK-NEXT: .file 1 "/" "a53-debug-front.c"
+; CHECK-NEXT: .loc 1 2 17 prologue_end // a53-debug-front.c:2:17
+; CHECK-NEXT: ldr x8, [x2]
+; CHECK-NEXT: nop
+; CHECK-NEXT: .Ltmp0: // Block address taken
+; CHECK-NEXT: // %bb.1: // %block1
+; CHECK-NEXT: .Ltmp1:
+; CHECK-NEXT: //DEBUG_LABEL: a53_debug_front:block1
+; CHECK-NEXT: .loc 1 5 3 // a53-debug-front.c:5:3
+; CHECK-NEXT: madd x8, x8, x1, x0
+; CHECK-NEXT: adrp x9, .Ltmp0
+; CHECK-NEXT: add x9, x9, :lo12:.Ltmp0
+; CHECK-NEXT: add x0, x9, x8
+; CHECK-NEXT: .loc 1 6 3 // a53-debug-front.c:6:3
+; CHECK-NEXT: ret
+; CHECK-NEXT: .Ltmp2:
+entry:
+ %loaded = load i64, ptr %c, align 8, !dbg !9
+ br label %block1, !dbg !10
+
+block1:
+ call void @llvm.dbg.label(metadata !8), !dbg !11
+ %mul = mul nsw i64 %loaded, %b, !dbg !12
+ %add = add nsw i64 %mul, %a, !dbg !12
+ %address = ptrtoint ptr blockaddress(@a53_debug_front, %block1) to i64, !dbg !12
+ %ret = add nsw i64 %address, %add, !dbg !12
+ ret i64 %ret, !dbg !13
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "ccmdv2", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+!1 = !DIFile(filename: "a53-debug-front.c", directory: "/")
+!2 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed)
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "a53_debug_front", scope: !1, file: !1, line: 1, type: !5, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !7)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!2, !2, !2, !2}
+!7 = !{}
+!8 = !DILabel(scope: !4, name: "block1", file: !1, line: 4)
+!9 = !DILocation(line: 2, column: 17, scope: !4)
+!10 = !DILocation(line: 3, column: 3, scope: !4)
+!11 = !DILocation(line: 4, column: 1, scope: !4)
+!12 = !DILocation(line: 5, column: 3, scope: !4)
+!13 = !DILocation(line: 6, column: 3, scope: !4)
More information about the llvm-commits
mailing list