Fix global value numbering.

This commit is contained in:
Max Schaefer
2020-01-14 20:44:13 +00:00
parent 2fdd45255c
commit 3d508d44e7
3 changed files with 17 additions and 4 deletions

View File

@@ -338,7 +338,10 @@ private predicate mkBoolConst(DataFlow::Node nd, boolean val) {
nd.isPlatformIndependentConstant()
}
private predicate mkFunc(DataFlow::Node nd, Function f) { nd = f.getARead() }
private predicate mkFunc(DataFlow::Node nd, Function f) {
nd = f.getARead() and
not f instanceof Method
}
private predicate analyzableConst(DataFlow::Node e) {
mkNumericConst(e, _) or mkStringConst(e, _) or mkBoolConst(e, _) or mkFunc(e, _)
@@ -349,7 +352,7 @@ private predicate analyzableMethodAccess(Read access, DataFlow::Node receiver, M
not access.isConst()
}
private predicate mkMethodAccess(DataFlow::Node access, GVN qualifier, Function m) {
private predicate mkMethodAccess(DataFlow::Node access, GVN qualifier, Method m) {
exists(DataFlow::Node base |
analyzableMethodAccess(access, base, m) and
qualifier = globalValueNumber(base)

View File

@@ -40,3 +40,5 @@
| regressions.go:7:11:7:15 | false | regressions.go:7:11:7:15 | false |
| regressions.go:9:11:9:12 | !... | regressions.go:11:11:11:14 | true |
| regressions.go:11:11:11:14 | true | regressions.go:11:11:11:14 | true |
| regressions.go:30:9:30:22 | call to getPayload | regressions.go:30:9:30:22 | call to getPayload |
| regressions.go:30:26:30:39 | call to getPayload | regressions.go:30:26:30:39 | call to getPayload |

View File

@@ -12,7 +12,7 @@ const f = true
type cell struct {
payload int
next *cell
next *cell
}
func test4(x, y cell) int {
@@ -20,4 +20,12 @@ func test4(x, y cell) int {
y.payload +
x.next.payload +
y.next.payload
}
}
func (c *cell) getPayload() int {
return c.payload
}
func test5(x, y cell) int {
return x.getPayload() + y.getPayload()
}