aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-03 15:59:11 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-03 15:59:11 -0800
commit3d4a6d6d24fc5a220ba4b32d9bdae069389a084e (patch)
tree9d56985453e9b545fa3ff2b7bc069dac238f9fae /src
parent684cf9c78e20899f8e7d39eda4df17d9756dd44d (diff)
debug info cleanup
Diffstat (limited to 'src')
-rw-r--r--src/compiler.js6
-rw-r--r--src/intertyper.js8
-rw-r--r--src/modules.js13
3 files changed, 14 insertions, 13 deletions
diff --git a/src/compiler.js b/src/compiler.js
index ea55d95e..d2d14d9b 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -153,9 +153,11 @@ if (FAKE_X86_FP80) {
var lines = raw.split('\n');
raw = null;
-// Do it
+// Parse metadata
+
+Debugging.handleMetadata(lines);
-//dprint(JSON.stringify(C_DEFINES));
+// Do it
var intertyped = intertyper(lines);
lines = null;
diff --git a/src/intertyper.js b/src/intertyper.js
index 86da2a1f..834345bf 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -21,14 +21,6 @@ function intertyper(data, sidePass, baseLineNum) {
LLVM_STYLE = (data.indexOf('<label>') == -1 && data.indexOf('entry:') != -1) ? 'old' : 'new';
//dprint('LLVM_STYLE: ' + LLVM_STYLE);
}
-
- // If the source contains debug info as LLVM metadata, process that out (and save the debugging info for later)
- for (var i = data.length-1; i >= 0; i--) {
- if (/^!\d+ = metadata .*/.exec(data[i])) {
- Debugging.processMetadata(data);
- break;
- }
- }
}
// Substrate
diff --git a/src/modules.js b/src/modules.js
index db43a4e7..411bc66f 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -21,6 +21,15 @@ var LLVM = {
LLVM.GLOBAL_MODIFIERS = set(keys(LLVM.LINKAGES).concat(['constant', 'global', 'hidden']));
var Debugging = {
+ handleMetadata: function(lines) {
+ for (var i = lines.length-1; i >= 0; i--) {
+ if (/^!\d+ = metadata .*/.exec(lines[i])) {
+ Debugging.processMetadata(lines);
+ break;
+ }
+ }
+ },
+
processMetadata: function(lines) {
var llvmLineToMetadata = {};
var metadataToSourceLine = {};
@@ -49,11 +58,9 @@ var Debugging = {
var formStructMembers = /^!(\d+) = metadata !\{(.*)\}$/;
var formMember = /^!(\d+) = metadata !\{i32 \d+, metadata !\d+, metadata !"([^"]+)", metadata !\d+, (?:i32 \d+|null), i64 \d+, i64 \d+, i64 \d+, .+?, metadata !(\d+)}.*$/;
- var debugComment = new RegExp(/; +\[debug line = \d+:\d+\]/);
-
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
- line = line.replace(debugComment, '');
+ line = line.replace(/; +\[debug line = \d+:\d+\]/, '');
var skipLine = false;
if (form6.exec(line)) {