[llvm] [BPF] Use ".L" local prefix label for basic blocks (PR #95103)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 11 05:30:23 PDT 2024
https://github.com/aengelke created https://github.com/llvm/llvm-project/pull/95103
Previously, PrivateLabelPrefix was default-initialized to "L", so basic block labels were added to the symbol table. This seems like an oversight, so use ".L" for all private labels.
---
I'm not sure whether this is correct. But there's no documentation anywhere that states something else and MCAsmInfo.h documentation states that PrivateLabelPrefix "Defaults to the same as PrivateGlobalPrefix," so this really seems like an oversight. Also, BPF is the only target where private label and global prefixes differ.
>From a0446a3d1ae118fa1155d5e4c4def99a0e82693f Mon Sep 17 00:00:00 2001
From: Alexis Engelke <engelke at in.tum.de>
Date: Tue, 11 Jun 2024 14:21:44 +0200
Subject: [PATCH] [BPF] Use local prefix label for basic block
Previously, PrivateLabelPrefix was default-initialized to "L", so basic
block labels were added to the symbol table. This seems like an
oversight, so use ".L" for all private labels.
---
llvm/lib/Target/BPF/MCTargetDesc/BPFMCAsmInfo.h | 1 +
llvm/test/CodeGen/BPF/cttz-ctlz.ll | 16 ++++++++--------
llvm/test/CodeGen/BPF/gotol.ll | 12 ++++++------
llvm/test/CodeGen/BPF/objdump_cond_op.ll | 9 +++------
llvm/test/CodeGen/BPF/objdump_cond_op_2.ll | 6 ++----
llvm/test/CodeGen/BPF/sanity.ll | 14 +++++++-------
6 files changed, 27 insertions(+), 31 deletions(-)
diff --git a/llvm/lib/Target/BPF/MCTargetDesc/BPFMCAsmInfo.h b/llvm/lib/Target/BPF/MCTargetDesc/BPFMCAsmInfo.h
index 7b2168458c930..6c2a955fb5aa4 100644
--- a/llvm/lib/Target/BPF/MCTargetDesc/BPFMCAsmInfo.h
+++ b/llvm/lib/Target/BPF/MCTargetDesc/BPFMCAsmInfo.h
@@ -25,6 +25,7 @@ class BPFMCAsmInfo : public MCAsmInfo {
IsLittleEndian = false;
PrivateGlobalPrefix = ".L";
+ PrivateLabelPrefix = PrivateGlobalPrefix;
WeakRefDirective = "\t.weak\t";
UsesELFSectionDirectiveForBSS = true;
diff --git a/llvm/test/CodeGen/BPF/cttz-ctlz.ll b/llvm/test/CodeGen/BPF/cttz-ctlz.ll
index f42b2e2d10871..69fe0276c8a23 100644
--- a/llvm/test/CodeGen/BPF/cttz-ctlz.ll
+++ b/llvm/test/CodeGen/BPF/cttz-ctlz.ll
@@ -31,7 +31,7 @@ define i32 @cttz_i32(i32 %a) {
; CHECK-NEXT: r2 = r1
; CHECK-NEXT: r2 <<= 32
; CHECK-NEXT: r2 >>= 32
-; CHECK-NEXT: if r2 == 0 goto LBB1_2
+; CHECK-NEXT: if r2 == 0 goto .LBB1_2
; CHECK-NEXT: # %bb.1: # %cond.false
; CHECK-NEXT: r2 = r1
; CHECK-NEXT: r2 = -r2
@@ -43,7 +43,7 @@ define i32 @cttz_i32(i32 %a) {
; CHECK-NEXT: r2 = {{\.?LCPI[0-9]+_[0-9]+}} ll
; CHECK-NEXT: r2 += r1
; CHECK-NEXT: r0 = *(u8 *)(r2 + 0)
-; CHECK-NEXT: LBB1_2: # %cond.end
+; CHECK-NEXT: .LBB1_2: # %cond.end
; CHECK-NEXT: exit
%ret = call i32 @llvm.cttz.i32(i32 %a, i1 0)
ret i32 %ret
@@ -73,7 +73,7 @@ define i64 @cttz_i64(i64 %a) {
; CHECK-LABEL: cttz_i64:
; CHECK: # %bb.0:
; CHECK-NEXT: r0 = 64
-; CHECK-NEXT: if r1 == 0 goto LBB3_2
+; CHECK-NEXT: if r1 == 0 goto .LBB3_2
; CHECK-NEXT: # %bb.1: # %cond.false
; CHECK-NEXT: r2 = r1
; CHECK-NEXT: r2 = -r2
@@ -84,7 +84,7 @@ define i64 @cttz_i64(i64 %a) {
; CHECK-NEXT: r2 = {{\.?LCPI[0-9]+_[0-9]+}} ll
; CHECK-NEXT: r2 += r1
; CHECK-NEXT: r0 = *(u8 *)(r2 + 0)
-; CHECK-NEXT: LBB3_2: # %cond.end
+; CHECK-NEXT: .LBB3_2: # %cond.end
; CHECK-NEXT: exit
%ret = call i64 @llvm.cttz.i64(i64 %a, i1 0)
ret i64 %ret
@@ -152,7 +152,7 @@ define i32 @ctlz_i32(i32 %a) {
; CHECK-NEXT: r2 = r1
; CHECK-NEXT: r2 <<= 32
; CHECK-NEXT: r2 >>= 32
-; CHECK-NEXT: if r2 == 0 goto LBB5_2
+; CHECK-NEXT: if r2 == 0 goto .LBB5_2
; CHECK-NEXT: # %bb.1: # %cond.false
; CHECK-NEXT: r2 = 4294967294 ll
; CHECK-NEXT: r3 = r1
@@ -197,7 +197,7 @@ define i32 @ctlz_i32(i32 %a) {
; CHECK-NEXT: r1 = 4278190080 ll
; CHECK-NEXT: r0 &= r1
; CHECK-NEXT: r0 >>= 24
-; CHECK-NEXT: LBB5_2: # %cond.end
+; CHECK-NEXT: .LBB5_2: # %cond.end
; CHECK-NEXT: exit
%ret = call i32 @llvm.ctlz.i32(i32 %a, i1 0)
ret i32 %ret
@@ -256,7 +256,7 @@ define i64 @ctlz_i64(i64 %a) {
; CHECK-LABEL: ctlz_i64:
; CHECK: # %bb.0:
; CHECK-NEXT: r0 = 64
-; CHECK-NEXT: if r1 == 0 goto LBB7_2
+; CHECK-NEXT: if r1 == 0 goto .LBB7_2
; CHECK-NEXT: # %bb.1: # %cond.false
; CHECK-NEXT: r2 = r1
; CHECK-NEXT: r2 >>= 1
@@ -296,7 +296,7 @@ define i64 @ctlz_i64(i64 %a) {
; CHECK-NEXT: r1 = 72340172838076673 ll
; CHECK-NEXT: r0 *= r1
; CHECK-NEXT: r0 >>= 56
-; CHECK-NEXT: LBB7_2: # %cond.end
+; CHECK-NEXT: .LBB7_2: # %cond.end
; CHECK-NEXT: exit
%ret = call i64 @llvm.ctlz.i64(i64 %a, i1 0)
ret i64 %ret
diff --git a/llvm/test/CodeGen/BPF/gotol.ll b/llvm/test/CodeGen/BPF/gotol.ll
index 0c7d9291f72da..20e5ad180db83 100644
--- a/llvm/test/CodeGen/BPF/gotol.ll
+++ b/llvm/test/CodeGen/BPF/gotol.ll
@@ -38,8 +38,8 @@ entry:
; case (3): conditional jmp followed by an unconditional jmp
; CHECK: w0 = w2
; CHECK-NEXT: if w1 < w2 goto
-; CHECK: gotol LBB0_4 # encoding: [0x06'A',A,A,A,0x00,0x00,0x00,0x00]
-; CHECK-NEXT: # fixup A - offset: 0, value: LBB0_4, kind: FK_BPF_PCRel_4
+; CHECK: gotol .LBB0_4 # encoding: [0x06'A',A,A,A,0x00,0x00,0x00,0x00]
+; CHECK-NEXT: # fixup A - offset: 0, value: .LBB0_4, kind: FK_BPF_PCRel_4
begin: ; preds = %next2, %next
%s.0 = phi i32 [ %mul3, %next ], [ %mul7, %next2 ]
@@ -49,12 +49,12 @@ begin: ; preds = %next2, %next
; case (2): conditional jmp
; CHECK: w0 *= w1
-; CHECK-NEXT: if w0 > w2 goto LBB0_7
-; CHECK: goto LBB0_4
-; CHECK-LABEL: LBB0_7:
+; CHECK-NEXT: if w0 > w2 goto .LBB0_7
+; CHECK: goto .LBB0_4
+; CHECK-LABEL: .LBB0_7:
; CHECK: gotol
-; CHECK-LABEL: LBB0_4:
+; CHECK-LABEL: .LBB0_4:
if.then2: ; preds = %begin
%mul = mul i32 %div, %div
diff --git a/llvm/test/CodeGen/BPF/objdump_cond_op.ll b/llvm/test/CodeGen/BPF/objdump_cond_op.ll
index 4a4fa84376cc8..3b2e6c1922fc4 100644
--- a/llvm/test/CodeGen/BPF/objdump_cond_op.ll
+++ b/llvm/test/CodeGen/BPF/objdump_cond_op.ll
@@ -27,7 +27,7 @@ define i32 @test(i32, i32) local_unnamed_addr #0 {
br label %13
; CHECK: r1 <<= 32
; CHECK: r1 >>= 32
-; CHECK: if r1 != 2 goto +6 <LBB0_2>
+; CHECK: if r1 != 2 goto +6 <test+0x48>
; <label>:8: ; preds = %2
%9 = icmp eq i32 %0, %1
@@ -38,32 +38,29 @@ define i32 @test(i32, i32) local_unnamed_addr #0 {
; CHECK: r0 = *(u32 *)(r1 + 0)
; CHECK: r0 *= r0
; CHECK: r0 <<= 1
-; CHECK: goto +7 <LBB0_4>
+; CHECK: goto +7 <test+0x80>
; <label>:11: ; preds = %8
%12 = shl nsw i32 %10, 2
br label %13
-; CHECK-LABEL: <LBB0_2>:
; CHECK: r3 = 0 ll
; CHECK: r0 = *(u32 *)(r3 + 0)
; CHECK: r2 <<= 32
; CHECK: r2 >>= 32
-; CHECK: if r1 == r2 goto +4 <LBB0_5>
+; CHECK: if r1 == r2 goto +4 <test+0x98>
; CHECK: r0 <<= 2
; <label>:13: ; preds = %4, %11
%14 = phi i32 [ %12, %11 ], [ %7, %4 ]
store i32 %14, ptr @gbl, align 4
br label %15
-; CHECK-LABEL: <LBB0_4>:
; CHECK: r1 = 0 ll
; CHECK: *(u32 *)(r1 + 0) = r0
; <label>:15: ; preds = %8, %13
%16 = phi i32 [ %14, %13 ], [ %10, %8 ]
ret i32 %16
-; CHECK-LABEL: <LBB0_5>:
; CHECK: exit
}
attributes #0 = { norecurse nounwind }
diff --git a/llvm/test/CodeGen/BPF/objdump_cond_op_2.ll b/llvm/test/CodeGen/BPF/objdump_cond_op_2.ll
index 4edd52a463ea9..8c9e91d4a80ea 100644
--- a/llvm/test/CodeGen/BPF/objdump_cond_op_2.ll
+++ b/llvm/test/CodeGen/BPF/objdump_cond_op_2.ll
@@ -14,8 +14,7 @@ define i32 @test(i32, i32) local_unnamed_addr #0 {
; <label>:4: ; preds = %2
br label %5
-; CHECK: if r4 s>= r3 goto +10 <LBB0_2>
-; CHECK-LABEL: <LBB0_1>:
+; CHECK: if r4 s>= r3 goto +10 <test+0x90>
; <label>:5: ; preds = %4, %5
%6 = phi i32 [ %9, %5 ], [ 0, %4 ]
@@ -27,12 +26,11 @@ define i32 @test(i32, i32) local_unnamed_addr #0 {
%12 = icmp slt i32 %10, %11
br i1 %12, label %5, label %13
; CHECK: r1 = r3
-; CHECK: if r2 s> r3 goto -10 <LBB0_1>
+; CHECK: if r2 s> r3 goto -10 <test+0x40>
; <label>:13: ; preds = %5, %2
%14 = phi i32 [ 0, %2 ], [ %9, %5 ]
ret i32 %14
-; CHECK-LABEL: <LBB0_2>:
; CHECK: exit
}
attributes #0 = { norecurse nounwind readnone }
diff --git a/llvm/test/CodeGen/BPF/sanity.ll b/llvm/test/CodeGen/BPF/sanity.ll
index 117d1bb7d9522..e84adea8b1990 100644
--- a/llvm/test/CodeGen/BPF/sanity.ll
+++ b/llvm/test/CodeGen/BPF/sanity.ll
@@ -1,4 +1,4 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
; RUN: llc < %s -mtriple=bpfel-- | FileCheck %s
@foo_printf.fmt = private unnamed_addr constant [9 x i8] c"hello \0A\00", align 1
@@ -76,10 +76,10 @@ define signext i8 @foo_cmp(i8 signext %a, i8 signext %b) #0 {
; CHECK-LABEL: foo_cmp:
; CHECK: # %bb.0:
; CHECK-NEXT: r0 = r1
-; CHECK-NEXT: if r2 s> r0 goto LBB5_2
+; CHECK-NEXT: if r2 s> r0 goto .LBB5_2
; CHECK-NEXT: # %bb.1:
; CHECK-NEXT: r0 = r2
-; CHECK-NEXT: LBB5_2:
+; CHECK-NEXT: .LBB5_2:
; CHECK-NEXT: exit
%1 = icmp slt i8 %a, %b
%a.b = select i1 %1, i8 %a, i8 %b
@@ -91,18 +91,18 @@ define i32 @foo_muldiv(i8 signext %a, i16 signext %b, i32 %c, i64 %d) #0 {
; CHECK-LABEL: foo_muldiv:
; CHECK: # %bb.0:
; CHECK-NEXT: r0 = r2
-; CHECK-NEXT: if r1 == 0 goto LBB6_2
+; CHECK-NEXT: if r1 == 0 goto .LBB6_2
; CHECK-NEXT: # %bb.1:
; CHECK-NEXT: r0 *= r3
-; CHECK-NEXT: goto LBB6_3
-; CHECK-NEXT: LBB6_2:
+; CHECK-NEXT: goto .LBB6_3
+; CHECK-NEXT: .LBB6_2:
; CHECK-NEXT: r3 <<= 32
; CHECK-NEXT: r3 >>= 32
; CHECK-NEXT: r4 <<= 32
; CHECK-NEXT: r4 >>= 32
; CHECK-NEXT: r4 /= r3
; CHECK-NEXT: r0 = r4
-; CHECK-NEXT: LBB6_3:
+; CHECK-NEXT: .LBB6_3:
; CHECK-NEXT: exit
%1 = icmp eq i8 %a, 0
br i1 %1, label %5, label %2
More information about the llvm-commits
mailing list