[llvm] [RISCV] Move the emitValueToAlignment before the header in emitNoteGnuPropertySection. (PR #151436)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 30 19:21:48 PDT 2025
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/151436
I assume the feature_1_and should appear immediately after the header so we should align the header to avoid a gap.
>From 8e219f996a2589ee2ac8ddaeb9c44d7bdf374e29 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Wed, 30 Jul 2025 19:19:32 -0700
Subject: [PATCH] [RISCV] Move the emitValueToAlignment before the header in
emitNoteGnuPropertySection.
I assume the feature_1_and should appear immediately after the
header so we should align the header to avoid a gap.
---
llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp | 2 +-
llvm/test/CodeGen/RISCV/note-gnu-property-zicfiss.ll | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
index 36558613d9172..6cb0d6843f965 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -83,6 +83,7 @@ void RISCVTargetStreamer::emitNoteGnuPropertySection(
OutStreamer.switchSection(NoteSection);
// Emit the note header
+ OutStreamer.emitValueToAlignment(NoteAlign);
OutStreamer.emitIntValue(4, 4); // n_namsz
MCSymbol *const NDescBeginSym = Ctx.createTempSymbol();
@@ -97,7 +98,6 @@ void RISCVTargetStreamer::emitNoteGnuPropertySection(
// Emit n_desc field
OutStreamer.emitLabel(NDescBeginSym);
- OutStreamer.emitValueToAlignment(NoteAlign);
// Emit the feature_1_and property
OutStreamer.emitIntValue(ELF::GNU_PROPERTY_RISCV_FEATURE_1_AND, 4); // pr_type
diff --git a/llvm/test/CodeGen/RISCV/note-gnu-property-zicfiss.ll b/llvm/test/CodeGen/RISCV/note-gnu-property-zicfiss.ll
index 24d63cbebc7af..ee31c762c1be1 100644
--- a/llvm/test/CodeGen/RISCV/note-gnu-property-zicfiss.ll
+++ b/llvm/test/CodeGen/RISCV/note-gnu-property-zicfiss.ll
@@ -7,13 +7,13 @@
; ASM: .section ".note.GNU-stack","", at progbits
; ASM-NEXT: .section .note.gnu.property,"a", at note
+; ASM32-NEXT: .p2align 2, 0x0
+; ASM64-NEXT: .p2align 3, 0x0
; ASM-NEXT: .word 4
; ASM-NEXT: .word .Ltmp1-.Ltmp0
; ASM-NEXT: .word 5
; ASM-NEXT: .asciz "GNU"
; ASM-NEXT: .Ltmp0:
-; ASM32-NEXT: .p2align 2, 0x0
-; ASM64-NEXT: .p2align 3, 0x0
; ASM-NEXT: .word 3221225472
; ASM-NEXT: .word 4
; ASM-NEXT: .word 2
More information about the llvm-commits
mailing list