Open Nirhar opened 3 months ago
As a first time contributor to this project, I'd like to ask some questions:
I am new to rust, so if you find anything that goes against conventional programming style in rust, please let me know!
- Is there any formatting rules that I have to follow, or do we use any tools like clang-format?
Have you checked our contributing guide https://solang.readthedocs.io/en/latest/contributing.html?
One way to write a test for this is to add test to
tests/codegen_tests/..
which does something like the following:contract C { function foo() public returns (bool) { int a = 100; return a < 200; } function bar() public returns (bool r) { int a = 100; int b = 200; r = a < b; } }
Make sure the test ensures that the code generation constant folds the expressions and generates
false
for both functions.
I've added a similar test case as you've suggested, and when I try to execute it as:
<path-to-solang> compile --target polkadot --emit cfg
I find ty:bool %r = (signed less int256 100 < int256 200)
which suggests to me that my optimization did not kick in. I'm not sure if cfg is the right place to investigate the results of optimizations. I also tried to emit llvm-ir to inspect (with --emit llvm-ir
), however, nothing was printed to the console when I do so. Can you please suggest the right IR format where I should be able to see the results of my code changes?
This patch supports evaluation of comparison expressions with constants as operands during compile time.
Fixes #755