Skip to content

[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
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions llvm/lib/MC/MCAsmStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2428,10 +2428,7 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,

void MCAsmStreamer::emitInstruction(const MCInst &Inst,
const MCSubtargetInfo &STI) {
assert(getCurrentSectionOnly() &&
"Cannot emit contents before setting section!");

if (!MAI->usesDwarfFileAndLocDirectives())
if (!MAI->usesDwarfFileAndLocDirectives() && CurFrag)
// Now that a machine instruction has been assembled into this section, make
// a line entry for any .loc directive that has been seen.
MCDwarfLineEntry::make(this, getCurrentSectionOnly());
Expand Down
1 change: 1 addition & 0 deletions llvm/test/MC/Disassembler/AArch64/colored.txt
Original file line number Diff line number Diff line change
@@ -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 #20
0x00 0x7c 0x00 0x13
Expand Down
5 changes: 2 additions & 3 deletions llvm/test/MC/Disassembler/ARM/arm-trustzone.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-mc -triple=armv7-apple-darwin -mcpu=cortex-a8 -disassemble -mattr=-trustzone < %s | FileCheck %s -check-prefix=NOTZ
# RUN: llvm-mc -triple=armv7-apple-darwin -mcpu=cortex-a8 -disassemble -mattr=-trustzone %s 2>&1 | FileCheck %s -check-prefix=NOTZ
# RUN: llvm-mc -triple=armv7-apple-darwin -mcpu=cortex-a8 -disassemble -mattr=trustzone < %s | FileCheck %s -check-prefix=TZ


Expand All @@ -9,8 +9,7 @@
0x7f 0x00 0x60 0xe1
0x70 0x00 0x60 0x01

# NOTZ-NOT: smc #15
# NOTZ-NOT: smceq #0
# NOTZ-COUNT-2: warning: invalid instruction encoding
# TZ: smc #15
# TZ: smceq #0

2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-mc/line_end_with_space.test
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions llvm/tools/llvm-mc/Disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ int Disassembler::disassemble(const Target &T, const std::string &Triple,
return -1;
}

// Set up initial section manually here
Streamer.initSections(false, STI);

bool ErrorOccurred = false;

// Convert the input to a vector for disassembly.
Expand Down
Loading