• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include <numeric>
18 #include <unordered_map>
19 
20 #include "bytecode_optimizer/reg_acc_alloc.h"
21 #include "bytecode_optimizer/reg_encoder.h"
22 #include "compiler_options.h"
23 #include "graph_test.h"
24 #include "mem/arena_allocator.h"
25 #include "mem/pool_manager.h"
26 #include "optimizer/optimizations/cleanup.h"
27 #include "optimizer/optimizations/lowering.h"
28 #include "optimizer/optimizations/regalloc/interference_graph.h"
29 #include "optimizer/optimizations/regalloc/location_mask.h"
30 #include "optimizer/optimizations/regalloc/reg_alloc_base.h"
31 #include "optimizer/optimizations/regalloc/reg_alloc_graph_coloring.h"
32 #include "optimizer/optimizations/regalloc/reg_alloc_resolver.h"
33 #include "optimizer/optimizations/regalloc/reg_alloc_stat.h"
34 #include "optimizer/optimizations/regalloc/reg_type.h"
35 #include "optimizer/optimizations/regalloc/reg_alloc.h"
36 #include "optimizer/optimizations/regalloc/spill_fills_resolver.h"
37 #include "optimizer/optimizations/regalloc/split_resolver.h"
38 #include "utils/arena_containers.h"
39 
40 using namespace testing::ext;
41 
42 namespace panda::compiler {
43 class RegallocTest : public testing::Test {
44 public:
SetUpTestCase(void)45     static void SetUpTestCase(void) {};
TearDownTestCase(void)46     static void TearDownTestCase(void) {};
SetUp()47     void SetUp() {};
TearDown()48     void TearDown() {};
49 
50     GraphTest graph_test_;
51 };
52 
53 namespace {
54 constexpr unsigned DEFAULT_CAPACITY1 = 10;
55 unsigned TEST_EDGES1[2][2] = {{0, 1}, {7, 4}};
__anonbbc8952d0202(unsigned a, unsigned b) 56 auto is_in_set = [](unsigned a, unsigned b) {
57     for (int i = 0; i < 2; i++) {
58         if ((a == TEST_EDGES1[i][0] && b == TEST_EDGES1[i][1]) || (b == TEST_EDGES1[i][0] && a == TEST_EDGES1[i][1])) {
59             return true;
60         }
61     }
62     return false;
63 };
64 
65 const unsigned DEFAULT_CAPACITY2 = 5;
66 const unsigned DEFAULT_EDGES2 = 6;
67 ::std::pair<unsigned, unsigned> TEST_EDGES2[DEFAULT_EDGES2] = {{0, 1}, {1, 2}, {2, 0}, {0, 3}, {2, 3}, {3, 4}};
68 }
69 
70 /**
71  * @tc.name: regalloc_test_001
72  * @tc.desc: Verify the GetCallsiteIntersectCount function.
73  * @tc.type: FUNC
74  * @tc.require: issueNumber
75  */
76 HWTEST_F(RegallocTest, regalloc_test_001, TestSize.Level1)
77 {
78     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
79     const char *test_method_name = "func_main_0";
80     bool status = false;
__anonbbc8952d0302(Graph* graph, std::string &method_name) 81     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
82         if (test_method_name != method_name) {
83             return;
84         }
85         status = true;
86         EXPECT_NE(graph, nullptr);
87         InterferenceGraph inter_graph(graph->GetAllocator());
88         inter_graph.Reserve(1);
89         auto cnode = inter_graph.AllocNode();
90 
91         cnode->SetBias(1);
92         EXPECT_EQ(cnode->GetBias(), 1);
93         EXPECT_FALSE(cnode->IsPhysical());
94 
95         Register color = 1;
96         bool is_physical = true;
97         cnode->SetFixedColor(color, is_physical);
98         EXPECT_TRUE(cnode->IsPhysical());
99         is_physical = false;
100         cnode->SetFixedColor(color, is_physical);
101         EXPECT_FALSE(cnode->IsPhysical());
102         LifeNumber point = 0;
103         cnode->AddCallsite(point);
104         EXPECT_EQ(cnode->GetCallsiteIntersectCount(), 1U);
105     });
106     EXPECT_TRUE(status);
107 }
108 
109 /**
110  * @tc.name: regalloc_test_002
111  * @tc.desc: Verify the HasAffinityEdge function.
112  * @tc.type: FUNC
113  * @tc.require: issueNumber
114  */
115 HWTEST_F(RegallocTest, regalloc_test_002, TestSize.Level1)
116 {
117     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
118     const char *test_method_name = "func_main_0";
119     bool status = false;
__anonbbc8952d0402(Graph* graph, std::string &method_name) 120     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
121         if (test_method_name != method_name) {
122             return;
123         }
124         status = true;
125         EXPECT_NE(graph, nullptr);
126 
127         GraphMatrix graph_matrix(graph->GetAllocator());
128         unsigned capacity = 8;
129         graph_matrix.SetCapacity(capacity);
130         EXPECT_EQ(graph_matrix.GetCapacity(), 8);
131         graph_matrix.AddAffinityEdge(1, 1);
132         EXPECT_TRUE(graph_matrix.HasAffinityEdge(1, 1));
133     });
134     EXPECT_TRUE(status);
135 }
136 
137 /**
138  * @tc.name: regalloc_test_003
139  * @tc.desc: Verify the UpdateBiasData function.
140  * @tc.type: FUNC
141  * @tc.require: issueNumber
142  */
143 HWTEST_F(RegallocTest, regalloc_test_003, TestSize.Level1)
144 {
145     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
146     const char *test_method_name = "func_main_0";
147     bool status = false;
__anonbbc8952d0502(Graph* graph, std::string &method_name) 148     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
149         if (test_method_name != method_name) {
150             return;
151         }
152         status = true;
153         EXPECT_NE(graph, nullptr);
154 
155         InterferenceGraph inter_graph(graph->GetAllocator());
156         inter_graph.Reserve(1);
157         auto cnode = inter_graph.AllocNode();
158         EXPECT_FALSE(inter_graph.GetNode(0).HasBias());
159         inter_graph.AddBias();
160         InterferenceGraph::Bias bias;
161         bias.callsites = 1;
162         bias.color = INVALID_REG;
163         inter_graph.UpdateBiasData(&bias, *cnode);
164 
165         cnode->SetColor(ACC_REG_ID);
166         inter_graph.UpdateBiasData(&bias, *cnode);
167         EXPECT_EQ(inter_graph.GetBiasCount(), 1);
168     });
169     EXPECT_TRUE(status);
170 }
171 
172 /**
173  * @tc.name: regalloc_test_004
174  * @tc.desc: Verify the HasEdge function.
175  * @tc.type: FUNC
176  * @tc.require: issueNumber
177  */
178 HWTEST_F(RegallocTest, regalloc_test_004, TestSize.Level1)
179 {
180     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
181     const char *test_method_name = "func_main_0";
182     bool status = false;
__anonbbc8952d0602(Graph* graph, std::string &method_name) 183     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
184         if (test_method_name != method_name) {
185             return;
186         }
187         status = true;
188         EXPECT_NE(graph, nullptr);
189 
190         GraphMatrix matrix(graph->GetAllocator());
191         matrix.SetCapacity(DEFAULT_CAPACITY1);
192         EXPECT_FALSE(matrix.AddEdge(0, 1));
193         unsigned a = 7;
194         unsigned b = 4;
195         EXPECT_FALSE(matrix.AddEdge(a, b));
196         for (unsigned i = 0; i < DEFAULT_CAPACITY1; i++) {
197             for (unsigned j = 0; j < DEFAULT_CAPACITY1; j++) {
198                 EXPECT_EQ(matrix.HasEdge(i, j), is_in_set(i, j));
199             }
200         }
201         EXPECT_GE(matrix.GetCapacity(), DEFAULT_CAPACITY1);
202     });
203     EXPECT_TRUE(status);
204 }
205 
206 /**
207  * @tc.name: regalloc_test_005
208  * @tc.desc: Verify the SetPhysicalReg function.
209  * @tc.type: FUNC
210  * @tc.require: issueNumber
211  */
212 HWTEST_F(RegallocTest, regalloc_test_005, TestSize.Level1)
213 {
214     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
215     const char *test_method_name = "func5";
216     bool status = false;
__anonbbc8952d0702(Graph* graph, std::string &method_name) 217     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
218         if (test_method_name != method_name) {
219             return;
220         }
221 
222         EXPECT_NE(graph, nullptr);
223         status = true;
224         EXPECT_TRUE(graph->RunPass<compiler::Cleanup>());
225         EXPECT_TRUE(graph->RunPass<bytecodeopt::RegAccAlloc>());
226         EXPECT_TRUE(RegAlloc(graph));
227     });
228     EXPECT_TRUE(status);
229 }
230 
231 /**
232  * @tc.name: regalloc_test_006
233  * @tc.desc: Verify the HasAffinityEdge function.
234  * @tc.type: FUNC
235  * @tc.require: issueNumber
236  */
237 HWTEST_F(RegallocTest, regalloc_test_006, TestSize.Level1)
238 {
239     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
240     const char *test_method_name = "func_main_0";
241     bool status = false;
__anonbbc8952d0802(Graph* graph, std::string &method_name) 242     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
243         if (test_method_name != method_name) {
244             return;
245         }
246         status = true;
247         EXPECT_NE(graph, nullptr);
248         InterferenceGraph gr(graph->GetAllocator());
249         gr.Reserve(DEFAULT_CAPACITY1);
250 
251         EXPECT_EQ(gr.Size(), 0);
252         auto *node1 = gr.AllocNode();
253         EXPECT_EQ(gr.Size(), 1);
254         EXPECT_EQ(node1->GetNumber(), 0);
255 
256         auto *node2 = gr.AllocNode();
257         EXPECT_EQ(gr.Size(), 2);
258         EXPECT_EQ(node2->GetNumber(), 1);
259         EXPECT_NE(node1, node2);
260         EXPECT_FALSE(gr.HasAffinityEdge(1, 1));
261     });
262     EXPECT_TRUE(status);
263 }
264 
265 /**
266  * @tc.name: regalloc_test_007
267  * @tc.desc: Verify the AddEdge function.
268  * @tc.type: FUNC
269  * @tc.require: issueNumber
270  */
271 HWTEST_F(RegallocTest, regalloc_test_007, TestSize.Level1)
272 {
273     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
274     const char *test_method_name = "func_main_0";
275     bool status = false;
__anonbbc8952d0902(Graph* graph, std::string &method_name) 276     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
277         if (test_method_name != method_name) {
278             return;
279         }
280         status = true;
281         EXPECT_NE(graph, nullptr);
282         InterferenceGraph gr(graph->GetAllocator());
283         gr.Reserve(DEFAULT_CAPACITY1);
284 
285         EXPECT_TRUE(gr.IsChordal());
286 
287         gr.AllocNode();
288         EXPECT_TRUE(gr.IsChordal());
289 
290         gr.AddEdge(0, 1);
291         EXPECT_TRUE(gr.IsChordal());
292 
293         gr.AddEdge(1, 2);
294         EXPECT_TRUE(gr.IsChordal());
295 
296         gr.AddEdge(0, 2);
297         EXPECT_TRUE(gr.IsChordal());
298 
299         // Make nonchordal
300         gr.AllocNode();
301         gr.AllocNode();
302         gr.AddEdge(3, 2);
303         gr.AddEdge(3, 4);
304         gr.AddEdge(0, 4);
305         EXPECT_TRUE(gr.IsChordal());
306     });
307     EXPECT_TRUE(status);
308 }
309 
310 /**
311  * @tc.name: regalloc_test_008
312  * @tc.desc: Verify the LexBFS function.
313  * @tc.type: FUNC
314  * @tc.require: issueNumber
315  */
316 HWTEST_F(RegallocTest, regalloc_test_008, TestSize.Level1)
317 {
318     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
319     const char *test_method_name = "func_main_0";
320     bool status = false;
__anonbbc8952d0a02(Graph* graph, std::string &method_name) 321     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
322         if (test_method_name != method_name) {
323             return;
324         }
325         status = true;
326         EXPECT_NE(graph, nullptr);
327         InterferenceGraph gr(graph->GetAllocator());
328         gr.Reserve(2);
329 
330         gr.AllocNode();
331         gr.AllocNode();
332         gr.AddEdge(0, 1);
333 
334         auto peo = gr.LexBFS();
335         EXPECT_EQ(peo.size(), 2);
336         EXPECT_EQ(peo[0], 0);
337         EXPECT_EQ(peo[1], 1);
338     });
339     EXPECT_TRUE(status);
340 }
341 
342 /**
343  * @tc.name: regalloc_test_009
344  * @tc.desc: Verify the IsChordal function.
345  * @tc.type: FUNC
346  * @tc.require: issueNumber
347  */
348 HWTEST_F(RegallocTest, regalloc_test_009, TestSize.Level1)
349 {
350     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
351     const char *test_method_name = "func_main_0";
352     bool status = false;
__anonbbc8952d0b02(Graph* graph, std::string &method_name) 353     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
354         if (test_method_name != method_name) {
355             return;
356         }
357         status = true;
358         EXPECT_NE(graph, nullptr);
359         InterferenceGraph gr(graph->GetAllocator());
360         gr.Reserve(DEFAULT_CAPACITY2);
361         for (auto i = 0; i < DEFAULT_CAPACITY2; i++) {
362             gr.AllocNode();
363         }
364 
365         for (unsigned i = 0; i < DEFAULT_EDGES2; i++) {
366             auto x = TEST_EDGES2[i].first;
367             auto y = TEST_EDGES2[i].second;
368             gr.AddEdge(x, y);
369         }
370 
371         auto peo = gr.LexBFS();
372         EXPECT_EQ(peo.size(), DEFAULT_CAPACITY2);
373     });
374     EXPECT_TRUE(status);
375 }
376 
377 /**
378  * @tc.name: regalloc_test_010
379  * @tc.desc: Verify the SetColor function.
380  * @tc.type: FUNC
381  * @tc.require: issueNumber
382  */
383 HWTEST_F(RegallocTest, regalloc_test_010, TestSize.Level1)
384 {
385     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
386     const char *test_method_name = "func_main_0";
387     bool status = false;
__anonbbc8952d0c02(Graph* graph, std::string &method_name) 388     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
389         if (test_method_name != method_name) {
390             return;
391         }
392         status = true;
393         EXPECT_NE(graph, nullptr);
394         InterferenceGraph gr(graph->GetAllocator());
395         gr.Reserve(DEFAULT_CAPACITY2);
396 
397         auto *nd0 = gr.AllocNode();
398         auto *nd1 = gr.AllocNode();
399         auto *nd2 = gr.AllocNode();
400         auto *nd3 = gr.AllocNode();
401         auto *nd4 = gr.AllocNode();
402         for (unsigned i = 0; i < DEFAULT_EDGES2; i++) {
403             auto x = TEST_EDGES2[i].first;
404             auto y = TEST_EDGES2[i].second;
405             gr.AddEdge(x, y);
406         }
407         // 32: Max color value
408         // 3: Set max size
409         EXPECT_EQ(gr.AssignColors<32>(3, 0), 3);
410         EXPECT_NE(nd0->GetColor(), nd1->GetColor());
411         EXPECT_NE(nd0->GetColor(), nd2->GetColor());
412         EXPECT_NE(nd0->GetColor(), nd3->GetColor());
413 
414         EXPECT_NE(nd2->GetColor(), nd1->GetColor());
415         EXPECT_NE(nd2->GetColor(), nd3->GetColor());
416 
417         nd4->SetColor(ACC_REG_ID);
418         EXPECT_NE(nd4->GetColor(), nd3->GetColor());
419     });
420     EXPECT_TRUE(status);
421 }
422 
423 /**
424  * @tc.name: regalloc_test_011
425  * @tc.desc: Verify the GetColor function.
426  * @tc.type: FUNC
427  * @tc.require: issueNumber
428  */
429 HWTEST_F(RegallocTest, regalloc_test_011, TestSize.Level1)
430 {
431     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
432     const char *test_method_name = "func_main_0";
433     bool status = false;
__anonbbc8952d0d02(Graph* graph, std::string &method_name) 434     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
435         if (test_method_name != method_name) {
436             return;
437         }
438         status = true;
439         EXPECT_NE(graph, nullptr);
440         const unsigned DEFAULT_CAPACITY = 11;
441         const unsigned DEFAULT_EDGES1 = 12;
442         const unsigned DEFAULT_EDGES2 = 4;
443         ::std::pair<unsigned, unsigned> test_edges1[DEFAULT_EDGES1] = {{0, 1}, {1, 2}, {2, 0}, {0, 3}, {2, 3},  {3, 4},
444                                                                       {6, 5}, {5, 7}, {6, 7}, {9, 8}, {9, 10}, {8, 10}};
445         ::std::pair<unsigned, unsigned> test_edges2[DEFAULT_EDGES2] = {{3, 6}, {6, 9}, {2, 5}, {7, 8}};
446         InterferenceGraph gr(graph->GetAllocator());
447         gr.Reserve(DEFAULT_CAPACITY);
448 
449         std::string name = "test:main" ;
450         std::string test_data = "Nodes: 0\n\n\n"
451                                 "graph test_main {\n"
452                                 "node [colorscheme=spectral9]\n}\n";
453         std::stringstream data;
454         gr.Dump(name, false, data);
455         EXPECT_EQ(data.str(), test_data);
456         auto *nd0 = gr.AllocNode();
457         auto *nd1 = gr.AllocNode();
458         auto *nd2 = gr.AllocNode();
459         auto *nd3 = gr.AllocNode();
460         auto *nd4 = gr.AllocNode();
461         auto *nd5 = gr.AllocNode();
462         auto *nd6 = gr.AllocNode();
463         auto *nd7 = gr.AllocNode();
464         auto *nd8 = gr.AllocNode();
465         auto *nd9 = gr.AllocNode();
466         auto *nd10 = gr.AllocNode();
467 
468         for (unsigned i = 0; i < DEFAULT_EDGES1; i++) {
469             auto x = test_edges1[i].first;
470             auto y = test_edges1[i].second;
471             gr.AddEdge(x, y);
472         }
473         for (unsigned i = 0; i < DEFAULT_EDGES2; i++) {
474             auto x = test_edges2[i].first;
475             auto y = test_edges2[i].second;
476             gr.AddAffinityEdge(x, y);
477         }
478         auto &bias0 = gr.AddBias();
479         auto &bias1 = gr.AddBias();
480         auto &bias2 = gr.AddBias();
481 
482         nd3->SetBias(0);
483         nd6->SetBias(0);
484         nd9->SetBias(0);
485         nd2->SetBias(1);
486         nd5->SetBias(1);
487         nd7->SetBias(2);
488         nd8->SetBias(2);
489 
490         // 32: Max color value
491         // 3: Set max size
492         EXPECT_EQ(gr.AssignColors<32>(3, 0), 3);
493 
494         // Check nodes inequality
495         EXPECT_NE(nd0->GetColor(), nd1->GetColor());
496         EXPECT_NE(nd0->GetColor(), nd2->GetColor());
497         EXPECT_NE(nd0->GetColor(), nd3->GetColor());
498 
499         EXPECT_NE(nd2->GetColor(), nd1->GetColor());
500         EXPECT_NE(nd2->GetColor(), nd3->GetColor());
501 
502         EXPECT_NE(nd4->GetColor(), nd3->GetColor());
503 
504         EXPECT_NE(nd5->GetColor(), nd6->GetColor());
505         EXPECT_NE(nd7->GetColor(), nd6->GetColor());
506         EXPECT_NE(nd5->GetColor(), nd7->GetColor());
507 
508         EXPECT_NE(nd8->GetColor(), nd9->GetColor());
509         EXPECT_NE(nd8->GetColor(), nd10->GetColor());
510         EXPECT_NE(nd9->GetColor(), nd10->GetColor());
511 
512         // Check biases work
513         EXPECT_EQ(nd3->GetColor(), nd6->GetColor());
514         EXPECT_EQ(nd9->GetColor(), nd6->GetColor());
515 
516         EXPECT_EQ(nd2->GetColor(), nd5->GetColor());
517         EXPECT_EQ(nd7->GetColor(), nd8->GetColor());
518 
519         Register color = INVALID_REG;
520         nd7->SetColor(color);
521         EXPECT_NE(nd7->GetColor(), nd8->GetColor());
522 
523         // Check biases values
524         EXPECT_NE(bias0.color, bias1.color);
525         EXPECT_NE(bias0.color, bias2.color);
526 
527         auto inst = graph->CreateInst(Opcode::SaveState);
528         LifeIntervals lifeInter(graph->GetAllocator(), inst);
529         lifeInter.AppendRange({90, 100});
530         lifeInter.AppendRange({80, 90});
531         lifeInter.AppendRange({40, 50});
532         lifeInter.AppendRange({35, 40});
533         lifeInter.AppendRange({20, 34});
534         lifeInter.StartFrom(30);
535         lifeInter.AppendRange({10, 20});
536         lifeInter.AppendGroupRange({10, 25});
537         lifeInter.AppendGroupRange({10, 79});
538         lifeInter.AppendGroupRange({10, 95});
539 
540         nd0->Assign(&lifeInter);
541         nd1->Assign(&lifeInter);
542         nd2->Assign(&lifeInter);
543         nd3->Assign(&lifeInter);
544         nd4->Assign(&lifeInter);
545         nd5->Assign(&lifeInter);
546         nd6->Assign(&lifeInter);
547         nd7->Assign(&lifeInter);
548         nd8->Assign(&lifeInter);
549         nd9->Assign(&lifeInter);
550         nd10->Assign(&lifeInter);
551 
552         test_data = "Nodes: 0\n\n\n"
553                     "graph test_main {\n"
554                         "node [colorscheme=spectral9]\n"
555                     "}\n"
556                     "Nodes: 11\n\n\n"
557                     "graph test_main {\n"
558                         "node [colorscheme=spectral9]\n"
559                         "0 [color=0, xlabel=\"0\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
560                         "1 [color=1, xlabel=\"1\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
561                         "2 [color=2, xlabel=\"2\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
562                         "3 [color=1, xlabel=\"1\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
563                         "4 [color=0, xlabel=\"0\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
564                         "5 [color=2, xlabel=\"2\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
565                         "6 [color=1, xlabel=\"1\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
566                         "7 [color=0, xlabel=\"255\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
567                         "8 [color=0, xlabel=\"0\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
568                         "9 [color=1, xlabel=\"1\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
569                         "10 [color=2, xlabel=\"2\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
570                         "1--0\n2--0\n2--1\n3--0\n3--2\n4--3\n6--5\n7--5\n7--6\n9--8\n10--8\n10--9\n}\n";
571         data.clear();
572         gr.Dump(name, false, data);
573         EXPECT_EQ(data.str(), test_data);
574         data.str("");
575         nd10->SetFixedColor(1, true);
576         test_data = "Nodes: 11\n\n\n"
577                     "graph test_main {\n"
578                         "node [colorscheme=spectral9]\n"
579                         "0 [color=0, xlabel=\"0\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
580                         "1 [color=1, xlabel=\"1\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
581                         "2 [color=2, xlabel=\"2\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
582                         "3 [color=1, xlabel=\"1\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
583                         "4 [color=0, xlabel=\"0\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
584                         "5 [color=2, xlabel=\"2\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
585                         "6 [color=1, xlabel=\"1\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
586                         "7 [color=0, xlabel=\"255\", tooltip=\"[10:100) {inst v61}\", shape=\"ellipse\"]\n"
587                         "8 [color=0, xlabel=\"0\", tooltip=\"[10:100) {inst v61}\", shape=\"hexagon\"]\n"
588                         "9 [color=1, xlabel=\"1\", tooltip=\"[10:100) {inst v61}\", shape=\"hexagon\"]\n"
589                         "1--0\n2--0\n2--1\n3--0\n3--2\n4--3\n6--5\n7--5\n7--6\n9--8\n}\n";
590         data.clear();
591         gr.Dump(name, true, data);
592         EXPECT_EQ(data.str(), test_data);
593 
594         // Check biases work
595         EXPECT_EQ(nd3->GetColor(), nd6->GetColor());
596         EXPECT_EQ(nd9->GetColor(), nd6->GetColor());
597         EXPECT_EQ(nd2->GetColor(), nd5->GetColor());
598     });
599     EXPECT_TRUE(status);
600 }
601 
602 /**
603  * @tc.name: regalloc_test_012
604  * @tc.desc: Verify the ConvertRegType function.
605  * @tc.type: FUNC
606  * @tc.require: issueNumber
607  */
608 HWTEST_F(RegallocTest, regalloc_test_012, TestSize.Level1)
609 {
610     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
611     const char *test_method_name = "func4";
612     bool status = false;
__anonbbc8952d0e02(Graph* graph, std::string &method_name) 613     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
614         if (test_method_name != method_name) {
615             return;
616         }
617         status = true;
618         EXPECT_NE(graph, nullptr);
619         EXPECT_EQ(ConvertRegType(graph, DataType::Type::FLOAT32), DataType::Type::UINT64);
620     });
621     EXPECT_TRUE(status);
622 }
623 
624 /**
625  * @tc.name: regalloc_test_013
626  * @tc.desc: Verify the AbortIfFailed function.
627  * @tc.type: FUNC
628  * @tc.require: issueNumber
629  */
630 HWTEST_F(RegallocTest, regalloc_test_013, TestSize.Level1)
631 {
632     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
633     const char *test_method_name = "func_main_0";
634     bool status = false;
__anonbbc8952d0f02(Graph* graph, std::string &method_name) 635     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
636         if (test_method_name != method_name) {
637             return;
638         }
639         status = true;
640         EXPECT_NE(graph, nullptr);
641         RegMask reg_mask(0U);
642         std::shared_ptr<RegAllocBase> base = std::make_shared<RegAllocGraphColoring>(graph);
643         base->SetRegMask(reg_mask);
644         EXPECT_EQ(base->GetRegMask().GetSize(), 32);  // 32: It's registers number
645         base->SetVRegMask(reg_mask);
646         EXPECT_EQ(base->GetVRegMask().GetSize(), 32);  // 32: It's registers number
647         base->SetSlotsCount(0);
648         EXPECT_EQ(base->GetStackMask().GetSize(), 0);
649         EXPECT_NE(base->GetPassName(), nullptr);
650         EXPECT_TRUE(base->AbortIfFailed());
651     });
652     EXPECT_TRUE(status);
653 }
654 
655 /**
656  * @tc.name: regalloc_test_014
657  * @tc.desc: Verify the SetCompilerDumpLifeIntervals function.
658  * @tc.type: FUNC
659  * @tc.require: issueNumber
660  */
661 HWTEST_F(RegallocTest, regalloc_test_014, TestSize.Level1)
662 {
663     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
664     const char *test_method_name = "func4";
665     bool status = false;
__anonbbc8952d1002(Graph* graph, std::string &method_name) 666     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
667         if (test_method_name != method_name) {
668             return;
669         }
670         status = true;
671         EXPECT_NE(graph, nullptr);
672 
673         RegisterMap map(graph->GetLocalAllocator());
674         RegMask reg_mask(0U);
675         RegAllocGraphColoring base(graph);
676         base.SetRegMask(reg_mask);
677 
678         LocationMask reg_mask1 = base.GetRegMask();
679         size_t priority_reg = 1;
680         map.SetMask(reg_mask1, priority_reg);
681         map.SetCallerFirstMask(reg_mask1, 0, 1);
682         EXPECT_EQ(map.RegallocToCodegenReg(0), 2);
683         map.SetCallerFirstMask(reg_mask1, 1, 1);
684         EXPECT_EQ(map.RegallocToCodegenReg(1), 2);
685         reg_mask1.Set(0);
686         map.SetCallerFirstMask(reg_mask1, 1, 1);
687         EXPECT_EQ(map.RegallocToCodegenReg(2), 4);
688 
689         EXPECT_EQ(map.Size(), 32);
690         EXPECT_TRUE(map.IsRegAvailable(0, Arch::AARCH32));
691         EXPECT_TRUE(map.IsRegAvailable(0, Arch::AARCH64));
692 
693         Register reg = 65; // 65: Random Numbers
694         EXPECT_FALSE(map.IsRegAvailable(reg, Arch::AARCH32));
695 
696         std::string test_data = "Regalloc -> Codegen\n"
697                                 "r0 -> r2\n"
698                                 "r1 -> r3\n"
699                                 "r2 -> r4\n"
700                                 "r3 -> r5\n"
701                                 "r4 -> r6\n"
702                                 "r5 -> r7\n"
703                                 "r6 -> r8\n"
704                                 "r7 -> r9\n"
705                                 "r8 -> r10\n"
706                                 "r9 -> r11\n"
707                                 "r10 -> r12\n"
708                                 "r11 -> r13\n"
709                                 "r12 -> r14\n"
710                                 "r13 -> r15\n"
711                                 "r14 -> r16\n"
712                                 "r15 -> r17\n"
713                                 "r16 -> r18\n"
714                                 "r17 -> r19\n"
715                                 "r18 -> r20\n"
716                                 "r19 -> r21\n"
717                                 "r20 -> r22\n"
718                                 "r21 -> r23\n"
719                                 "r22 -> r24\n"
720                                 "r23 -> r25\n"
721                                 "r24 -> r26\n"
722                                 "r25 -> r27\n"
723                                 "r26 -> r28\n"
724                                 "r27 -> r29\n"
725                                 "r28 -> r30\n"
726                                 "r29 -> r31\n"
727                                 "r30 -> r1\n"
728                                 "Unavailable for RA:\n"
729                                 "r31 -> r0\n";
730         std::stringstream data;
731         EXPECT_EQ(map.CodegenToRegallocReg(0), 31);
732         map.Dump(&data);
733         EXPECT_EQ(data.str(), test_data);
734         EXPECT_EQ(map.Size(), 32);
735     });
736     EXPECT_TRUE(status);
737 }
738 
739 /**
740  * @tc.name: regalloc_test_015
741  * @tc.desc: Verify the Resolve function.
742  * @tc.type: FUNC
743  * @tc.require: issueNumber
744  */
745 HWTEST_F(RegallocTest, regalloc_test_015, TestSize.Level1)
746 {
747     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
748     const char *test_method_name = "func5";
749     bool status = false;
__anonbbc8952d1102(Graph* graph, std::string &method_name) 750     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
751         if (test_method_name != method_name) {
752             return;
753         }
754         status = true;
755         EXPECT_NE(graph, nullptr);
756         for (auto block : graph->GetBlocksRPO()) {
757             for (auto inst : block->AllInstsSafe()) {
758                 if (inst->IsSaveState()) {
759                     continue;
760                 }
761                 inst->SetOpcode(Opcode::Phi);
762                 EXPECT_EQ(inst->GetOpcode(), Opcode::Phi);
763             }
764         }
765         EXPECT_TRUE(graph->RunPass<LivenessAnalyzer>());
766         RegAllocResolver regalloc(graph);
767         regalloc.Resolve();
768         EXPECT_TRUE(regalloc.ResolveCatchPhis());
769     });
770     EXPECT_TRUE(status);
771 }
772 
773 /**
774  * @tc.name: regalloc_test_016
775  * @tc.desc: Verify the ResolveIfRequired function.
776  * @tc.type: FUNC
777  * @tc.require: issueNumber
778  */
779 HWTEST_F(RegallocTest, regalloc_test_016, TestSize.Level1)
780 {
781     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
782     const char *test_method_name = "func4";
783     bool status = false;
__anonbbc8952d1202(Graph* graph, std::string &method_name) 784     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
785         if (test_method_name != method_name) {
786             return;
787         }
788         EXPECT_NE(graph, nullptr);
789         EXPECT_TRUE(graph->RunPass<Cleanup>());
790         EXPECT_TRUE(graph->RunPass<bytecodeopt::RegAccAlloc>());
791         EXPECT_FALSE(graph->RunPass<Cleanup>());
792         EXPECT_TRUE(RegAlloc(graph));
793         EXPECT_FALSE(graph->RunPass<Cleanup>());
794         EXPECT_TRUE(graph->RunPass<bytecodeopt::RegEncoder>());
795         for (const auto &block : graph->GetVectorBlocks()) {
796             if (block == nullptr) {
797                 continue;
798             }
799             for (auto inst : block->AllInsts()) {
800                 if (inst->GetOpcode() != Opcode::SpillFill) {
801                     continue;
802                 }
803                 status = true;
804                 Location src(Location::Kind::IMMEDIATE, 0);
805                 Location dst(Location::Kind::REGISTER, 0);
806                 auto spill_fill_inst = inst->CastToSpillFill();
807                 spill_fill_inst->AddSpillFill(src, dst, DataType::UINT64);
808                 EXPECT_EQ(spill_fill_inst->GetSpillFills().size(), 6);  // It's spillfille size
809 
810                 SpillFillsResolver resolver(graph);
811                 resolver.Resolve(spill_fill_inst);
812 
813                 Location src1(Location::Kind::REGISTER, 0);
814                 Location dst1(Location::Kind::STACK_ARGUMENT, 0);
815                 auto spill_fill_inst1 = inst->CastToSpillFill();
816                 spill_fill_inst1->AddSpillFill(src1, dst1, DataType::UINT64);
817                 EXPECT_EQ(spill_fill_inst->GetSpillFills().size(), 7);  // It's spillfille size
818                 resolver.Resolve(spill_fill_inst1);
819 
820                 SpillFillsResolver sResolver1(graph);
821                 sResolver1.Resolve(spill_fill_inst);
822                 sResolver1.ResolveIfRequired(spill_fill_inst);
823                 sResolver1.Run();
824 
825                 auto spill_fill_inst2 = inst->CastToSpillFill();
826                 spill_fill_inst2->AddSpillFill(src1, dst, DataType::UINT64);
827                 EXPECT_EQ(spill_fill_inst->GetSpillFills().size(), 8);  // It's spillfille size
828                 resolver.Resolve(spill_fill_inst2);
829 
830                 Location src2(Location::Kind::STACK, 30);  // It's random number
831                 Location dst3(Location::Kind::STACK, 25);  // It's random number
832                 spill_fill_inst->AddSpillFill(src2, dst3, DataType::UINT64);
833                 EXPECT_EQ(spill_fill_inst->GetSpillFills().size(), 8);  // It's spillfille size
834                 Location dst4(Location::Kind::FP_REGISTER, 0);
835                 spill_fill_inst->AddSpillFill(src1, dst4, DataType::UINT64);
836                 EXPECT_EQ(spill_fill_inst->GetSpillFills().size(), 9);  // It's spillfille size
837             }
838         }
839     });
840     EXPECT_TRUE(status);
841 }
842 
843 /**
844  * @tc.name: regalloc_test_017
845  * @tc.desc: Verify the Run function.
846  * @tc.type: FUNC
847  * @tc.require: issueNumber
848  */
849 HWTEST_F(RegallocTest, regalloc_test_017, TestSize.Level1)
850 {
851     std::string pfile = GRAPH_TEST_ABC_DIR "cleanUpTest.abc";
852     const char *test_method_name = "func_main_0";
853     bool status = false;
854     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph,
__anonbbc8952d1302(Graph* graph, std::string &method_name) 855         std::string &method_name) {
856         if (test_method_name != method_name) {
857             return;
858         }
859         EXPECT_NE(graph, nullptr);
860         EXPECT_TRUE(graph->RunPass<LivenessAnalyzer>());
861         auto liven = &graph->GetAnalysis<LivenessAnalyzer>();
862         int32_t reg = 0;
863         int32_t index = 0; // index: mark opcode
864         int32_t index1 = 2;
865         int32_t index2 = 3;
866         for (const auto &block : graph->GetVectorBlocks()) {
867             if (block == nullptr) {
868                 continue;
869             }
870             for (auto inst : block->AllInsts()) {
871                 if (inst->GetOpcode() != Opcode::Phi) {
872                     continue;
873                 }
874                 if (index == index1 || index == index2) {
875                     status = true;
876                     auto param = liven->GetInstLifeIntervals(inst);
877                     param->SetReg(reg++);
878                     param->AppendRange({0, 10});
879                     param->StartFrom(0);
880                     EXPECT_EQ(param->GetRanges().size(), 2);
881                     EXPECT_EQ(param->GetReg(), reg - 1);
882                     EXPECT_NE(param->SplitAt(1, graph->GetAllocator()), nullptr);
883                     param->SetLocation(Location::MakeConstant(0));
884                     EXPECT_EQ(param->GetLocation().GetValue(), 0);
885                 }
886                 index++;
887             }
888         }
889         for (auto interval : liven->GetLifeIntervals()) {
890             interval->StartFrom(0);
891             EXPECT_EQ(interval->GetRanges().size(), 1);
892         }
893         SplitResolver resolver(graph, liven);
894         resolver.Run();
895     });
896     EXPECT_TRUE(status);
897 }
898 
899 /**
900  * @tc.name: regalloc_test_018
901  * @tc.desc: Verify the RegAllocStat function.
902  * @tc.type: FUNC
903  * @tc.require: issueNumber
904  */
905 HWTEST_F(RegallocTest, regalloc_test_018, TestSize.Level1)
906 {
907     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
908     const char *test_method_name = "func5";
909     bool status = false;
__anonbbc8952d1402(Graph* graph, std::string &method_name) 910     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
911         if (test_method_name != method_name) {
912             return;
913         }
914         status = true;
915         EXPECT_NE(graph, nullptr);
916         EXPECT_TRUE(graph->RunPass<LivenessAnalyzer>());
917         auto interval = graph->GetAnalysis<LivenessAnalyzer>().GetLifeIntervals();
918         RegAllocStat sts(interval);
919         Location rhs(Location::Kind::REGISTER, 0);
920         for (const auto &interv : interval) {
921             interv->SetLocation(rhs);
922         }
923         RegAllocStat st1(interval);
924         EXPECT_EQ(st1.GetVSlotCount(), 0);
925 
926         Location rhs1(Location::Kind::FP_REGISTER, 1);
927         for (const auto &interv : interval) {
928             interv->SetLocation(rhs1);
929         }
930         RegAllocStat st2(interval);
931         EXPECT_EQ(st2.GetSlotCount(), 0);
932 
933         Location rhs2(Location::Kind::STACK, 2);
934         for (const auto &interv : interval) {
935             interv->SetLocation(rhs2);
936         }
937         RegAllocStat st3(interval);
938         EXPECT_EQ(st3.GetVRegCount(), 0);
939 
940         for (const auto &interv : interval) {
941             interv->SetPhysicalReg(1, DataType::UINT64);
942         }
943         RegAllocStat st4(interval);
944         EXPECT_EQ(st4.GetRegCount(), 0);
945     });
946     EXPECT_TRUE(status);
947 }
948 
949 /**
950  * @tc.name: regalloc_test_019
951  * @tc.desc: Verify the SetCatchBegin function.
952  * @tc.type: FUNC
953  * @tc.require: issueNumber
954  */
955 HWTEST_F(RegallocTest, regalloc_test_019, TestSize.Level1)
956 {
957     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTryTest.abc";
958     const char *test_method_name = "func_main_0";
959     bool status = false;
__anonbbc8952d1502(Graph* graph, std::string &method_name) 960     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
961         if (test_method_name != method_name) {
962             return;
963         }
964         status = true;
965         EXPECT_NE(graph, nullptr);
966         for (auto block : graph->GetBlocksRPO()) {
967             for (auto inst : block->AllInstsSafe()) {
968                 if (inst->IsSaveState()) {
969                     continue;
970                 }
971                 inst->SetOpcode(Opcode::Phi);
972                 EXPECT_EQ(inst->GetOpcode(), Opcode::Phi);
973             }
974         }
975         graph->RunPass<LivenessAnalyzer>();
976         RegAllocResolver regalloc(graph);
977         regalloc.Resolve();
978         for (auto block : graph->GetBlocksRPO()) {
979             block->SetCatchBegin(true);
980             EXPECT_TRUE(block->IsCatchBegin());
981         }
982         EXPECT_TRUE(regalloc.ResolveCatchPhis());
983     });
984     EXPECT_TRUE(status);
985 }
986 
987 /**
988  * @tc.name: regalloc_test_020
989  * @tc.desc: Verify the ResolveCatchPhis function.
990  * @tc.type: FUNC
991  * @tc.require: issueNumber
992  */
993 HWTEST_F(RegallocTest, regalloc_test_020, TestSize.Level1)
994 {
995     std::string pfile = GRAPH_TEST_ABC_DIR "regallocTest.abc";
996     const char *test_method_name = "func5";
997     bool status = false;
__anonbbc8952d1602(Graph* graph, std::string &method_name) 998     graph_test_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) {
999         if (test_method_name != method_name) {
1000             return;
1001         }
1002         EXPECT_NE(graph, nullptr);
1003         graph->RunPass<LivenessAnalyzer>();
1004         ArenaVector<bool> reg_write(graph->GetLocalAllocator()->Adapter());
1005         size_t offset = 32;
1006         reg_write.resize(offset);
1007         graph->InitUsedRegs<DataType::INT64>(&reg_write);
1008 
1009         for (auto block : graph->GetBlocksRPO()) {
1010             if (block == nullptr) {
1011                 continue;
1012             }
1013             for (auto inst : block->AllInstsSafe()) {
1014                 if (inst->GetOpcode() == Opcode::Phi || inst->GetOpcode() == Opcode::CatchPhi ||
1015                     inst->GetOpcode() == Opcode::SaveState) {
1016                     continue;
1017                 }
1018                 for (size_t i = 0; i < inst->GetInputsCount(); i++) {
1019                     if (inst->GetLocation(i).IsUnallocatedRegister()) {
1020                         status = true;
1021                         Location src(Location::Kind::IMMEDIATE, i);
1022                         inst->SetLocation(i, src);
1023                         EXPECT_FALSE(inst->GetLocation(i).IsConstant());
1024                         inst->SetType(DataType::UINT64);
1025                         EXPECT_EQ(inst->GetType(), DataType::UINT64);
1026                     }
1027                 }
1028             }
1029         }
1030         for (auto block : graph->GetBlocksRPO()) {
1031             for (auto inst : block->AllInstsSafe()) {
1032                 if (inst->IsSaveState()) {
1033                     continue;
1034                 }
1035                 inst->SetOpcode(Opcode::Phi);
1036                 EXPECT_EQ(inst->GetOpcode(), Opcode::Phi);
1037             }
1038         }
1039         RegAllocResolver regalloc(graph);
1040         regalloc.Resolve();
1041         EXPECT_TRUE(regalloc.ResolveCatchPhis());
1042     });
1043     EXPECT_TRUE(status);
1044 }
1045 
1046 /**
1047  * @tc.name: regalloc_test_021
1048  * @tc.desc: Verify the Arch::AARCH32 function.
1049  * @tc.type: FUNC
1050  * @tc.require: issueNumber
1051  */
1052 HWTEST_F(RegallocTest, regalloc_test_021, TestSize.Level1)
1053 {
1054     std::string pfile_name = GRAPH_TEST_ABC_DIR "regallocTest.abc";
1055     const char *test_method_name = "#*#func4";
1056     bool status = false;
1057     auto pfile = panda_file::OpenPandaFile(pfile_name);
1058     for (uint32_t id : pfile->GetClasses()) {
1059         panda_file::File::EntityId record_id {id};
1060 
1061         if (pfile->IsExternal(record_id)) {
1062             continue;
1063         }
1064 
1065         panda_file::ClassDataAccessor cda {*pfile, record_id};
__anonbbc8952d1702(panda_file::MethodDataAccessor &mda) 1066         cda.EnumerateMethods([&pfile, test_method_name, &status](panda_file::MethodDataAccessor &mda) {
1067             if (mda.IsExternal()) {
1068                 return;
1069             }
1070             ArenaAllocator allocator {SpaceType::SPACE_TYPE_COMPILER};
1071             ArenaAllocator local_allocator {SpaceType::SPACE_TYPE_COMPILER, nullptr, true};
1072 
1073             auto method_ptr = reinterpret_cast<compiler::RuntimeInterface::MethodPtr>(
1074                 mda.GetMethodId().GetOffset());
1075             panda::BytecodeOptimizerRuntimeAdapter adapter(mda.GetPandaFile());
1076             auto *graph = allocator.New<Graph>(&allocator, &local_allocator, Arch::AARCH32, method_ptr, &adapter,
1077                                                false, nullptr, true, true);
1078             graph->RunPass<panda::compiler::IrBuilder>();
1079 
1080             auto method_name = std::string(utf::Mutf8AsCString(pfile->GetStringData(mda.GetNameId()).data));
1081             if (test_method_name != method_name) {
1082                 return;
1083             }
1084             status = true;
1085             EXPECT_TRUE(graph->RunPass<bytecodeopt::RegAccAlloc>());
1086             EXPECT_TRUE(RegAlloc(graph));
1087         });
1088     }
1089     EXPECT_TRUE(status);
1090 }
1091 }  // namespace panda::compiler
1092