[llvm] Fix warning on align directives with non-zero fill value (PR #67237)
Luís Marques via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 23 06:03:50 PDT 2023
https://github.com/luismarques created https://github.com/llvm/llvm-project/pull/67237
The original patch (PR #66792) did not properly check the non-zero fill value condition. This patch adds a new test case to ensure the overly aggressive check does not return.
>From 61aad5837b4d9fef3cdbe1a5fa032846e8708bc0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lu=C3=ADs=20Marques?= <luismarques at lowrisc.org>
Date: Sat, 23 Sep 2023 13:56:39 +0100
Subject: [PATCH] Fix warning on align directives with non-zero fill value
The original patch (PR #66792) did not properly check the non-zero fill
value condition. This patch adds a new test case to ensure the overly
aggressive check does not return.
---
llvm/lib/MC/MCParser/AsmParser.cpp | 2 +-
llvm/test/MC/ELF/nobits-non-zero-value.s | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 15ba96b84fa4701..b36c5f067a95392 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3452,7 +3452,7 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
}
}
- if (HasFillExpr) {
+ if (HasFillExpr && FillExpr != 0) {
MCSection *Sec = getStreamer().getCurrentSectionOnly();
if (Sec && Sec->isVirtualSection()) {
ReturnVal |=
diff --git a/llvm/test/MC/ELF/nobits-non-zero-value.s b/llvm/test/MC/ELF/nobits-non-zero-value.s
index 8f37a957b6b56c0..9b2bea6278e6955 100644
--- a/llvm/test/MC/ELF/nobits-non-zero-value.s
+++ b/llvm/test/MC/ELF/nobits-non-zero-value.s
@@ -15,5 +15,8 @@
# CHECK: {{.*}}.s:[[#@LINE+1]]:11: warning: ignoring non-zero fill value in SHT_NOBITS section '.bss'
.align 4, 42
+# CHECK-NOT: {{.*}}.s:[[#@LINE+1]]:11: warning: ignoring non-zero fill value in SHT_NOBITS section '.bss'
+.align 4, 0
+
# CHECK: <unknown>:0: error: SHT_NOBITS section '.bss' cannot have non-zero initializers
.long 1
More information about the llvm-commits
mailing list