Resolc is live on Compiler Explorer

We have integrated resolc into Compiler Explorer–a popular web application for inspecting and understanding the assembly code generated by various compilers.

When a Solidity smart contract is compiled, the Ethereum Solidity solc compiler is used as the Solidity frontend for compiling Solidity down to its intermediate representation (IR) called Yul IR. resolc then lowers Yul to LLVM IR and uses LLVM for further optimization and compilation into RISC-V. During the compilation process, debug information can be requested.

Through Compiler Explorer you can now explore the output of the compilation process (screenshots are also provided below):

  1. Choose between two input languages:
    • Solidity
    • Yul (Solidity IR)
  2. Choose a resolc compiler
  3. View the assembly
    • PolkaVM assembly (if enabling the option Compile to binary object)
    • RISC-V (64 bits) assembly
  4. View intermediate results (click + or Add new):
    • LLVM IR
      • Optimized (if enabling the option Show Optimized)
      • Unoptimized
    • Yul
      • Only available when Solidity is the input language
  5. Optionally, pass additional arguments to the compiler via the Compiler options field.
    • Note: Unlike most other compilers, -Oz is enabled by default.

Limitations:

  1. Source mappings are currently only available for the Yul IR input language.
    • Currently, solc propagates Solidity source locations to Yul only as comments, which resolc does not yet parse. We hope to improve this once ethdebug format lands in an upstream release.
  2. The assembly output is truncated at 5K LOC. Thus, it is currently suitable for smaller contracts and you may need to isolate parts of your code.

Screenshot 1:

  • Input: Yul
  • Output: RISC-V and LLVM IR optimized

Screenshot 2:

  • Input: Solidity
  • Output: PolkaVM assembly and Yul

:backhand_index_pointing_right: Please let us know if you spot a translation bug or a cool optimization opportunity in your code! :slightly_smiling_face:

3 Likes