const Type *RetTy = FTy->getReturnType();
const Type *NRetTy;
unsigned RetCount = NumRetVals(F);
+ // Explicitely track if anything changed, for debugging
+ bool Changed = false;
// -1 means unused, other numbers are the new index
SmallVector<int, 5> NewRetIdxs(RetCount, -1);
std::vector<const Type*> RetTypes;
NewRetIdxs[i] = RetTypes.size() - 1;
} else {
++NumRetValsEliminated;
- DOUT << "DAE - Removing return value " << i << " from " << F->getNameStart() << "\n";
+ DOUT << "DAE - Removing return value " << i << " from " << F->getNameStart() << "\n";
+ Changed = true;
}
}
else
} else {
DOUT << "DAE - Removing return value from " << F->getNameStart() << "\n";
++NumRetValsEliminated;
+ Changed = true;
}
if (RetTypes.size() == 0)
// No return types? Make it void
} else {
++NumArgumentsEliminated;
DOUT << "DAE - Removing argument " << i << " (" << I->getNameStart() << ") from " << F->getNameStart() << "\n";
+ Changed = true;
}
}
if (NFTy == FTy)
return false;
+ // The function type is only allowed to be different if we actually left out
+ // an argument or return value
+ assert(Changed && "Function type changed while no arguments or retrurn values were removed!");
+
// Create the new function body and insert it into the module...
Function *NF = Function::Create(NFTy, F->getLinkage());
NF->copyAttributesFrom(F);