-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-mc] Don't print initial .text for disassembler #120185
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
MaskRay
merged 3 commits into
main
from
users/MaskRay/spr/llvm-mc-dont-print-initial-text
Dec 17, 2024
Merged
[llvm-mc] Don't print initial .text for disassembler #120185
MaskRay
merged 3 commits into
main
from
users/MaskRay/spr/llvm-mc-dont-print-initial-text
Dec 17, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-mc @llvm/pr-subscribers-backend-aarch64 Author: Fangrui Song (MaskRay) ChangesOmit the initial
Full diff: https://github.com/llvm/llvm-project/pull/120185.diff 3 Files Affected:
diff --git a/llvm/test/MC/Disassembler/AArch64/colored.txt b/llvm/test/MC/Disassembler/AArch64/colored.txt
index 3293de8a8748f4..1379c552d85cc3 100644
--- a/llvm/test/MC/Disassembler/AArch64/colored.txt
+++ b/llvm/test/MC/Disassembler/AArch64/colored.txt
@@ -1,6 +1,7 @@
# UNSUPPORTED: system-windows
# RUN: llvm-mc -triple=aarch64 -mattr=+all --cdis %s | FileCheck %s --strict-whitespace --match-full-lines
+# CHECK-NOT:{{.}}
0xa1 0x00 0x00 0x54
# CHECK: b.ne �[0;31m#20�[0m
0x00 0x7c 0x00 0x13
diff --git a/llvm/test/tools/llvm-mc/line_end_with_space.test b/llvm/test/tools/llvm-mc/line_end_with_space.test
index 5ad5a8382edfae..b9f44afc43bb4d 100644
--- a/llvm/test/tools/llvm-mc/line_end_with_space.test
+++ b/llvm/test/tools/llvm-mc/line_end_with_space.test
@@ -1,3 +1,3 @@
# Test that llvm-mc doesn't crash when disassembling a line that ends with a
# space.
-RUN: echo -n ' ' | llvm-mc -disassemble
+RUN: echo -n ' ' | llvm-mc -disassemble | count 0
diff --git a/llvm/tools/llvm-mc/Disassembler.cpp b/llvm/tools/llvm-mc/Disassembler.cpp
index 30577fe631d62e..d02445e21e4c31 100644
--- a/llvm/tools/llvm-mc/Disassembler.cpp
+++ b/llvm/tools/llvm-mc/Disassembler.cpp
@@ -169,7 +169,7 @@ int Disassembler::disassemble(const Target &T, const std::string &Triple,
}
// Set up initial section manually here
- Streamer.initSections(false, STI);
+ Streamer.switchSectionNoPrint(Ctx.getObjectFileInfo()->getTextSection());
bool ErrorOccurred = false;
|
s-barannikov
approved these changes
Dec 17, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
boomanaiden154
approved these changes
Dec 17, 2024
Created using spr 1.3.5-bogner
MaskRay
added a commit
that referenced
this pull request
Dec 17, 2024
This kludge will go away after #120185.
Created using spr 1.3.5-bogner
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The initial
.text
kludge is dueinitSection
, which is actually onlyneeded by AIX XCOFF for its
getCurrentSectionOnly()
use inMCAsmStreamer::emitInstruction (https://reviews.llvm.org/D95518). Adjust
MCAsmStreamer::emitInstruction to not trigger failures on