Skip to content

No local variable name info with -g4 in Emscripten 1.37.0 #5094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xiyanggudao opened this issue Mar 30, 2017 · 4 comments
Closed

No local variable name info with -g4 in Emscripten 1.37.0 #5094

xiyanggudao opened this issue Mar 30, 2017 · 4 comments

Comments

@xiyanggudao
Copy link

After upgrade Emscripten from 1.35 to 1.37, the JS code generate by -g4 has no local variable name info, it looks like they were minimized when compiled to BC. Is there any method to keep these info?
Thanks.

@kripken
Copy link
Member

kripken commented Mar 30, 2017

That's surprising, do you have a testcase showing the issue?

@xiyanggudao
Copy link
Author

I use the llvm-dis to transform bc to assembler, and find the local variable name info has lost. So I guess it is because the upgrade of llvm.

A a testcase hello_world.cpp
#include <stdio.h>
int main() {
int local_val;
scanf("%d", &local_val);
printf("hello, world! %d\n", local_val);
return 0;
}

compile command
emcc hello_world.cpp -o hello_world.js -g4

The javascript code. local variable “local_val” was transformed with "$2"
function _main() {
var $0 = 0, $1 = 0, $2 = 0, $vararg_buffer = 0, $vararg_buffer1 = 0, label = 0, sp = 0;
sp = STACKTOP;
STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abortStackOverflow(32|0);
$vararg_buffer1 = sp + 8|0;
$vararg_buffer = sp;
$1 = sp + 12|0;
$0 = 0;
HEAP32[$vararg_buffer>>2] = $1; //@line 7 "hello_world.cpp"
(_scanf(488,$vararg_buffer)|0); //@line 7 "hello_world.cpp"
$2 = HEAP32[$1>>2]|0; //@line 8 "hello_world.cpp"
HEAP32[$vararg_buffer1>>2] = $2; //@line 8 "hello_world.cpp"
(_printf(491,$vararg_buffer1)|0); //@line 8 "hello_world.cpp"
STACKTOP = sp;return 0; //@line 9 "hello_world.cpp"
}

@kripken
Copy link
Member

kripken commented Mar 31, 2017

LLVM updates can change that, but on latest incoming (1.37.9), I see this output:

function _main() {
 var $0 = 0, $local_val = 0, $retval = 0, $vararg_buffer = 0, $vararg_buffer1 = 0, label = 0, sp = 0;
 sp = STACKTOP;
 STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abortStackOverflow(32|0);
 $vararg_buffer1 = sp + 8|0;
 $vararg_buffer = sp;
 $local_val = sp + 12|0;
 $retval = 0;
 HEAP32[$vararg_buffer>>2] = $local_val; //@line 4 "a.cpp"
 (_scanf(756,$vararg_buffer)|0); //@line 4 "a.cpp"
 $0 = HEAP32[$local_val>>2]|0; //@line 5 "a.cpp"
 HEAP32[$vararg_buffer1>>2] = $0; //@line 5 "a.cpp"
 (_printf(759,$vararg_buffer1)|0); //@line 5 "a.cpp"
 STACKTOP = sp;return 0; //@line 6 "a.cpp"
}

Looks like local_val is there, so perhaps the last LLVM update changed things again.

@xiyanggudao
Copy link
Author

OK, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants