Hi,
While working on A4, I have a question regarding transferCallEdge().
I noticed that in transferCallEdge(), the arguments from Stmt.getUses() seem to be in the same order as parameters from getParams(). Is this ordering guaranteed by the API?
I checked the docs but didn't find clarification. If it's intended, maybe we could document it to help future users. If not, perhaps we could provide a utility method like CallEdge.getParameterMapping() to make the mapping explicit.
My implementation of transferCallEdge() is as follows:
protected CPFact transferCallEdge(CallEdge<Stmt> edge, CPFact callSiteOut) {
List<RValue> uses = edge.getSource().getUses();
List<Var> params = edge.getCallee().getIR().getParams();
CPFact newFact = new CPFact();
for (int i = 0; i < params.size(); i++) {
if (uses.get(i) instanceof Var var) {
newFact.update(params.get(i), callSiteOut.get(var));
}
}
return newFact;
}
This code relies on an implicit assumption: the order of arguments returned by uses corresponds exactly to the order of parameters in params. While I verified this through debugging, this guarantee is not documented in Stmt.getUses() or JMethod.getIR().getParams().
A cleaner design might expose a getParameterMapping() method directly on CallEdge, making the argument-parameter correspondence explicit and freeing callers from depending on index ordering.
Thanks!
Hi,
While working on A4, I have a question regarding transferCallEdge().
I noticed that in
transferCallEdge(), the arguments fromStmt.getUses()seem to be in the same order as parameters fromgetParams(). Is this ordering guaranteed by the API?I checked the docs but didn't find clarification. If it's intended, maybe we could document it to help future users. If not, perhaps we could provide a utility method like
CallEdge.getParameterMapping()to make the mapping explicit.My implementation of transferCallEdge() is as follows:
This code relies on an implicit assumption: the order of arguments returned by uses corresponds exactly to the order of parameters in params. While I verified this through debugging, this guarantee is not documented in Stmt.getUses() or JMethod.getIR().getParams().
A cleaner design might expose a getParameterMapping() method directly on CallEdge, making the argument-parameter correspondence explicit and freeing callers from depending on index ordering.
Thanks!