[MC] Diagnose a negative .fill count through MCContext #6

Closed
techwritescode wants to merge 1 commit from ps2-mc-fill-warning into r5900-ee

MCObjectStreamer::emitFill printed the "negative repeat count" warning with getContext().getSourceManager()->PrintMessage. getSourceManager() is null when the MC layer emits code for input that is not an assembly file, so a negative count in inline assembly (file-scope or in a function) crashed clang. Found with the IRX table macros, where .fill 8-(.-1b), 1, 0 goes negative for a module name longer than 8 bytes.

It now calls MCContext::reportWarning, which handles the inline-asm source manager and -w/-Werror. Before: clang crashes. After: <inline asm>:3:8: warning: '.fill' directive with negative repeat count has no effect [-Winline-asm].

Test: CodeGen/Mips/inline-asm-fill-negative.ll (run by hand with llc and FileCheck). Worth sending upstream.

🤖 Generated with Claude Code

`MCObjectStreamer::emitFill` printed the "negative repeat count" warning with `getContext().getSourceManager()->PrintMessage`. `getSourceManager()` is null when the MC layer emits code for input that is not an assembly file, so a negative count in inline assembly (file-scope or in a function) crashed clang. Found with the IRX table macros, where `.fill 8-(.-1b), 1, 0` goes negative for a module name longer than 8 bytes. It now calls `MCContext::reportWarning`, which handles the inline-asm source manager and `-w`/`-Werror`. Before: clang crashes. After: `<inline asm>:3:8: warning: '.fill' directive with negative repeat count has no effect [-Winline-asm]`. Test: `CodeGen/Mips/inline-asm-fill-negative.ll` (run by hand with llc and FileCheck). Worth sending upstream. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
[MC] Diagnose a negative .fill count through MCContext
Some checks failed
action.yml / [MC] Diagnose a negative .fill count through MCContext (push) Failing after 0s
release-binaries-all.yml / [MC] Diagnose a negative .fill count through MCContext (push) Failing after 0s
release-binaries.yml / [MC] Diagnose a negative .fill count through MCContext (push) Failing after 0s
release-documentation.yml / [MC] Diagnose a negative .fill count through MCContext (push) Failing after 0s
release-sources.yml / [MC] Diagnose a negative .fill count through MCContext (push) Failing after 0s
Check for private emails used in PRs / validate_email (pull_request) Has been skipped
action.yml / [MC] Diagnose a negative .fill count through MCContext (pull_request) Failing after 0s
Check LLVM ABI annotations / Check LLVM_ABI annotations with ids (pull_request) Has been skipped
CI Checks / Build and Test Linux (pull_request) Has been skipped
CI Checks / Build and Test Windows (pull_request) Has been skipped
CI Checks / Compute macOS Projects (pull_request) Has been skipped
CI Checks / Build and Test macOS arm64 (pull_request) Has been skipped
release-binaries-all.yml / [MC] Diagnose a negative .fill count through MCContext (pull_request) Failing after 0s
release-binaries.yml / [MC] Diagnose a negative .fill count through MCContext (pull_request) Failing after 0s
release-documentation.yml / [MC] Diagnose a negative .fill count through MCContext (pull_request) Failing after 0s
release-sources.yml / [MC] Diagnose a negative .fill count through MCContext (pull_request) Failing after 0s
Add buildbot information to first PRs from new contributors / buildbot_comment (pull_request_target) Has been skipped
Labelling new pull requests / greeter (pull_request_target) Has been cancelled
Labelling new pull requests / automate-prs-labels (pull_request_target) Has been cancelled
8f6af403d9
MCObjectStreamer::emitFill printed the warning through getSourceManager(), which is
null when the input is not an assembly file, so a negative count in inline assembly
crashed the compiler. reportWarning handles the inline-asm source manager.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
techwritescode closed this pull request 2026-10-12 22:33:01 +00:00
Some checks failed
action.yml / [MC] Diagnose a negative .fill count through MCContext (push) Failing after 0s
release-binaries-all.yml / [MC] Diagnose a negative .fill count through MCContext (push) Failing after 0s
release-binaries.yml / [MC] Diagnose a negative .fill count through MCContext (push) Failing after 0s
release-documentation.yml / [MC] Diagnose a negative .fill count through MCContext (push) Failing after 0s
release-sources.yml / [MC] Diagnose a negative .fill count through MCContext (push) Failing after 0s
Check for private emails used in PRs / validate_email (pull_request) Has been skipped
action.yml / [MC] Diagnose a negative .fill count through MCContext (pull_request) Failing after 0s
Check LLVM ABI annotations / Check LLVM_ABI annotations with ids (pull_request) Has been skipped
CI Checks / Build and Test Linux (pull_request) Has been skipped
CI Checks / Build and Test Windows (pull_request) Has been skipped
CI Checks / Compute macOS Projects (pull_request) Has been skipped
CI Checks / Build and Test macOS arm64 (pull_request) Has been skipped
release-binaries-all.yml / [MC] Diagnose a negative .fill count through MCContext (pull_request) Failing after 0s
release-binaries.yml / [MC] Diagnose a negative .fill count through MCContext (pull_request) Failing after 0s
release-documentation.yml / [MC] Diagnose a negative .fill count through MCContext (pull_request) Failing after 0s
release-sources.yml / [MC] Diagnose a negative .fill count through MCContext (pull_request) Failing after 0s
Add buildbot information to first PRs from new contributors / buildbot_comment (pull_request_target) Has been skipped
Labelling new pull requests / greeter (pull_request_target) Has been cancelled
Labelling new pull requests / automate-prs-labels (pull_request_target) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ps2/llvm!6
No description provided.