2747 Commits
Author SHA1 Message Date
Matt GodboltandClaude 520ab0a738 Update generated PTX documentation after docenizer refactoring
The refactored docenizer now correctly:
- Identifies instructions by their actual names from code elements
- Removes false duplicate entries (e.g., "arrive", "async" which were misidentified)
- Includes previously missing instructions like "barrier", "elect", "match"
- Provides cleaner single entries for instructions with multiple type variants

Generated file maintains 121 instructions with improved accuracy.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 14:03:49 -05:00
Matt GodboltandClaude 5076a6f6a7 Fix docenizer issues per review feedback
PTX Docenizer:
- Document WHY the tooltip fallback is needed (some instructions lack short descriptions)
- Remove exception handling that just printed warnings - fail loudly instead
- Add exception when no docs can be parsed for an instruction
- Handle both <p> and <dl> elements for descriptions (needed for composite instructions)
- Deduplicate filtering logic with is_valid_instruction_section() helper
- Filter out documentation sections (mechanisms, restrictions) from variant checking

AMD64 Docenizer:
- Use list comprehension instead of loop: table = [row for tbl in tables for row in read_table(tbl)]

All changes ensure failures are loud and visible rather than silent.
Tests confirm everything works correctly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 11:18:14 -05:00
Matt GodboltandClaude 6d68821ac2 Simplify control flow and remove unnecessary fallbacks in PTX docenizer
Improvements:
- Eliminate redundant conditionals for short_desc and text truncation
- Add helper function get_tooltip() to centralize tooltip text logic
- Remove all fallback paths that could hide documentation structure changes
- Replace generic exception catching with specific ValueError handling
- Add explicit filters to skip non-instruction sections (restrictions, mechanisms, etc.)
- Make parser fail loudly with clear error messages when structure doesn't match

The docenizer now:
- Raises clear errors instead of silently generating fallback documentation
- Logs warnings for sections that don't match expected structure
- Only includes actual PTX instructions, not documentation sections
- Has cleaner, more maintainable control flow

Result: More robust parser that will alert us to documentation changes
rather than silently producing incorrect output.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 10:27:34 -05:00
Matt GodboltandClaude cb1db58de1 Refactor PTX docenizer to use structural parsing only
Replace all hardcoded lists and text matching with proper structural HTML parsing:

- Remove hardcoded keyword filter list (the, for, if, else, etc.)
- Remove hardcoded "common instruction" lists (add, sub, mul, div)
- Remove exact text matching for descriptions
- Remove useless conditional lxml import that did nothing

New approach uses document structure exclusively:
- Identifies instruction sections by ID pattern and documentation rubrics
- Extracts BOTH short descriptions (between instruction name and Syntax rubric)
  and detailed descriptions (after Description rubric)
- Short descriptions used for tooltips (e.g., "Add two values.")
- Detailed descriptions used for HTML content
- Prioritizes sections by hierarchy (integer-arithmetic > floating-point > etc.)
- Automatically adapts to documentation format changes

Result: Cleaner, more maintainable code that properly captures both the
concise tooltip text and detailed descriptions without any hardcoded patterns.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 10:16:42 -05:00
Matt GodboltandClaude 897397775c Fix docenizer issues: AMD64 SHR missing and PTX descriptions
- Fix AMD64 docenizer to read ALL tables in HTML files, not just the first
  SAL:SAR:SHL:SHR.html has multiple tables and SHR was in the second table
- Fix PTX docenizer to properly extract instruction descriptions
  - Prioritize instruction sections over changelog sections for common ops
  - Extract both short descriptions (for tooltips) and detailed descriptions
  - Handle Description sections to get "Performs addition..." text
  - Add explicit mappings for base instructions to their integer sections

Tests now pass completely for both AMD64 and PTX documentation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 08:37:45 -05:00
Ofek 5a7b0c27a4 Add CFG for MSVC compilers (#8134) 2025-09-25 00:23:36 +03:00
Ofek df5a83ea5b Fix #8081: remove -S from preprocessor compilation (#8133) 2025-09-24 15:59:14 +03:00
Ofek a971b1bc86 Fix #8131: comment filtering can leave empty lines. +Some renaming. (#8132) 2025-09-24 15:53:00 +03:00
narpfel 4836aa2360 Fix quadratic runtime in execution output reading (#8123) 2025-09-22 21:29:42 +02:00
Ofek 9bedb75b24 Fix #8116: rework GccCFGParser.filterData (#8117) 2025-09-20 22:09:05 +03:00
Ofek 80e446a16e Fix #8102: classify opt-remarks based on prefix (#8108) 2025-09-16 22:18:41 +03:00
Patrick Quist 102c74c09b fix tool invokations include paths for libraries (#8096) 2025-09-12 15:23:55 -05:00
Matt Godbolt f824efe73e Library updates and lint fixes (#8099)
* Minor updates only
* Added explicit radix parameter (10) to all Number.parseInt() calls throughout the codebase (new lint rule)
* Updated several @ts-ignore comments to @ts-expect-error for better TypeScript practices (new lint rule)
* Removed unnecessary @ts-ignore comments in some mode files (ditto)
* Used "none return" based arrow functions for some map stuff
* Replaced a `map()` call that didn't return anything to a for() loop
* Fixed up some cypress stuff, noting work for the future
2025-09-12 14:23:49 -05:00
Partouf 847ea95559 bugfix 2025-09-12 18:07:12 +02:00
Patrick Quist 0c5b4a5fd6 Add S3 overflow support for compilation workers (#8091) 2025-09-12 00:05:43 +02:00
Partouf 6b6efecb92 execution worker fix 2025-09-10 08:19:40 +02:00
Partouf 8fed840401 better protection against failures in websocket handling 2025-09-10 06:13:02 +02:00
Patrick Quist 447201a583 fix unicode stream bug (#8086) 2025-09-10 06:00:40 +02:00
Patrick Quist b3c6a321f1 Add compilation worker mode infrastructure (#7864) 2025-09-08 22:07:47 +02:00
Andy SofferandMatt Kulukundis 082c4304f2 Add tool arguments to bronto-refactor tool. (#8079)
This change just feeds the arguments passed via CE directly to the
binary tool.

Co-authored-by: Matt Kulukundis <matt@brontosource.dev>
2025-09-08 13:02:27 -05:00
Partouf 74a7611f3e fix #2986 2025-08-26 12:39:37 +02:00
narpfel 028bd96400 Update rustfmt to 1.89 and 2024 edition (#8059)
Resolves #8058.
2025-08-25 21:23:40 -05:00
narpfel 63faf792ba Fix jump to label with symbols containing $ (#8051)
For example Rust will mangle `<` to `$LT$`:
https://godbolt.org/z/86n9M6P3f
2025-08-25 21:19:07 -05:00
kevinjeon-g fc37e42d13 Fix errors in dex2oat compilation (#8050)
This fixes missing inlines (noticed on ArrayList iterators) and
incorrectly-emitted read barriers on local dex2oat.
2025-08-25 21:17:55 -05:00
Matt Godbolt 7c74b5aa0d Make compiler startup less chatty (#8043) 2025-08-19 08:48:30 -05:00
Ofek 96103f044f Fix #8000: stop forcing dwarf 4 (#8036) 2025-08-16 17:39:09 +03:00
narpfel 5d1d7cf77b Fix demangling for symbols with dots in jump instructions (#8028)
For example Rust on AArch64: https://godbolt.org/z/e3q9Wv7zj
2025-08-14 10:09:02 -05:00
narpfel 68db4ca482 Remove unused method AsmParser.labelFindFor (#8022)
`AsmParser.labelFindFor` was only called in tests.
2025-08-12 08:50:53 -05:00
narpfel f289b79f1d Don’t filter .set directives that declare merged functions (#8021)
Resolves #2409.
2025-08-11 14:31:44 -05:00
narpfel 82407976d1 Accept multiple dots in symbol names for jump to label (#8018)
Some compilers emit symbol names with multiple dots, e. g. Clang for
static data (like string literals) or GCC for function clones (e. g. due
to interprocedural constant propagation).

Test cases: https://godbolt.org/z/dGbGncnh8,
https://godbolt.org/z/dhrGGqrjo
2025-08-11 14:28:06 -05:00
Matt GodboltandPartouf 2ae38a0c3f Make argument parsers instances instead of static classes (#8017)
- Made parsers stateful instances instead of shared static state (for
mllvm options). Fixes #8011 as this is caused by multiple clang-based
compilers being run concurrently and stomping over each others' state.
- passes `Compiler` to the constructor, which removes some param passing
- Added some missing awaits
- Tried to get things less dependent on `examples`, only `go` needs it
- Spotted that `zig` c++ might have issues in discovery
- Fly-by fixed a broken go path in ppc64le_gl122
- removed a redundant override in coccinelle
- made the mojo parser actually use the parser it defined
- canonified tablegen's special method
- 

I changed the zig parser too but as best I can tell it was broken before
(the `1` return value from the command it runs:)

```
ubuntu@ip-172-30-0-164:/infra/.deploy$ /opt/compiler-explorer/zig-0.14.1/zig c++ -mllvm --help-list-hidden /infra/.deploy/examples/c++/default.cpp -S -o /tmp/output.s
...
  --x86-use-vzeroupper                                                       - Minimize AVX to SSE transition penalty
  --xcore-max-threads=<number>                                               - Maximum number of threads (for emulation thread-local storage)
/infra/.deploy/examples/c++/default.cpp:1:1: error: FileNotFound
```
return code 1 (means it's not cached)

---------

Co-authored-by: Partouf <partouf@gmail.com>
2025-08-11 12:14:13 -05:00
A. R. Shajii bea6e67715 Add Codon Python compiler (#8008) 2025-08-11 11:14:26 -05:00
Matt Godbolt 56cf9859c3 Disable failed assertion 2025-08-09 14:27:40 -05:00
Ofek a85260bc27 Fix #8009: Allow quotes as part of labels (#8015) 2025-08-09 20:21:31 +02:00
Ofek fbfcd52dd5 Fix #8010: detection of jmp targets in python cfg (#8012) 2025-08-09 16:53:58 +03:00
Matt GodboltandClaude c29ad46f3a [Not Live; disabled by default] Add Claude Explain feature for AI-powered assembly explanations (#7749)
Add Claude Explain feature for AI-powered code explanations

This PR introduces Claude Explain, a new feature that provides AI-powered explanations of compiler output directly within Compiler Explorer.

Key features:

Claude Explain functionality:
  - New explain view pane
  - Explains compiler output with full context of source code and compilation output
  - Configurable audience level and explanation type
  - Response caching to improve performance and reduce API calls
  - Usage statistics display showing requests used and token counts

User experience:
  - Consent flow on first use explaining data handling and privacy
  - AI disclaimer banner warning about potential LLM inaccuracies
  - Respects "no-ai" directive in source code for users who don't want AI processing

Privacy and security:
  - Data sent to Anthropic's Claude API as documented in privacy policy
  - No data used for model training
  - Clear consent required before first use
  - Support for opting out via "no-ai" directive

The feature is marked as beta and can be enabled via configuration.

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-05 09:31:48 -05:00
Iain Buclaw 1055430504 Add alias option for gcc tree/rtl viewer (#7985) (#7987)
This option is undocumented, but has been around since 2010 for GCC
4.6.0
2025-08-04 15:44:08 +02:00
Shawn Zhong 9c72429e08 Remove duplicates in SASS docs (#7991)
In PR https://github.com/compiler-explorer/compiler-explorer/pull/7976,
I forgot to handle the case where same instructions have different
descriptions. This PR fixes the script and removes the duplicates from
the generated file.

The SASS docs are extracted from multiple tables from
https://docs.nvidia.com/cuda/cuda-binary-utilities/index.html#instruction-set-reference.
For example,
- Table 4. Maxwell and Pascal Instruction Set
- ...
- Table 8. Hopper Instruction Set
- Table 8. Blackwell Instruction Set (wait...what? both tables are table
8? whatever...)

Previously, only the duplications for the (opcode, descriptions) pair
were removed. In this PR, we only check the duplications based on the
opcode and only keep the last one (based on the assumption that the
newer ones are better).

I manually went through the removed duplicates, and found that
- No instruction actually changed the meaning across generations (I
would be very surprised if they did so).
- Most of the changes are minor fixes like changing capitalization
(e.g., `generic Memory` -> `Generic Memory`) or fixing typo (e.g.,
`Local within Shared Memory Window` -> `Load within Shared Memory
Window`)
- A couple of the descriptions are for whatever reason simplified (e.g.,
`LOP3`: `3-input Logic Operation` -> `Logic Operation`), which is a bit
unfortunate.
2025-08-04 08:20:28 -05:00
Matt GodboltandClaude 0eee48a0fb Optimize logo file sizes to reduce webpack bundle size (#7979)
## Summary
- Optimized 13 logo files, reducing total size by ~560KB
- Converted hylo.svg (321KB) and nim.svg (126KB) to optimized PNGs
(27KB, 13KB)
- Resized oversized images to max 256×256 while preserving aspect ratios
- Optimized SVGs with SVGO where beneficial
- Fixed file permissions (removed execute bits from image files)
- Added comprehensive README.md with optimization guidelines

## Files Changed
- `lib/languages.ts`: Updated references from hylo.svg → hylo.png,
nim.svg → nim.png
- `public/logos/`: Optimized multiple logo files
- `public/logos/README.md`: New optimization guidelines for future logo
additions

## Size Reductions
- hylo.svg → hylo.png: 321KB → 27KB (92% reduction)
- nim.svg → nim.png: 126KB → 13KB (90% reduction)  
- scala.png: 79KB → 14KB (82% reduction)
- haskell.png: 19KB → 6.5KB (66% reduction)
- pony.svg: 53KB → 35KB (34% reduction)
- odin.png: 48KB → 27KB (44% reduction)
- nix.svg: 26KB → 5KB (81% reduction)
- gimple.svg: 21KB → 11KB (48% reduction)
- spice.png: 16KB → 9.3KB (42% reduction)
- hook.png: 14KB → 9.3KB (34% reduction)
- hook-dark.png: 13KB → 9.3KB (28% reduction)

## Test plan
- [x] Verify all logos display correctly in the language selection UI
- [x] Confirm no broken image references
- [x] Check that webpack bundle size warnings are reduced
- [x] Ensure visual quality is acceptable at small icon sizes

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-31 16:07:04 -05:00
Shawn Zhong 97c6ce61ec Update SASS docs and fix link (#7976)
- Change SASS instruction link from
`https://docs.nvidia.com/cuda/cuda-binary-utilities/index.html#id14` to
`https://docs.nvidia.com/cuda/cuda-binary-utilities/index.html#instruction-set-reference`.
In the former URL, the tag (`#id14`) no longer exists on the webpage.
- Run `etc/scripts/docenizers/docenizer-ptx-sass.py` and add some new
instructions from the website.
2025-07-31 08:21:27 -05:00
Shawn Zhong f92b6f388a Remove dangling empty braces in PTX (#7960)
After directive filtering, there will be dangling `{}` spanning two
lines. This PR attempts to remove them.

For example, 
```
.section    .debug_abbrev
{
.b8 1
}
.section    .debug_info
{
.b32 70
.b32 .debug_abbrev
}
```

The above assembly used to become the following text after filtering
directive

```
{
}
{
}
```
2025-07-30 10:40:00 -05:00
Shawn Zhong 227595d83e Fix PTX parsing with predicate (#7959)
Recogonize lines with predicate (e.g., `@%p1`, `@!%p1`) as instructions:
- `@%p1 ld.global.v4.b32 { %r9, %r10, %r11, %r12 }, [ %rd3 + 0 ];`
- `@%p2 bra $L__BB0_28;`
- `@!%p2 bra $L__BB0_28;`

| Before | After | 
| --- | --- |
| <img width="580" height="320" alt="image"
src="https://github.com/user-attachments/assets/c3913b09-ce04-44c5-a4c0-fa69805cf1d7"
/> | <img width="566" height="323" alt="image"
src="https://github.com/user-attachments/assets/08308b3d-df00-4cf1-8321-203c374c27c3"
/> |



From
https://docs.nvidia.com/cuda/parallel-thread-execution/#instruction-statements:

> Instructions have an optional guard predicate which controls
conditional execution. The guard predicate follows the optional label
and precedes the opcode, and is written as @p, where p is a predicate
register. The guard predicate may be optionally negated, written as @!p.

Implementation-wise, added `(@!?%\w+\s+)?` to existing default
`hasOpcodeRe` (`/^\s*(%[$.A-Z_a-z][\w$.]*\s*=\s*)?[A-Za-z]/`)
2025-07-30 10:34:59 -05:00
Shawn ZhongandMatt Godbolt 8befc91a79 Add Triton language and compiler (#7919)
Close #5530. Infra:
https://github.com/compiler-explorer/infra/pull/1711. Previous work by
@siboehm at #5531


## Summary

This pull request introduces support for the
[Triton](https://github.com/triton-lang/triton) language, a Python-based
DSL for writing highly efficient GPU kernels.


- [x] **New Language Support**: I've added comprehensive support for the
Triton programming language, allowing users to compile and inspect
Triton kernels within Compiler Explorer. (c.f.,
`lib/compilers/triton.ts`)
- [x] **Python Wrapper for Compilation**: A new Python wrapper script
(`triton_wrapper.py`) has been introduced to manage Triton compilation,
patching its behavior to dump compiled kernels and intermediate
representations without requiring actual execution, and consolidating
the output for Compiler Explorer.
- [x] **Device Assembly View**: Enables viewing of generated device
assembly code (e.g., PTX, AMDGCN) and various intermediate
representations (MLIR, LLVM IR) produced by the Triton compiler.
- [x] **MLIR Parsing**: New parsers (`asm-parser-mlir.ts` and
`mlir-pass-dump-parser.ts`) have been added to correctly interpret and
display MLIR assembly and optimization pass dumps, including source
location information.
- [x] **Multi-Version & Multi-Backend Support**: Painstakingly includes
all 8 versions (from 2.2.0 to 3.3.1) of Triton that supports Python
3.12. Supports both CUDA and HIP backend for Triton 3.

## Screenshots

Source and assembly:
<img width="1354" height="789" alt="image"
src="https://github.com/user-attachments/assets/c29650ff-2073-40e0-a9e6-ff8377094b5e"
/>



Device view for MLIR and LLVM IR: 
<img width="1402" height="670" alt="image"
src="https://github.com/user-attachments/assets/43dd5c68-ca78-41b1-9865-e97ffe3ef73c"
/>

Opt pipeline viewer:
<img width="1408" height="668" alt="image"
src="https://github.com/user-attachments/assets/429eef8c-aaac-4781-aafa-39ef0ffc7241"
/>

Diff of TTIR in Triton 3.3.1 vs 2.3.0:
<img width="1580" height="726" alt="image"
src="https://github.com/user-attachments/assets/a928c893-dd9a-4c3a-a048-14046e56a14c"
/>

CUDA & HIP:
<img width="1596" height="800" alt="image"
src="https://github.com/user-attachments/assets/c18800c3-cfad-4e5e-96de-ba92c9f236ea"
/>

## Implementation Details (and Notes for Reviewers)

- For Device Assembly View, I Implemented `MlirAsmParser` for parsing
MLIR assembly. Technically MLIR is not an assembly language, but there
is no better choice to make the source line map work w/ device view.
- I Implemented `MlirPassDumpParser` for processing MLIR optimization
pass dumps. I tried to subclass `LlvmPassDumpParser`, but they turn out
to be too different to worth doing it.
- `LlvmPassDumpParser` made some assumptions that do not hold true for
MLIR passed. Some effort is put to make sure that the passes are
properly diff-ed, since some passes can run multiple times and also
sometimes pass can be nested (i.e., some number of `before`s followed by
some number of `after`s)
- A lot of effort is put into `patch_triton` to make sure that the we
only compile the kernel without actually running it, and that needs to
work across all the versions we support.

## Steps to Run Locally

1. Clone https://github.com/ShawnZhong/compiler-explorer-infra.git
2. Install Triton to `/opt/compiler-explorer/triton`:
```sh
$ cd compiler-explorer-infra
$ ./bin/ce_install install triton
$ ls /opt/compiler-explorer/triton
# v2.2.0  v2.3.0  v2.3.1  v3.0.0  v3.1.0  v3.2.0  v3.3.0  v3.3.1
```
3. Clone https://github.com/ShawnZhong/compiler-explorer.git and
checkout branch `triton`
4. Run Compiler Explorer
```sh
make EXTRA_ARGS='--language triton' dev
```
5. Enjoy

---------

Co-authored-by: Matt Godbolt <matt@godbolt.org>
2025-07-30 10:15:28 -05:00
Jacob Panov c7056b31eb Fix llvm-mca tool preprocessing of debug directives (#7964)
This PR fixes the "unassigned file number" error in llvm-mca when
processing GCC-generated assembly with debug information #6795 .

**Problem**: GCC with `-g` flag generates `.loc` and `.file` debug
directives that cause llvm-mca to fail with "unassigned file number"
errors.

**Solution**: Filter out `.loc` and `.file` directives during assembly
preprocessing, similar to how other problematic directives are already
handled.

**Changes**:
- Add regex filtering for `.loc` and `.file` directives in
`rewriteAsm()`
- Make `rewriteAsm()` method public for testability
- Add comprehensive test coverage for debug directive removal

The fix is minimal, targeted, and follows the existing pattern of
directive filtering.
2025-07-30 10:00:09 -05:00
Jacob Panov 1a388a580f Fix NIM compiler ENOENT error when -c passed as options (#7952)
This PR addresses an issue that causes an `ENOENT` in the presence of the `-c` parameter being passed as an option in binary mode.
2025-07-30 09:55:17 -05:00
Matt Godbolt 8734c3e492 Update biome (#7956)
- latest biome, and fix its configuration
- fixes "static" content to be globally configured too (instead of
per-line)
- fixes issues:
  - imports fixed up
  - `Date.now()` vs `+new Date()`
  - some unused things `_` prefixed
 
After discussion with the team, turned off the unused parameter warning.
2025-07-28 10:34:46 -05:00
Partouf 818d2b50c4 more extensions 2025-07-27 19:40:26 +02:00
Partouf 6b2b3a8925 add cuda extension 2025-07-27 19:35:06 +02:00
Quinton Miller 33f433cb1f Crystal: support Intel assembly output syntax (#7940) 2025-07-27 14:44:02 +02:00
Patrick Quist 477eec3e70 apply waittimeseconds (#7868) 2025-07-27 14:42:44 +02:00