Skip to content

[AMDGPU][MC] Use normal ELF syntax for section switching #77267

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

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

shiltian
Copy link
Contributor

@shiltian shiltian commented Jan 8, 2024

For some reasons SunStyleELFSectionSwitchSyntax is set to true for AMDGPU, but according to #64862 (comment) that syntax is only limited to Sun system.

Fix #64862.

@llvmbot llvmbot added the mc Machine (object) code label Jan 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 8, 2024

@llvm/pr-subscribers-backend-amdgpu

@llvm/pr-subscribers-mc

Author: Shilei Tian (shiltian)

Changes

Fix #64862.


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

2 Files Affected:

  • (modified) llvm/lib/MC/MCParser/ELFAsmParser.cpp (+2)
  • (added) llvm/test/MC/AsmParser/pr64862.s (+4)
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index 93e1d2f44b8c56..b22d08dfedce0c 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -379,6 +379,8 @@ unsigned ELFAsmParser::parseSunStyleSectionFlags() {
       flags |= ELF::SHF_WRITE;
     else if (flagId == "tls")
       flags |= ELF::SHF_TLS;
+    else if (flagId == "exclude")
+      flags |= ELF::SHF_EXCLUDE;
     else
       return -1U;
 
diff --git a/llvm/test/MC/AsmParser/pr64862.s b/llvm/test/MC/AsmParser/pr64862.s
new file mode 100644
index 00000000000000..1e0458129d9963
--- /dev/null
+++ b/llvm/test/MC/AsmParser/pr64862.s
@@ -0,0 +1,4 @@
+; RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu gfx1030 %s | FileCheck %s
+
+; CHECK: .section	".linker-options",#exclude
+	.section	".linker-options",#exclude

@shiltian shiltian changed the title [MC] Add support for exclude flag when parsing sun-style section flags [AMDGPU][MC] Use normal ELF syntax for section switching Jan 9, 2024
@shiltian shiltian requested review from MaskRay and arsenm January 9, 2024 03:56
Copy link
Contributor

@arsenm arsenm left a comment

Choose a reason for hiding this comment

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

Does the assembler still recognize the sun syntax? Can you add a test for what happens if you try reading old asm with the sun name?

@shiltian
Copy link
Contributor Author

shiltian commented Jan 9, 2024

Does the assembler still recognize the sun syntax? Can you add a test for what happens if you try reading old asm with the sun name?

Do we still want the sun style to work? I tried locally and the assembler can still recognize it.

@shiltian shiltian merged commit b629b86 into llvm:main Jan 9, 2024
@shiltian shiltian deleted the PR64862 branch January 9, 2024 19:13
@arsenm
Copy link
Contributor

arsenm commented Jan 10, 2024

Does the assembler still recognize the sun syntax? Can you add a test for what happens if you try reading old asm with the sun name?

Do we still want the sun style to work? I tried locally and the assembler can still recognize it.

Well we ideally wouldn't break existing asm people are relying on parsing

@shiltian
Copy link
Contributor Author

Does the assembler still recognize the sun syntax? Can you add a test for what happens if you try reading old asm with the sun name?

Do we still want the sun style to work? I tried locally and the assembler can still recognize it.

Well we ideally wouldn't break existing asm people are relying on parsing

We can keep as it for now and probably add some checks when parsing Sun syntax after next release or so.

justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
For some reasons `SunStyleELFSectionSwitchSyntax` is set to `true` for
AMDGPU, but according to
llvm#64862 (comment)
that syntax is only limited to Sun system.

Fix llvm#64862.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AMDGPU mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[AMDGPU] Clang -cc1as does not recognize the #exclude flag
4 participants