Skip to content
 
 

Repository files navigation

VSCode LLVM Compiler Explorer

Download from VSCode marketplace.

This is a tool for compiler developers of LLVM. This vscode extension can support exploring LLVM IR and machine IR after each pass.

Features

  1. Run a clang or rustc command and explore preprocessing phase (C/C++ only), clang AST building phase (C/C++ only), each phase of LLVM passes, and final generated assembly code.
  2. Compare difference between IRs before and after running a pass.
  3. Support custom clang or modified version.
  4. NEW: Support for Rust compiler (rustc) - view LLVM IR and assembly output from Rust code!

How to use

For C/C++ (Clang)

  1. Click 'New config' for creating a new configuration
  2. Type your command to compile the file (e.g., clang -O2 main.c)

  1. (Optional) If you want to focus on one function. You can type the function name in the 'filter function' field. Please note, this function name should be mangle name if it's C++. Then, click the command name to run the command.
  2. Now, you can explore the IRs after each pass.

For Rust (rustc)

  1. Click 'New config' for creating a new configuration
  2. Type your rustc command to compile the file, for example:
    • rustc main.rs --emit llvm-ir,asm -O
    • rustc main.rs --emit llvm-ir,asm -C opt-level=3
  3. Click the command name to run the command
  4. View the LLVM IR and assembly output in the pipeline view

For more details on Rust support, see RUST_SUPPORT.md.

Compare Mode

To debug a pass, you may want to compare a clang command with and without the pass. Or you want to debug a different version of clang with the stable version. This extension can help you to compare the difference between two IRs after each pass.

Source2Asm Mapping View

Inspired by Compiler Explorer, this extension can highlight the mapping between source code and the assembly code.

Run Print Pass to View CallGraph/CFG/DOMTree

There is a list of utility passes available in this plugin. You can run these passes to view the CallGraph, CFG, and DOMTree of an IR file.

When you open an IR file, you can click the 'Print Call Graph' button to generate a callgraph.dot file. Then, you can use the Graphviz plugin to view the callgraph.

Note: You need to have 'opt' tool in your PATH (or specify the path in settings) and installed Graphviz preview plugin.

Syntax Highlighting

This plugin provides syntax highlighting for Clang AST and assembly language. You may need to install additional LLVM syntax highlighting plugins, there are some options:

About

VSCode RUSTC LLVM Compiler Explorer

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages