EA goes over arguments to a non inlined call and uses
`BCEscapeAnalyzer` to add edges to the `ConnectionGraph`. With
valhalla, that code goes over inputs to a `CallNode` using the
scalarized calling convention and queries `BCEscapeAnalyzer` with the
index of the argument in the scalarized CC but `BCEscapeAnalyzer` has
no knowledge of the scalarized CC. So `is_arg_returned()` for instance
is passed the wrong argument number and EA, as a result, can add
incorrect edges to the `ConnectionGraph`.
In the test case:
static value class MyValue {
Object o;
MyValue(Object o) {
this.o = o;
}
}
static int test1(Object o) {
MyValue v = new MyValue(null);
Object res = notInlined(v, o);
if (res == null) {
return 1;
}
return 2;
}
static Object notInlined(MyValue arg1, Object arg2) {
return arg2;
}
2nd argument is returned by `notInlined()`. The second argument in the
scalarized CC in `test1()` is `Myvalue.o`. So EA deduces that the
return value of `notInlined()` is `v.o` (which is `null`) instead of
`o` which is non null.
With this EA:
public static void test2() {
MyValue arg = new MyValue(null);
MyValue res = notInlined2(arg);
if (res.o != null) {
throw new RuntimeException("never taken");
}
}
static MyValue notInlined2(MyValue v) {
return v;
}
the fixed logic connects the return of `notInlined2` with `v.o`.
-------------
Commit messages:
- whitespaces
- more
- test case
- more
- more
- fix & test
Changes: https://git.openjdk.org/valhalla/pull/2079/files
Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=2079&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8377480
Stats: 257 lines in 8 files changed: 244 ins; 3 del; 10 mod
Patch: https://git.openjdk.org/valhalla/pull/2079.diff
Fetch: git fetch https://git.openjdk.org/valhalla.git pull/2079/head:pull/2079
PR: https://git.openjdk.org/valhalla/pull/2079