* edge to check for merge input values
* @return possibly-modified dataflow value
*/
private UnconditionalValueDerefSet propagateDerefSetsToMergeInputValues(UnconditionalValueDerefSet fact, Edge edge) {
ValueNumberFrame blockValueNumberFrame = vnaDataflow.getResultFact(edge.getSource());
ValueNumberFrame targetValueNumberFrame = vnaDataflow.getStartFact(edge.getTarget());
UnconditionalValueDerefSet originalFact = fact;
fact = duplicateFact(fact);
if (blockValueNumberFrame.isValid() && targetValueNumberFrame.isValid()) {
int slots = 0;
if (targetValueNumberFrame.getNumSlots() == blockValueNumberFrame.getNumSlots()) {
slots = targetValueNumberFrame.getNumSlots();
} else if (targetValueNumberFrame.getNumLocals() == blockValueNumberFrame.getNumLocals()) {
slots = targetValueNumberFrame.getNumLocals();
}
if (slots > 0) {
if (DEBUG) {
System.out.println("** Valid VNA frames for " + edge);
System.out.println("** Block : " + blockValueNumberFrame);
System.out.println("** Target: " + targetValueNumberFrame);
}
for (int i = 0; i < slots; i++) {
ValueNumber blockVN = blockValueNumberFrame.getValue(i);
ValueNumber targetVN = targetValueNumberFrame.getValue(i);
if (blockVN.equals(targetVN)) {
continue;
}
fact.clearDerefSet(blockVN);
if (originalFact.isUnconditionallyDereferenced(targetVN)) {
fact.setDerefSet(blockVN, originalFact.getUnconditionalDerefLocationSet(targetVN));
}
} // for all slots
for (ValueNumber blockVN : blockValueNumberFrame.valueNumbersForLoads()) {
AvailableLoad load = blockValueNumberFrame.getLoad(blockVN);
if (load == null) {
continue;
}
ValueNumber[] targetVNs = targetValueNumberFrame.getAvailableLoad(load);
if (targetVNs != null) {
for (ValueNumber targetVN : targetVNs) {
if (targetVN.hasFlag(ValueNumber.PHI_NODE) && fact.isUnconditionallyDereferenced(targetVN)
&& !fact.isUnconditionallyDereferenced(blockVN)) {
// Block VN is also dereferenced
// unconditionally.
AvailableLoad targetLoad = targetValueNumberFrame.getLoad(targetVN);
if (!load.equals(targetLoad)) {
continue;
}
if (DEBUG) {
System.out.println("** Copy vn derefs for " + load + " from " + targetVN + " --> " + blockVN);