penberg/sparse-llvm — pull request #5 by jgarzik (2011-11-23 05:58:44+00:00)
Title: sparse, llvm: Fix loops, by properly handling OP_PHI forward references

Previous code simply omitted PHI sources that had not been assigned a
LLVMValueRef at the time of OP_PHI.

Fix by creating a list of such instances, and attempt to resolve forward
references at each OP_PHISOURCE appearance.

Testcase:

extern int bar (int);

int foo (int x)
{
int y = 0;

while (y < 1000) {
y += bar(x);
}

return y;
}

Signed-off-by: Jeff Garzik