emscripten-core / emscripten-core/emscripten
[DWARF] Strange line information at O1
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Compiling the following example with `-g -O1` with emcc 2.0.12 produces a bunch of strange entries in the DWARF line table:
```
#include
int a = 0;
void Func(int a) {
{
int a = 2;
{
int a = 3;
printf("%p %d\n", &a, a);
}
printf("%p %d\n", &a, a);
}
printf("%p %d\n", &a, a);
}
int main() {
Func(1);
printf("%p %d\n", &a, a);
}
```
I get a line table looking like this:
```
0x0000000000000006 4 0 1 0 0 is_stmt
0x000000000000001a 6 9 1 0 0 is_stmt prologue_end
0x0000000000000021 9 7 1 0 0 is_stmt
0x0000000000000028 8 11 1 0 0 is_stmt
0x000000000000002f 9 7 1 0 0 is_stmt
0x0000000000000044 11 5 1 0 0 is_stmt
0x0000000000000046 11 27 1 0 0
0x000000000000004b 11 5 1 0 0
0x0000000000000058 9 7 1 0 0 is_stmt
0x000000000000005b 11 5 1 0 0 is_stmt
0x0000000000000063 13 3 1 0 0 is_stmt
0x0000000000000065 13 25 1 0 0
0x000000000000006a 13 3 1 0 0
0x0000000000000077 9 7 1 0 0 is_stmt
0x000000000000007a 13 3 1 0 0 is_stmt
0x000000000000007f 14 1 1 0 0 is_stmt
0x0000000000000088 14 1 1 0 0 is_stmt end_sequence
```
As you can see, the execution seems to jump back to line 9 before every printf. AFAICT the code offsets for those jumping lines are instructions pushing the first argument to printf (the string). That argument is just an `i32.const 1024`, which means the line table entries are bogus.
Contributor guide
Assessment
This issue has not been assessed yet.