JDK-8314999 : IR framework fails to detect allocation
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 22,23,24
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2023-08-25
  • Updated: 2024-11-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
Attach TestAllocations.java fails with:

Failed IR Rules (1) of Methods (1)
----------------------------------
1) Method "static java.lang.Object compiler.c2.irTests.TestAllocation.test1(java.lang.Object)" - [Failed IR rules: 1]:
   * @IR rule 1: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeatureOr={}, applyIfCPUFeature={}, counts={"_#ALLOC#_", "4"}, failOn={}, applyIfAnd={}, applyIfOr={}, applyIfNot={})"
     > Phase "PrintOptoAssembly":
       - counts: Graph contains wrong number of nodes:
         * Constraint 1: "(.*precise .*\R((.*(?i:mov|mv|xorl|nop|spill).*|\s*)\R)*.*(?i:call,static).*wrapper for: _new_instance_Java)"
           - Failed comparison: [found] 3 = 4 [given]
             - Matched nodes (3):
               * 449     movq    RSI, precise compiler/c2/irTests/TestAllocation$MyClass: 0x00007f400c13c9d0:Constant:exact *	# ptr
                 453     xorl    RDX, RDX	# int
                 455     movq    RBP, [rsp + #0]	# spill
                         nop 	# 2 bytes pad for loops and calls
                 45b     call,static  wrapper for: _new_instance_Java
               * 470     movq    RSI, precise java/lang/Object: 0x00007f40080039c8:Constant:exact *	# ptr
                 47a     xorl    RDX, RDX	# int
                 47c     movq    RBP, [rsp + #0]	# spill
                         nop 	# 3 bytes pad for loops and calls
                 483     call,static  wrapper for: _new_instance_Java
               * 4c5     movq    RSI, precise java/util/HashMap: 0x00007f400c13f208 (java/lang/Cloneable,java/io/Serializable,java/util/Map):Constant:exact *	# ptr
                 4cf     xorl    RDX, RDX	# int
                         nop 	# 2 bytes pad for loops and calls
                 4d3     call,static  wrapper for: _new_instance_Java

The problem is that the following allocation is not detected by IRNode.ALLOC due to the pushq/popq spills:

495     B36: #	out( B42 B37 ) <- in( B7 )  Freq: 0.000100017
495     movq    RSI, precise java/util/HashSet: 0x00007f400c13d928 (java/lang/Cloneable,java/io/Serializable,java/lang/Iterable,java/util/Collection,java/util/Set):Constant:exact *	# ptr
49f     xorl    RDX, RDX	# int
4a1     movq    RBP, [rsp + #0]	# spill
4a5     pushq   [rsp + #16]	# 64-bit mem-mem spill
	popq    [rsp + #8]
4af     call,static  wrapper for: _new_instance_Java

Comments
That would be a good solution to do the matching on CompilePhase.FINAL_CODE instead of on the opto assembly output.
25-08-2023

ILW = IR framework fails to detect an allocation due to an unexpected spill, single test, no workaround = MLH = P4
25-08-2023

We could simply add pushq|popq to the IRNode.ALLOC regex but that's fragile because there might be many more shapes, depending what/how the register allocator decides to spill. We should come up with a more robust solution. For example, instead of matching on the opto assembly, we could match on the _new_instance_java runtime call. But to support ALLOC_OF / ALLOC_ARRAY_OF, we would need to add information about the allocation type to the C2 IR node.
25-08-2023