From 34d10f19f5321961bdeea8d1c9aff7ca89101d1f Mon Sep 17 00:00:00 2001 From: Christian Hagedorn Date: Mon, 14 Nov 2022 08:28:41 +0000 Subject: [PATCH] 8296243: [IR Framework] Fix issues with IRNode.ALLOC* regexes Reviewed-by: mdoerr, thartmann --- .../compiler/lib/ir_framework/IRNode.java | 19 +++++++++---------- .../tests/TestPhaseIRMatching.java | 12 ++++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java index 369962a0308e6..52fa4a1f16382 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java @@ -167,27 +167,25 @@ public class IRNode { public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX; static { - String idealIndependentRegex = START + "Allocate" + MID + END; - String optoRegex = "(.*precise .*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END; - allocNodes(ALLOC, idealIndependentRegex, optoRegex); + String optoRegex = "(.*precise .*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END; + allocNodes(ALLOC, "Allocate", optoRegex); } public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX; static { - String regex = "(.*precise .*" + IS_REPLACED + ":.*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END; + String regex = "(.*precise .*" + IS_REPLACED + ":.*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END; optoOnly(ALLOC_OF, regex); } public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX; static { - String idealIndependentRegex = START + "AllocateArray" + MID + END; - String optoRegex = "(.*precise \\[.*\\R((.*(?i:mov|xor|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END; - allocNodes(ALLOC_ARRAY, idealIndependentRegex, optoRegex); + String optoRegex = "(.*precise \\[.*\\R((.*(?i:mov|xor|nop|spill).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END; + allocNodes(ALLOC_ARRAY, "AllocateArray", optoRegex); } public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX; static { - String regex = "(.*precise \\[.*" + IS_REPLACED + ":.*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END; + String regex = "(.*precise \\[.*" + IS_REPLACED + ":.*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END; optoOnly(ALLOC_ARRAY_OF, regex); } @@ -1182,10 +1180,11 @@ private static void beforeMatchingNameRegex(String irNodePlaceholder, String irN IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex)); } - private static void allocNodes(String irNode, String idealRegex, String optoRegex) { + private static void allocNodes(String irNode, String irNodeName, String optoRegex) { + String idealIndependentRegex = START + irNodeName + "\\b" + MID + END; Map intervalToRegexMap = new HashMap<>(); intervalToRegexMap.put(new PhaseInterval(CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.PHASEIDEALLOOP_ITERATIONS), - idealRegex); + idealIndependentRegex); intervalToRegexMap.put(new PhaseInterval(CompilePhase.PRINT_OPTO_ASSEMBLY), optoRegex); MultiPhaseRangeEntry entry = new MultiPhaseRangeEntry(CompilePhase.PRINT_OPTO_ASSEMBLY, intervalToRegexMap); IR_NODE_MAPPINGS.put(irNode, entry); diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java index 09ac50ea29a56..0342ba463a5ef 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java @@ -104,6 +104,8 @@ class Basics { long l; Object obj; Object obj2; + Object obj3; + Object obj4; @Test @IR(failOn = IRNode.STORE, phase = {CompilePhase.DEFAULT, CompilePhase.PRINT_IDEAL}) @@ -243,6 +245,16 @@ public void alloc() { obj = new Object(); obj2 = new Object[1]; } + + @Test + @IR(counts = {IRNode.ALLOC, "2", IRNode.ALLOC_ARRAY, "2"}, // works for all phases + phase = {CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.CCP1, CompilePhase.PRINT_OPTO_ASSEMBLY, CompilePhase.DEFAULT}) + public void alloc2() { + obj = new Object(); + obj2 = new Object[1]; + obj3 = new Object(); + obj4 = new Object[2]; + } } class NoCompilationOutput {