@@ -430,14 +430,18 @@ private predicate mustTransformToGLValue(Expr expr) {
430430}
431431
432432/**
433- * Holds if `expr` has an lvalue-to-rvalue conversion that should be ignored
434- * when generating IR. This occurs for conversion from an lvalue of function type
435- * to an rvalue of function pointer type. The conversion is represented in the
436- * AST as an lvalue-to-rvalue conversion, but the IR represents both a function
433+ * Holds if `expr` has an explicit or implicit load that should be ignored
434+ * when generating IR. For example, this occurs for conversion from an lvalue of
435+ * function type to an rvalue of function pointer type. The conversion is represented
436+ * in the AST as an lvalue-to-rvalue conversion, but the IR represents both a function
437437 * lvalue and a function pointer prvalue the same.
438438 */
439439predicate ignoreLoad ( Expr expr ) {
440- expr .hasLValueToRValueConversion ( ) and
440+ (
441+ expr .hasLValueToRValueConversion ( )
442+ or
443+ isPRValueFieldAccessWithImplicitLoad ( expr )
444+ ) and
441445 (
442446 expr instanceof ThisExpr
443447 or
@@ -517,8 +521,11 @@ predicate hasTranslatedLoad(Expr expr) {
517521predicate hasTranslatedSyntheticTemporaryObject ( Expr expr ) {
518522 not ignoreExpr ( expr ) and
519523 mustTransformToGLValue ( expr ) and
520- // If it's a load, we'll just ignore the load in `ignoreLoad()`.
521- not expr .hasLValueToRValueConversion ( )
524+ // If it's an explicit or implicit field load, reuse the existing address by
525+ // ignoring the load in `ignoreLoad` instead of materializing another
526+ // temporary.
527+ not expr .hasLValueToRValueConversion ( ) and
528+ not isPRValueFieldAccessWithImplicitLoad ( expr )
522529}
523530
524531Opcode comparisonOpcode ( ComparisonOperation expr ) {
0 commit comments