diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-11-19 09:57:57 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-11-19 09:57:57 -0800 |
commit | 0af3502cde9a78f23e898264ed3a59ff88816541 (patch) | |
tree | 2c626192dc6c019a3cf308fdf0d819fe2a1e2643 /src | |
parent | cc86495ebd83005e1f63bfa12b90d903d7ac7b66 (diff) |
fix for phis from invoke
Diffstat (limited to 'src')
-rw-r--r-- | src/analyzer.js | 10 | ||||
-rw-r--r-- | src/jsifier.js | 5 | ||||
-rw-r--r-- | src/parseTools.js | 1 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 0c362eff..d8439a99 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -673,12 +673,14 @@ function analyzer(data) { var lastLine = sourceLabel.lines.slice(-1)[0]; assert(lastLine.intertype in LLVM.PHI_REACHERS, 'Only some can lead to labels with phis, line ' + [func.ident, label.ident]); if (!lastLine.phi) { - // We store the phi assignments in the branch's params (which are otherwise unused) lastLine.phi = true; - assert(!lastLine.params); - lastLine.params = []; + assert(!lastLine.dependent); + lastLine.dependent = { + intertype: 'phiassigns', + params: [] + }; }; - lastLine.params.push({ + lastLine.dependent.params.push({ intertype: 'phiassign', ident: line.ident, value: param.value, diff --git a/src/jsifier.js b/src/jsifier.js index 9cf7e1e0..b7d7a6a6 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -704,7 +704,7 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { function calcPhiSets(item) { if (!item.phi) return null; var phiSets = {}; - item.params.forEach(function(param) { + item.dependent.params.forEach(function(param) { if (!phiSets[param.targetLabel]) phiSets[param.targetLabel] = []; phiSets[param.targetLabel].push(param); param.valueJS = finalizeLLVMParameter(param.value); @@ -713,8 +713,9 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { } function getPhiSetsForLabel(phiSets, label) { + if (!phiSets) return ''; label = getOldLabel(label); - if (!phiSets || !phiSets[label]) return ''; + if (!phiSets[label]) return ''; var labelSets = phiSets[label]; // FIXME: Many of the |var |s here are not needed, but without them we get slowdowns with closure compiler. TODO: remove this workaround. if (labelSets.length == 1) { diff --git a/src/parseTools.js b/src/parseTools.js index 07855c70..e94279ee 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1696,6 +1696,7 @@ function walkInterdata(item, pre, post, obj) { var originalObj = obj; if (obj && obj.replaceWith) obj = obj.replaceWith; // allow pre to replace the object we pass to all its children if (item.value && walkInterdata(item.value, pre, post, obj)) return true; + if (item.dependent && walkInterdata(item.dependent, pre, post, obj)) return true; var i; for (i = 1; i <= 4; i++) { if (item['param'+i] && walkInterdata(item['param'+i], pre, post, obj)) return true; |