[CppEmitter] Improve code readability
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Now we use mlir-translate to convert the emitc dialect to cpp file,
For the following test, If we can fix the following case1 and case2 issue, then the code is more readability
```cpp
void member_of_pointer(mystruct* v1, int32_t v2, size_t v3) {
mystruct* v4;
v4 = v1; **// case1: the variable v4 is redundant, use v1 directly is better ?**
v4->a = v2;
int32_t v5 = v4->b;
int32_t v6;
v6 = v5;
int32_t v7 = (v4->c)[v3];
v6 = v7; **// case2: maybe use v6 = (v4->c)[v3]; to avoid using new temporary variable v7**
(v4->d)[v3] = v2;
return;
}
```
* test: https://llvm.godbo.lt/z/YnErWjvjn
Contributor guide
Research direction
Start by reproducing the linked test through mlir-translate and inspect the generated C++ for the two marked cases. Trace how the emitc dialect represents these assignments and determine whether the redundant temporaries can be removed without changing semantics. Done means the generated output is more direct for both cases and the linked test still passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100