Open
Description
If there is an import statement in an __init__.py
file that imports a module in a subpackage, then we'll have two global reads of the same module. The first one is from the one that is imported automatically and the other from the explicit import call. We could reuse the automatic one. Right now, there are two identical ones.
The potentially redundant read occurs here:
This issue can be exercised by running the following test case:
That results in the following IR for https://github.com/ponder-lab/ML/blob/d2946f69704a20bb575ea3bdcade2f43bed7f27a/com.ibm.wala.cast.python.test/data/proj51/src/__init__.py:
callees of node __init__.py : []
IR of node 2, context CallStringContext: [ com.ibm.wala.FakeRootClass.fakeRootMethod()V@2 ]
<Code body of function Lscript src/__init__.py>
CFG:
BB0[-1..-2]
-> BB1
BB1[0..96]
-> BB2
BB2[-1..-2]
Instructions:
BB0
BB1
0 global:global script src/__init__.py = v1<no information>
1 putfield v1.< PythonLoader, LRoot, src, <PythonLoader,LRoot> > = v1__init__.py [1:0] -> [1:21]
2 v3 = global:global script src/module.py __init__.py [1:0] -> [1:21]
3 putfield v1.< PythonLoader, LRoot, module, <PythonLoader,LRoot> > = v3__init__.py [1:0] -> [1:21]
...
95 v240 = global:global script src/module.py__init__.py [1:0] -> [1:21] [240=[f]]
96 v242 = fieldref v240.v239:#f __init__.py [1:0] -> [1:21] [242=[f]240=[f]]
BB2
Note that v3
and v240
have the same value, though the results seem to differ in the printing (I wonder if that's from the PA?).