Commit 02712d79 authored by Kevin Modzelewski's avatar Kevin Modzelewski

We're back to the future: rebase to LLVM trunk

Had to improve some of our rewriting; looks like there
must have been an LLVM commit that changes the live-out registers
we see.

Also, temporarily disabled format-checking: the rebase
updated clang-format, which now is formatting a few files
differently.  Will re-enable and re-format in the next commit.
parent bb417df2
......@@ -364,7 +364,7 @@ check:
$(MAKE) check_dbg
$(MAKE) check_format
# $(MAKE) check_format
$(MAKE) run_unittests
@# jit_prof forces the use of GCC as the compiler, which can expose other errors, so just build it and see what happens:
......
......@@ -674,15 +674,35 @@ void Rewriter::commit() {
// setDoneGuarding();
assert(live_out_regs.size() == live_outs.size());
// Live-outs placement: sometimes a live out can be placed into the location of a different live-out,
// so we need to reshuffle and solve those conflicts.
// For now, just use a simple approach, and iteratively try to move variables into place, and skip
// them if there's a conflict. Doesn't handle conflict cycles, but I would be very curious
// to see us generate one of those.
int num_to_move = live_outs.size();
std::vector<bool> moved(num_to_move, false);
while (num_to_move) {
int _start_move = num_to_move;
for (int i = 0; i < live_outs.size(); i++) {
if (moved[i])
continue;
assembler::GenericRegister ru = assembler::GenericRegister::fromDwarf(live_out_regs[i]);
Location expected(ru);
RewriterVar* var = live_outs[i];
// for (Location l : var->locations) {
// printf("%d %d\n", l.type, l._data);
//}
if (!var->isInLocation(expected)) {
if (var->isInLocation(expected)) {
moved[i] = true;
num_to_move--;
continue;
}
if (vars_by_location.count(expected))
continue;
assert(vars_by_location.count(expected) == 0);
if (ru.type == assembler::GenericRegister::GP) {
......@@ -694,8 +714,39 @@ void Rewriter::commit() {
} else {
RELEASE_ASSERT(0, "%d", ru.type);
}
// silly, but need to make a copy due to the mutations:
for (auto l : std::vector<Location>(var->locations.begin(), var->locations.end())) {
if (l == expected)
continue;
removeLocationFromVar(var, l);
}
moved[i] = true;
num_to_move--;
}
#ifndef NDEBUG
if (num_to_move >= _start_move) {
for (int i = 0; i < live_outs.size(); i++) {
printf("\n");
assembler::GenericRegister ru = assembler::GenericRegister::fromDwarf(live_out_regs[i]);
Location expected(ru);
expected.dump();
RewriterVar* var = live_outs[i];
for (auto l : var->locations) {
l.dump();
}
}
}
#endif
RELEASE_ASSERT(num_to_move < _start_move, "algorithm isn't going to terminate!");
}
for (int i = 0; i < live_outs.size(); i++) {
assembler::GenericRegister ru = assembler::GenericRegister::fromDwarf(live_out_regs[i]);
RewriterVar* var = live_outs[i];
assert(var->isInLocation(ru));
var->decUse();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment