aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/relooper/Relooper.cpp17
-rw-r--r--src/relooper/test_debug.txt85
-rwxr-xr-xsrc/relooper/updateit.sh2
3 files changed, 83 insertions, 21 deletions
diff --git a/src/relooper/Relooper.cpp b/src/relooper/Relooper.cpp
index 61daed79..c94d0000 100644
--- a/src/relooper/Relooper.cpp
+++ b/src/relooper/Relooper.cpp
@@ -379,12 +379,12 @@ void Relooper::Calculate(Block *Entry) {
Block *Curr = *iter;
TotalCodeSize += strlen(Curr->Code);
}
-
for (BlockSet::iterator iter = Live.begin(); iter != Live.end(); iter++) {
Block *Original = *iter;
if (Original->BranchesIn.size() <= 1 || Original->BranchesOut.size() > 0) continue;
if (strlen(Original->Code)*(Original->BranchesIn.size()-1) > TotalCodeSize/5) continue; // if splitting increases raw code size by a significant amount, abort
// Split the node (for simplicity, we replace all the blocks, even though we could have reused the original)
+ PrintDebug("Splitting block %d\n", Original->Id);
for (BlockBranchMap::iterator iter = Original->BranchesIn.begin(); iter != Original->BranchesIn.end(); iter++) {
Block *Prior = iter->first;
Block *Split = new Block(Original->Code);
@@ -393,6 +393,12 @@ void Relooper::Calculate(Block *Entry) {
Prior->BranchesOut.erase(Original);
Parent->AddBlock(Split);
Live.insert(Split);
+ for (BlockBranchMap::iterator iter = Original->BranchesOut.begin(); iter != Original->BranchesOut.end(); iter++) {
+ Block *Post = iter->first;
+ Branch *Details = iter->second;
+ Split->BranchesOut[Post] = new Branch(Details->Condition, Details->Code);
+ Post->BranchesIn[Split] = new Branch(NULL);
+ }
}
}
}
@@ -1010,9 +1016,14 @@ void Relooper::SetAsmJSMode(int On) {
void DebugDump(BlockSet &Blocks, const char *prefix) {
if (prefix) printf("%s ", prefix);
for (BlockSet::iterator iter = Blocks.begin(); iter != Blocks.end(); iter++) {
- printf("%d ", (*iter)->Id);
+ printf("%d:\n", (*iter)->Id);
+ for (BlockBranchMap::iterator iter2 = (*iter)->BranchesOut.begin(); iter2 != (*iter)->BranchesOut.end(); iter2++) {
+ printf(" OUT %d\n", iter2->first->Id);
+ }
+ for (BlockBranchMap::iterator iter2 = (*iter)->BranchesIn.begin(); iter2 != (*iter)->BranchesIn.end(); iter2++) {
+ printf(" IN %d\n", iter2->first->Id);
+ }
}
- printf("\n");
}
static void PrintDebug(const char *Format, ...) {
diff --git a/src/relooper/test_debug.txt b/src/relooper/test_debug.txt
index 1c7d0508..71da4a2b 100644
--- a/src/relooper/test_debug.txt
+++ b/src/relooper/test_debug.txt
@@ -38,46 +38,97 @@ int main() {
// Adding block 4 (LBB3)
// Process() called
// Process() running
- blocks : 1 2 3 4
- entries: 1
+ blocks : 1:
+ OUT 2
+ OUT 4
+2:
+ OUT 3
+ OUT 4
+ IN 1
+3:
+ OUT 4
+ IN 2
+4:
+ IN 1
+ IN 2
+ IN 3
+ entries: 1:
+ OUT 2
+ OUT 4
// creating simple block with block #1
// Solipsizing branches into 2
- relevant to solipsize: 1
+ relevant to solipsize: 1:
+ OUT 2
+ OUT 4
// eliminated branch from 1
// Solipsizing branches into 4
- relevant to solipsize: 1
+ relevant to solipsize: 1:
+ OUT 4
// eliminated branch from 1
// Process() running
- blocks : 2 3 4
- entries: 2 4
+ blocks : 2:
+ OUT 3
+ OUT 4
+3:
+ OUT 4
+ IN 2
+4:
+ IN 2
+ IN 3
+ entries: 2:
+ OUT 3
+ OUT 4
+4:
+ IN 2
+ IN 3
// Investigated independent groups:
- group: 2 3
+ group: 2:
+ OUT 3
+ OUT 4
+3:
+ OUT 4
+ IN 2
// Independent groups: 1
// Handleable independent groups: 1
// creating multiple block with 1 inner groups
// multiple group with entry 2:
- 2 3
+ 2:
+ OUT 3
+ OUT 4
+3:
+ OUT 4
+ IN 2
// Solipsizing branches into 4
- relevant to solipsize: 2 3
+ relevant to solipsize: 2:
+ OUT 3
+ OUT 4
+3:
+ OUT 4
+ IN 2
// eliminated branch from 2
// eliminated branch from 3
// Process() called
// Process() running
- blocks : 2 3
- entries: 2
+ blocks : 2:
+ OUT 3
+3:
+ IN 2
+ entries: 2:
+ OUT 3
// creating simple block with block #2
// Solipsizing branches into 3
- relevant to solipsize: 2
+ relevant to solipsize: 2:
+ OUT 3
// eliminated branch from 2
// Process() running
- blocks : 3
- entries: 3
+ blocks : 3:
+ entries: 3:
// creating simple block with block #3
// Process() returning
- remaining blocks after multiple: 4
+ remaining blocks after multiple: 4:
// Process() running
- blocks : 4
- entries: 4
+ blocks : 4:
+ entries: 4:
// creating simple block with block #4
// Process() returning
// === Optimizing shapes ===
diff --git a/src/relooper/updateit.sh b/src/relooper/updateit.sh
index 8c434753..da9fa9aa 100755
--- a/src/relooper/updateit.sh
+++ b/src/relooper/updateit.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
./test &> test.txt
./test2 &> test2.txt
./test3 &> test3.txt