Updating Analysis Pass

Dear All,

I am trying to use an Analysis Pass inside a transformation pass. After the transformations, I call the analysis pass again using getAvailableAnalysis but it seems to run on the old IR.

Snippet of my code:
MyAnalysis* MP = getAnalysisIfAvailable();

… Transformation code …
MyAnalysis* NewMP = getAnalysisIfAvailable();

… Transformation code …

MP and NewMP are the same, while I have transformed the code. Please let me know if there is something wrong with what I am doing.


It looks like your transformation pass and the analysis pass you’re querying are the same type of pass (either they’re both FunctionPass’es or ModulePass’es). The PassManager isn’t rerunning the analysis pass because your pass is still running; it will not decide on whether to rerun the analysis pass until your pass is finished. As a result, the analysis pass’s results reflect what it computed before your pass ran and will not reflect any changes that your transform pass has made. While there are a few exceptions, in the general case, a transform pass cannot rely on an analysis pass to update itself to reflect changes that the transform pass has made. The transform pass can only see analysis results for what the code looked like before transformation started. Regards, John Criswell