ustb-owl / mimic Goto Github PK
View Code? Open in Web Editor NEWMimiC is a compiler of C subset (extended SysY language) by USTB NSCSCC team.
License: GNU General Public License v3.0
MimiC is a compiler of C subset (extended SysY language) by USTB NSCSCC team.
License: GNU General Public License v3.0
When I try to compile some simple program, like (https://github.com/pku-minic/compiler-dev-test-cases/blob/master/testcases/lv9/16_sort2.c), the compiler always gives the following error:
demo.c:4:14: error: id: putint, conflicted function type
the putint definition is defined in src/main.cpp
, but I don't know why it is a conflicted function type.
Hello! I apologize for bothering you during the holiday, but I would like to report a bug.
I have discovered that the compiler is an excellent resource for learning. Before delving into the source code, I plan to test it with the provided test cases from this link: https://gitlab.eduxiji.net/windcome/sysyruntimelibrary. To do so, I am using the Sysy RISCV library found here: https://github.com/pku-minic/sysy-runtime-lib/.
For testing purposes, I have chosen to test 3 backends (C, AARCH32, RISCV32) and enable or disable optimizations. As I don't currently possess the ARM or RISCV board, I'm utilizing QEMU-static to test the cross-compiled binary executable files. Here is my current testing environment:
$ uname -osr
Linux 5.10.102.1-microsoft-standard-WSL2 GNU/Linux
$ clang --version
clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/sbin
$ qemu-riscv32-static --version
qemu-riscv32 version 8.0.0
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
Almost all the testcases passed, except for the riscv backend with -O2. There are three tests that failed, which are fft0, fft1, fft2. Since all backends generate the same IR, I don't think the bug is in the middle-end optimization passes.
Here is the build script:
mmcc = '../build/mmcc -S -ta riscv32'
exe = 'temp-rv'
asm = 'temp-rv.s'
obj = 'temp-rv.o'
asm_flags = '-target riscv32-unknown-linux-elf -march=rv32im -mabi=ilp32'
cc = f'clang {asm} -c -o {obj} {asm_flags}'
lib_flags = f'-L../sysy_lib/riscv32 -lsysy'
link = f'ld.lld {obj} {lib_flags} -o {exe}'
simu = f'qemu-riscv32-static ./{exe}'
After conducting some debugging, I found that the invalid instruction in fft0
is as follows:
00011c44 <.Lpcrel_hi30>:
11c44: 97 22 00 00 auipc t0, 2
11c48: 83 a2 02 0b lw t0, 176(t0)
11c4c: 23 22 54 e0 sw t0, -508(s0)
11c50: 13 83 02 00 mv t1, t0
11c54: b3 82 62 00 add t0, t0, t1
11c58: 23 22 54 e0 sw t0, -508(s0)
11c5c: b3 02 b5 01 add t0, a0, s11
11c60: 23 20 54 f4 sw t0, -192(s0)
11c64: 93 92 22 00 slli t0, t0, 2
11c68: 23 22 54 f4 sw t0, -188(s0)
11c6c: 83 22 c4 de lw t0, -532(s0)
11c70: 03 23 44 f4 lw t1, -188(s0)
11c74: b3 82 62 00 add t0, t0, t1
11c78: 23 2a 54 f4 sw t0, -172(s0)
11c7c: 83 a2 02 00 lw t0, 0(t0)
11c80: 23 24 54 f4 sw t0, -184(s0)
11c84: 03 23 44 e0 lw t1, -508(s0)
11c88: 23 20 53 00 sw t0, 0(t1) <--------- invalid
This can be verified using gdb:
(gdb) target remote :1234
Remote debugging using :1234
0x00012c64 in ?? ()
(gdb) b *0x11c84
Breakpoint 1 at 0x11c84
(gdb) c
Continuing.
Breakpoint 1, 0x00011c84 in ?? ()
(gdb) si
0x00011c88 in ?? ()
(gdb) si
Program received signal SIGSEGV, Segmentation fault.
0x00011c88 in ?? ()
However, I am currently unsure of how to proceed and locate the bug. If you have the time, could you please take a look? Your assistance would be greatly appreciated!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.