solang icon indicating copy to clipboard operation
solang copied to clipboard

Is it possible to use LLVM Pass module in Solang?

Open UESuperGate opened this issue 4 years ago • 7 comments

Hi there!

I'm curious about whether Solang supports loading LLVM Pass module to perform some preprocessing on the generated LLVM-IR.

For instance, we can use LLVM Pass module in clang like this: clang -Xclang -load -Xclang ../build/PlacementPass/libLLVMPassname.so demo.c -o demo

Can Solang do the same thing?

UESuperGate avatar Oct 08 '21 07:10 UESuperGate

As solang uses llvm, there is no reason why it should not support it. Right now it does not have the command line options and the hooks to make this happen though.

For what reason are you interested in this? Is there specific pass you have in mind?

seanyoung avatar Oct 08 '21 15:10 seanyoung

There are already smart contract vulnerability detection and automatic repair solutions. I'm thinking about that if we can use LLVM to compile smart contract source code, we can add these features to LLVM Pass module, which can be used in the process of compiling.

Some general optimization schemes on Solidity can also be applied to LLVM Pass, by the way.

UESuperGate avatar Oct 09 '21 07:10 UESuperGate

Ok, interesting. Do you have a specific pass in mind?

seanyoung avatar Oct 09 '21 10:10 seanyoung

I found a pretty interesting paper which provides a vulnerability detection method based on a series of well-defined dependency rules, and the corresponding patch scheme.

Therefore, I will try to optimize and port this set of programs to LLVM Pass though it's just a idea in my mind for now.

UESuperGate avatar Oct 09 '21 10:10 UESuperGate

ok. The reason I ask for a specific pass is that a) there is a something to test and develop against and b) there is a specific benefit today.

seanyoung avatar Oct 09 '21 19:10 seanyoung

Got it. Thanks for your reply!

UESuperGate avatar Oct 10 '21 01:10 UESuperGate

Let me know if you make any progress writing the pass, I'll will look at adding this to solang when needed.

seanyoung avatar Oct 11 '21 09:10 seanyoung