summaryrefslogtreecommitdiff
path: root/src/ast_utils.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-04-28 10:48:27 -0700
committerGitHub <noreply@github.com>2017-04-28 10:48:27 -0700
commit5d4f9eb82226acc0fdb5e2dea1a04e17c340c371 (patch)
treeb1b18217aec65f04da0080a1d6d2266489d56db7 /src/ast_utils.h
parenta0b162d13c7e8d5df1f1b6e33efd4d9e3f699aa9 (diff)
downloadbinaryen-5d4f9eb82226acc0fdb5e2dea1a04e17c340c371.tar.gz
binaryen-5d4f9eb82226acc0fdb5e2dea1a04e17c340c371.tar.bz2
binaryen-5d4f9eb82226acc0fdb5e2dea1a04e17c340c371.zip
Preserve debug info through the optimizer (#981)
* add debugInfo option to passes, and use it to keep debug info alive through optimizations when we need it * add fib testcase for debug info * when preserving debug info, do not move code around call-imports, so debug info intrinsics remain stationary * improve wasm-module-building handling of the single-threaded case: don't create workers, which is more efficient and also nicer for debugging * process debug info in a more precise way, reordering it from being after the node (as it was a comment in JS) to before the node * remove unreachable hack for debug info, which is no longer needed since we reorder them, and make sure to finalize blocks in which we reorder
Diffstat (limited to 'src/ast_utils.h')
-rw-r--r--src/ast_utils.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h
index 00b755bf7..17627d959 100644
--- a/src/ast_utils.h
+++ b/src/ast_utils.h
@@ -73,10 +73,12 @@ struct BreakSeeker : public PostWalker<BreakSeeker> {
struct EffectAnalyzer : public PostWalker<EffectAnalyzer> {
EffectAnalyzer(PassOptions& passOptions, Expression *ast = nullptr) {
ignoreImplicitTraps = passOptions.ignoreImplicitTraps;
+ debugInfo = passOptions.debugInfo;
if (ast) analyze(ast);
}
bool ignoreImplicitTraps;
+ bool debugInfo;
void analyze(Expression *ast) {
breakNames.clear();
@@ -187,7 +189,14 @@ struct EffectAnalyzer : public PostWalker<EffectAnalyzer> {
}
void visitCall(Call *curr) { calls = true; }
- void visitCallImport(CallImport *curr) { calls = true; }
+ void visitCallImport(CallImport *curr) {
+ calls = true;
+ if (debugInfo) {
+ // debugInfo call imports must be preserved very strongly, do not
+ // move code around them
+ branches = true; // !
+ }
+ }
void visitCallIndirect(CallIndirect *curr) { calls = true; }
void visitGetLocal(GetLocal *curr) {
localsRead.insert(curr->index);