willi19 / swpp202301-compiler-team6

MIT License
0 stars 0 forks source link

[Sprint 3] Add function inline pass #37

Closed sharaelong closed 1 year ago

sharaelong commented 1 year ago

Overview

This pull request implements function inline pass. Inliner pass is implemented in llvm already, but I tried to add architecture-dependent conditions for deciding whether this function has to be inlined or not. Specifically I considered these 3 properties:

Implementation

First iterate through all functions in module. Check basic inlining conditions and above criteria.

Unit tests

  1. One of the most important usage of inline pass is inlining malloc_upto_8. First tests is responsible for this.
  2. Check if cycle detection logic is well designed. functionA and functionB calls each other.
  3. max calls fact internally. So only max has to be inlined in main function.
sharaelong commented 1 year ago

I found that usage of both heap2stack and functioninline pass makes runtime error in matmul2.

willi19 commented 1 year ago

Today, we found out that error was due to two reason. First returning :all in heap2stack passed incorrect analysis to other pass. Second spilled register in main function are accessed by the sp register but heap2stack update the sp so this caused incorrect output. This can be fixed by changing heap2stack to allocated stack memory at the beginning of the program.

germanium32 commented 1 year ago

Fairly simple logic(detecting block graph structure then inlining), so I have no doubt about this implementation.

LGTM!

sharaelong commented 1 year ago

I fixed bug that found on offline session: matmul2 main logic function is inlined even it is bigger than my threshold.

sharaelong commented 1 year ago

Fairly simple logic(detecting block graph structure then inlining), so I have no doubt about this implementation.

LGTM!

Actually, there was a bug!! haha... but it was subtle =)