Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning on align directives with non-zero fill value #67237

Merged
merged 1 commit into from
Sep 27, 2023

Conversation

luismarques
Copy link
Contributor

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.

The original patch (PR llvm#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.
@llvmbot llvmbot added the mc Machine (object) code label Sep 23, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 23, 2023

@llvm/pr-subscribers-mc

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/67237.diff

2 Files Affected:

  • (modified) llvm/lib/MC/MCParser/AsmParser.cpp (+1-1)
  • (modified) llvm/test/MC/ELF/nobits-non-zero-value.s (+3)
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

Copy link
Contributor

@MatzeB MatzeB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@luismarques luismarques merged commit 6e46545 into llvm:main Sep 27, 2023
legrosbuffle pushed a commit to legrosbuffle/llvm-project that referenced this pull request Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants