JLM: A research compiler based on the RVSDG IR

Related tags

Web programming jlm
Overview

JLM: A research compiler based on the RVSDG IR

Tests

Jlm is an experimental compiler/optimizer that consumes and produces LLVM IR. It uses the Regionalized Value State Dependence Graph (RVSDG) as intermediate representation for optimizations.

Dependencies

  • Clang/LLVM 11

Bootstrap

export LLVMCONFIG=
   
    
make submodule
make all

   

Please ensure that LLVMCONFIG is set to the correct version of llvm-config as stated in dependencies.

Publications

An introduction to the RVSDG and the optimizations supported by jlm can be found in the following articles:

N. Reissmann, J. C. Meyer, H. Bahmann, and M. Sjรคlander "RVSDG: An Intermediate Representation for Optimizing Compilers" ACM Transactions on Embedded Computing Systems (TECS), vol. 19, no. 6, Dec. 2020. https://dl.acm.org/doi/abs/10.1145/3391902

H. Bahmann, N. Reissmann, M. Jahre, and J. C. Meyer "Perfect Reconstructability of Control Flow from Demand Dependence Graphs" ACM Transactions on Architecture and Code Optimization (TACO), no. 66, Jan. 2015. https://dl.acm.org/doi/10.1145/2693261

N. Reissmann, J. C. Meyer, and M. Sjรคlander "RVSDG: An Intermediate Representation for the Multi-Core Era" Nordic Workshop on Multi-Core Computing (MCC), Nov. 2018. https://www.sjalander.com/research/pdf/sjalander-mcc2018.pdf

Comments
  • I can't compile it.

    I can't compile it.

    build/libjlm.a(CommandLine.la):(.rodata._ZTIN4llvm2cl15OptionValueCopyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE[_ZTIN4llvm2cl15OptionValueCopyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE]+0x10): undefined reference to `typeinfo for llvm::cl::GenericOptionValue' clang-14: fatal error: linker command failed with exit code 1 (use -v to see invocation)

    I am getting the error above when I type "make all". "$LLVMCONFIG --version" shows 14.0.6.

    Have you seen this error or fixed it? Thanks in advance. Screenshot 2022-09-28 at 1 23 38 AM

    help wanted 
    opened by gino-comp 6
  • Generated executable doesn't terminate

    Generated executable doesn't terminate

    The attached file executes instantaneous when compiled with clang while executed for 20 minutes before killing it when compiled with jlc.

    does-not-terminate.zip

    opened by sjalander 4
  • Alias Analysis crashes when locationSet contains only DummyLocations

    Alias Analysis crashes when locationSet contains only DummyLocations

    Alias analysis crashes if a locationSet contains only DummyLocations. DummyLocations are skipped when memoryNodeMap is populated in ConstructPointsToGraph. As a consequence FindModuleEscapingMemoryNodes crashes when trying to access the map for the "dummy" locationSet.

    As far as I can tell this can be fixed by either checking if the set is a key of memoryNodeMap and continuing otherwise, or by accessing memoryNodeMap even for DummyLocations.

    This can be reproduced by running
    jlc jlm-eval-suit/hls-test-suite/src/test-array.c followed by jlm-opt --llvm --AASteensgaardBasic -o /tmp/tmp-test-array-jlm-opt-out.ll /tmp/tmp-test-array-clang-out.ll (the -J option to explicitly specify jlm-opt passes in jlc seems to not be implemented)

    bug 
    opened by davidmetz 2
  • Linking causes a jive::compiler_error

    Linking causes a jive::compiler_error

    jlc -DNDEBUG -w -Werror=date-time '-DVERSION="1.00"' '-DCOMPDATE="today"' '-DCFLAGS=""' '-DHOSTNAME="thishost"' -o mason.c.o -c mason.c

    Adding -03 to the above line gives the following error: terminate called after throwing an instance of 'jive::compiler_error' what(): Invalid operand region. Aborted (core dumped)

    jlc -O3 mason.c.o -o mason

    clang: warning: mason.c.o: 'linker' input unused [-Wunused-command-line-argument] clang: warning: argument unused during compilation: '-emit-llvm' [-Wunused-command-line-argument] terminate called after throwing an instance of 'jive::compiler_error' what(): Invalid operand region. Aborted (core dumped)

    mason.zip

    bug 
    opened by sjalander 2
  • Jlc opt flags

    Jlc opt flags

    Must have deleted a line by mistake when adding the previous changes as to commits. The opts.jlmopts was never set in cmdline.cpp so didn't matter if -J was specified for jlc.

    opened by sjalander 2
  • LLVM 10

    LLVM 10

    Port of jlm to work with LLVM 10. Added MaybeAlign to memory operations. Added llvm fneg support to libjlm's ir operators.

    All checks pass and the complete polyench.

    Based on the make-targets branch.

    opened by sjalander 2
  • LLVM warnings

    LLVM warnings

    These changes address most warnings from clang but maybe should be solved differently. So this is to start the discussion on how the warnings should be addressed.

    opened by sjalander 2
  • jive: Bumped jive to version that use .hpp and .cpp

    jive: Bumped jive to version that use .hpp and .cpp

    The file endings in jive has been renamed to .hpp and .cpp from .h and .c, which required all includes in jlm to be updated and a make target for %.c to be changed to %.cpp

    opened by sjalander 2
  • jlc produces wrong result as compared to LLVM

    jlc produces wrong result as compared to LLVM

    Commands for replicating the error jlc -I$(CSMITH_HOME)/runtime -O test-wrong-result.c -o test.jlc; clang -I$(CSMITH_HOME)/runtime -O test-wrong-result.c -o test.clang; ./test.jlc > jlc.output ./test.clang > clang.output diff jlc.output clang.output

    wrong-result.zip

    bug 
    opened by sjalander 2
  • jlm-print crashes for -O2 optimization level and jlm-opt

    jlm-print crashes for -O2 optimization level and jlm-opt

    jlm-print crashes when inputting the floyd-warshall benchmark from the polybench-jlm benchmark suite if it is first optimized with jlm-opt, and subsequently clang-opt at optimization level -O2.

    Steps to reproduce:

    clang -S -emit-llvm -Xclang -disable-llvm-passes -o fw.ll medley/floyd-warshall/floyd-warshall.c -Iutilities
    jlm-opt --llvm fw.ll > fw-jlm.ll
    opt -S -O2 -o fw-opt.ll fw-jlm.ll
    jlm-print --j2rx --file fw-opt.ll > fw.xml
    

    Terminates with the following stack trace:

    terminate called after throwing an instance of 'jlm::error'
      what():  invalid type.
    
    Program received signal SIGABRT, Aborted.
    (gdb) up
    ...
    (gdb) up
    #6  0x0000555555672b93 in jlm::check_operands (operation=..., operands=std::vector of length 3, capacity 3 = {...})
        at libjlm/src/ir/tac.cpp:39
    39                              throw jlm::error("invalid type.");
    (gdb) list
    34              if (operands.size() != operation.narguments())
    35                      throw jlm::error("invalid number of operands.");
    36
    37              for (size_t n = 0; n < operands.size(); n++) {
    38                      if (operands[n]->type() != operation.argument(n).type())
    39                              throw jlm::error("invalid type.");
    40              }
    41      }
    42
    43      static void
    (gdb) print operands[n]->type()
    $10 = (const jive::type &) @0x555555856240: {_vptr.type = 0x5555557dbe38 <vtable for jlm::vectortype+16>}
    (gdb) print operation.argument(n).type()
    $11 = (const jive::type &) @0x555555856e10: {_vptr.type = 0x5555557dbd58 <vtable for jive::bittype+16>}
    
    bug 
    opened by sigvesn 2
  • jlm-print crashes for some programs generated by jlm-opt

    jlm-print crashes for some programs generated by jlm-opt

    jlm-print crashes on programs compiled with certain optimizations enabled, such as -loop-unroll. However, this happens only after it the bytecode is passed through jlm-opt, even when this is run without performing any optimizations.

    Tested on programs from the polybench benchmark suite: https://github.com/phate/polybench-jlm.

    Steps to reproduce (requires both the jlm-opt and opt steps in this specific order to crash)

    clang -S -emit-llvm -Xclang -disable-llvm-passes -o 2mm.ll linear-algebra/kernels/2mm/2mm.c -Iutilities
    jlm-opt --llvm 2mm.ll > 2mm-jlm.ll
    opt -S -loop-unroll -o 2mm-opt.ll 2mm-jlm.ll
    jlm-print --j2rx --file 2mm-opt.ll
    

    throws the follwing

    terminate called after throwing an instance of 'jlm::error'
      what():  expected at least two arguments.
    

    with stack trace:

    Program received signal SIGABRT, Aborted.
    __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50                                                                  
    50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.                                                                 
    (gdb) bt
    #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50                                                              
    #1  0x00007ffff40e6535 in __GI_abort () at abort.c:79
    #2  0x00007ffff44ae983 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6                                                          
    #3  0x00007ffff44b48c6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6                                                          
    #4  0x00007ffff44b4901 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6                                            
    #5  0x00007ffff44b4b34 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6                                                 
    #6  0x00005555555ec60c in jlm::phi_op::phi_op(std::vector<jlm::cfg_node*, std::allocator<jlm::cfg_node*> > const&, jive::type const&) ()
    #7  0x000055555564b737 in jlm::create_phi_tac ()
    #8  0x000055555564e7d8 in jlm::convert_phi_instruction(llvm::Instruction*, std::vector<std::unique_ptr<jlm::tac, std::default_delete<jlm
    ::tac> >, std::allocator<std::unique_ptr<jlm::tac, std::default_delete<jlm::tac> > > >&, jlm::context&) ()                             
    #9  0x00005555556517ab in jlm::convert_instruction(llvm::Instruction*, std::vector<std::unique_ptr<jlm::tac, std::default_delete<jlm::ta
    c> >, std::allocator<std::unique_ptr<jlm::tac, std::default_delete<jlm::tac> > > >&, jlm::context&) ()                                 
    #10 0x00005555555cd0e1 in jlm::convert_basic_blocks(llvm::SymbolTableList<llvm::BasicBlock>&, jlm::context&) ()                        
    #11 0x00005555555cd8d2 in jlm::create_cfg(llvm::Function&, jlm::context&) ()                                                           
    #12 0x00005555555cdb4b in jlm::convert_function(llvm::Function&, jlm::context&) ()                                                     
    #13 0x00005555555ce379 in jlm::convert_globals(llvm::Module&, jlm::context&) ()                                                        
    #14 0x00005555555ce46e in jlm::convert_module(llvm::Module&) ()
    #15 0x0000555555567796 in main ()
    

    The same error is encountered for every such fail. The -lcssa and -licm optimizations fail for all benchmarks programs, and -indvars, -loop-deletion, -loop-idiom, -loop-rotate, -loop-sink, -loop-unroll, and -loop-unswitch fail for the following benchmarks: 2mm, 3mm, adi, cholesky, correlation, covariance, deriche, doitgen, fdtd-2d, floyd-warshall, gemm, gemver, gramschmidt, heat-3d, jacobi-2d, ludcmp, lu, mvt, nussinov, seidel-2d, symm, syr2k, syrk, and trmm.

    bug 
    opened by sigvesn 2
  • Annotation takes almost 2 minutes for a file with 5000 lines of code

    Annotation takes almost 2 minutes for a file with 5000 lines of code

    jlc -DNDEBUG -Jinv -Jdne -Jivt -Jinv -Jdne -Jinv -Jdne -Jcne -Jdne -Jpll -Jinv -Jdne -Jurl -Jinv -J=print-cne-stat -J=print-dne-stat -J=print-inv-stat -J=print-ivt-stat -J=print-pull-stat -J=print-unroll-stat -J=print-rvsdg-optimization -Jprint-aggregation-time -Jprint-annotation-time -Jprint-cfr-time -w -Werror=date-time -J=s=jlm-stats.log -o constpool.c.o -c constpool.c

    constpool.zip

    opened by sjalander 0
  • Alias Analysis fails

    Alias Analysis fails

    Compilation fails with: jlc -DNDEBUG -Jaa-steensgaard -w -Werror=date-time -o sim4b1.c.o -c sim4b1.c terminate called after throwing an instance of 'jlm::error' what(): Expected at least one memory state. Aborted (core dumped) make: *** [Makefile:3: all] Error 1

    SIBsim4.zip

    bug 
    opened by phate 0
  • jlc does not handle escaped characters in strings correctly

    jlc does not handle escaped characters in strings correctly

    jlc -DPROJ_SRC_DIR="." -o test.c.o -c test.c

    test.c:36:31: error: expected expression read_dmatrix(&Dist_demux, INPUT_FILE); ^ test.c:9:20: note: expanded from macro 'INPUT_FILE' #define INPUT_FILE PROJ_SRC_DIR "/Dist_demux" ^ :1:22: note: expanded from here #define PROJ_SRC_DIR . ^ 1 error generated.

    While the following works jlc -DPROJ_SRC_DIR=\".\" -o test.c.o -c test.c

    string.zip

    opened by sjalander 0
  • Compiling perlbench ends with a core dump

    Compiling perlbench ends with a core dump

    Executing:

    jlc -c -o dist/IO/poll.o -DSPEC -DNDEBUG -DPERL_CORE -I. -Idist/IO -Icpan/Time-HiRes -Icpan/HTML-Parser -Iext/re -Ispecrand -DDOUBLE_SLASHES_SPECIAL=0 -DSPEC_AUTO_SUPPRESS_OPENMP -D_LARGE_FILES -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -DSPEC_LINUX_X64 -DSPEC_LP64 dist/IO/poll.c

    Results in:

    This should not have happened! UNREACHABLE executed at libjlm/src/frontend/llvm/llvm2jlm/instruction.cpp:52 Aborted (core dumped)

    opened by sjalander 3
Owner
Nico Reissmann
Nico Reissmann
A Blog & RSS system written in Rust based on Luke Smith's LB.

OB - Oliver's Blog Script A Blog and RSS system written in Rust. Features Converts blog entries written in Markdown into HTML. โœ?? Keeps a rolling blo

Oliver Brotchie 19 Aug 28, 2022
A minimal and flexible blog generator based on GitHub Gists.

gisture Utilizing GitHub Gists as a Blogging Platform A minimal and flexible blog generator based on GitHub Gists with SEO, Templating, Syntax Highlig

Mufeed VH 26 Dec 27, 2022
A web application to configuration Caddy based on MoonZoon.

Cream A web application to configuration Caddy based on MoonZoon. MoonZoon is a Rust Fullstack Framework. Live demo Run on a local machine Check you'v

Tw 4 Sep 19, 2022
๐Ÿ“ Web-based, reactive Datalog notebooks for data analysis and visualization

Percival is a declarative data query and visualization language. It provides a reactive, web-based notebook environment for exploring complex datasets, producing interactive graphics, and sharing results.

Eric Zhang 486 Dec 28, 2022
A GUI frontend in Rust based on web-view

neutrino I am not working anymore on this project. If you want to become a maintainer of neutrino, please answer to this issue. Preamble Docs | Repo |

null 287 Nov 25, 2022
Based on the Book Computer Graphics from Scratch

raytracing_basic v1 Description Based on the Book Computer Graphics from Scratch Dependencies Good Web Game Build and run cargo build --release

null 2 Jan 28, 2022
A WebGPU implementation based on the excellent wgpu crate.

A WebGPU implementation based on the excellent wgpu crate.

Ben Noordhuis 3 Jul 30, 2022
๐Ÿชช Session-based user authentication for Axum.

axum-login ?? Session-based user authentication for Axum. ?? Overview axum-login is a Tower middleware providing session-based user authentication for

Max Countryman 99 Jan 5, 2023
Layers, extractors and template engine wrappers for axum based Web MVC applications

axum-template Layers, extractors and template engine wrappers for axum based Web MVC applications Getting started Cargo.toml [dependencies] axum-templ

Altair Bueno 11 Dec 15, 2022
HTTP Proxy based solution for real-time interception and prioritization of SQL queries.

starproxy โš ๏ธ starproxy is a prototype: Not currently used in production, but will likely be some day. Table of Contents starproxy Table of Contents Ba

Will Eaton 5 Mar 6, 2023
OpenAPI-based test coverage analysis tool that helps teams improve integration test coverage in CI/CD pipelines

Ready-to-use OpenAPI test coverage analysis tool that helps teams improve integration CoveAPI is an advanced test coverage analysis tool based on the

Yasser Tahiri 18 Aug 3, 2023
axum-serde is a library that provides multiple serde-based extractors and responders for the Axum web framework.

axum-serde ?? Overview axum-serde is a library that provides multiple serde-based extractors / responses for the Axum web framework. It also offers a

GengTeng 3 Dec 12, 2023
Motion detection & video recording software based on OpenCV, built for research on Bumblebees

BombusCV Motion detection & video recording software based on OpenCV, built for research on Bumblebees (hence the name). Index Use case Examples Insta

Marco Radocchia 7 Dec 27, 2022
command line tools for coprolite research (paleontology and archaeology): estimate the producer's body mass based on coprolite diameter by the use of regression models

OVERVIEW OF COPROSIZE coprosize employs power, exponential and cubic regression models allowing to estimate the producer's body mass based on coprolit

Piotr Bajdek 7 Nov 25, 2022
C-like language compiler, the final project of ZJU Compiler Principle course

cc99 cc99 (not cc98.org) is a C-like language compiler, which is the final project of ZJU Compiler Principle course. It supports many of the C99 langu

Ralph 37 Oct 18, 2022
A Game Boy research project and emulator written in Rust

Mooneye GB Mooneye GB is a Game Boy research project and emulator written in Rust. The main goals of this project are accuracy and documentation. Some

Joonas Javanainen 802 Dec 28, 2022
๐Ÿ’ฅ Fast State-of-the-Art Tokenizers optimized for Research and Production

Provides an implementation of today's most used tokenizers, with a focus on performance and versatility. Main features: Train new vocabularies and tok

Hugging Face 6.2k Jan 2, 2023
Reviving the Research Edition Unix speak command

This repository contains the source code of Unix speak program that appeared in the Third (1973) to Sixth (1975) Research Unix editions, slightly adjusted to run on a modern computer. Details on the code's provenance and the methods employed for reviving it can be found in this blog post.

Diomidis Spinellis 31 Jul 27, 2022
๐Ÿ’ฅ Fast State-of-the-Art Tokenizers optimized for Research and Production

Provides an implementation of today's most used tokenizers, with a focus on performance and versatility. Main features: Train new vocabularies and tok

Hugging Face 6.2k Jan 5, 2023