1 /*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "graph_visualizer.h"
18
19 #include <dlfcn.h>
20
21 #include <cctype>
22 #include <ios>
23 #include <sstream>
24
25 #include "android-base/stringprintf.h"
26 #include "art_method.h"
27 #include "art_method-inl.h"
28 #include "base/intrusive_forward_list.h"
29 #include "bounds_check_elimination.h"
30 #include "builder.h"
31 #include "code_generator.h"
32 #include "data_type-inl.h"
33 #include "dead_code_elimination.h"
34 #include "dex/descriptors_names.h"
35 #include "disassembler.h"
36 #include "inliner.h"
37 #include "licm.h"
38 #include "nodes.h"
39 #include "optimization.h"
40 #include "reference_type_propagation.h"
41 #include "register_allocator_linear_scan.h"
42 #include "scoped_thread_state_change-inl.h"
43 #include "ssa_liveness_analysis.h"
44 #include "utils/assembler.h"
45
46 namespace art HIDDEN {
47
48 // Unique pass-name to identify that the dump is for printing to log.
49 constexpr const char* kDebugDumpName = "debug";
50 constexpr const char* kDebugDumpGraphName = "debug_graph";
51
52 using android::base::StringPrintf;
53
HasWhitespace(const char * str)54 static bool HasWhitespace(const char* str) {
55 DCHECK(str != nullptr);
56 while (str[0] != 0) {
57 if (isspace(str[0])) {
58 return true;
59 }
60 str++;
61 }
62 return false;
63 }
64
65 class StringList {
66 public:
67 enum Format {
68 kArrayBrackets,
69 kSetBrackets,
70 };
71
72 // Create an empty list
StringList(Format format=kArrayBrackets)73 explicit StringList(Format format = kArrayBrackets) : format_(format), is_empty_(true) {}
74
75 // Construct StringList from a linked list. List element class T
76 // must provide methods `GetNext` and `Dump`.
77 template<class T>
StringList(T * first_entry,Format format=kArrayBrackets)78 explicit StringList(T* first_entry, Format format = kArrayBrackets) : StringList(format) {
79 for (T* current = first_entry; current != nullptr; current = current->GetNext()) {
80 current->Dump(NewEntryStream());
81 }
82 }
83 // Construct StringList from a list of elements. The value type must provide method `Dump`.
84 template <typename Container>
StringList(const Container & list,Format format=kArrayBrackets)85 explicit StringList(const Container& list, Format format = kArrayBrackets) : StringList(format) {
86 for (const typename Container::value_type& current : list) {
87 current.Dump(NewEntryStream());
88 }
89 }
90
NewEntryStream()91 std::ostream& NewEntryStream() {
92 if (is_empty_) {
93 is_empty_ = false;
94 } else {
95 sstream_ << ",";
96 }
97 return sstream_;
98 }
99
100 private:
101 Format format_;
102 bool is_empty_;
103 std::ostringstream sstream_;
104
105 friend std::ostream& operator<<(std::ostream& os, const StringList& list);
106 };
107
operator <<(std::ostream & os,const StringList & list)108 std::ostream& operator<<(std::ostream& os, const StringList& list) {
109 switch (list.format_) {
110 case StringList::kArrayBrackets: return os << "[" << list.sstream_.str() << "]";
111 case StringList::kSetBrackets: return os << "{" << list.sstream_.str() << "}";
112 }
113 }
114
115 // On target: load `libart-disassembler` only when required (to save on memory).
116 // On host: `libart-disassembler` should be linked directly (either as a static or dynamic lib)
117 #ifdef ART_TARGET
118 using create_disasm_prototype = Disassembler*(InstructionSet, DisassemblerOptions*);
119 #endif
120
121 class HGraphVisualizerDisassembler {
122 public:
HGraphVisualizerDisassembler(InstructionSet instruction_set,const uint8_t * base_address,const uint8_t * end_address)123 HGraphVisualizerDisassembler(InstructionSet instruction_set,
124 const uint8_t* base_address,
125 const uint8_t* end_address)
126 : instruction_set_(instruction_set), disassembler_(nullptr) {
127 #ifdef ART_TARGET
128 constexpr const char* libart_disassembler_so_name =
129 kIsDebugBuild ? "libartd-disassembler.so" : "libart-disassembler.so";
130 libart_disassembler_handle_ = dlopen(libart_disassembler_so_name, RTLD_NOW);
131 if (libart_disassembler_handle_ == nullptr) {
132 LOG(ERROR) << "Failed to dlopen " << libart_disassembler_so_name << ": " << dlerror();
133 return;
134 }
135 constexpr const char* create_disassembler_symbol = "create_disassembler";
136 create_disasm_prototype* create_disassembler = reinterpret_cast<create_disasm_prototype*>(
137 dlsym(libart_disassembler_handle_, create_disassembler_symbol));
138 if (create_disassembler == nullptr) {
139 LOG(ERROR) << "Could not find " << create_disassembler_symbol << " entry in "
140 << libart_disassembler_so_name << ": " << dlerror();
141 return;
142 }
143 #endif
144 // Reading the disassembly from 0x0 is easier, so we print relative
145 // addresses. We will only disassemble the code once everything has
146 // been generated, so we can read data in literal pools.
147 disassembler_ = std::unique_ptr<Disassembler>(create_disassembler(
148 instruction_set,
149 new DisassemblerOptions(/* absolute_addresses= */ false,
150 base_address,
151 end_address,
152 /* can_read_literals= */ true,
153 Is64BitInstructionSet(instruction_set)
154 ? &Thread::DumpThreadOffset<PointerSize::k64>
155 : &Thread::DumpThreadOffset<PointerSize::k32>)));
156 }
157
~HGraphVisualizerDisassembler()158 ~HGraphVisualizerDisassembler() {
159 // We need to call ~Disassembler() before we close the library.
160 disassembler_.reset();
161 #ifdef ART_TARGET
162 if (libart_disassembler_handle_ != nullptr) {
163 dlclose(libart_disassembler_handle_);
164 }
165 #endif
166 }
167
Disassemble(std::ostream & output,size_t start,size_t end) const168 void Disassemble(std::ostream& output, size_t start, size_t end) const {
169 if (disassembler_ == nullptr) {
170 return;
171 }
172
173 const uint8_t* base = disassembler_->GetDisassemblerOptions()->base_address_;
174 if (instruction_set_ == InstructionSet::kThumb2) {
175 // ARM and Thumb-2 use the same disassembler. The bottom bit of the
176 // address is used to distinguish between the two.
177 base += 1;
178 }
179 disassembler_->Dump(output, base + start, base + end);
180 }
181
182 private:
183 InstructionSet instruction_set_;
184 std::unique_ptr<Disassembler> disassembler_;
185
186 #ifdef ART_TARGET
187 void* libart_disassembler_handle_;
188 #endif
189 };
190
191
192 /**
193 * HGraph visitor to generate a file suitable for the c1visualizer tool and IRHydra.
194 */
195 class HGraphVisualizerPrinter final : public HGraphDelegateVisitor {
196 public:
HGraphVisualizerPrinter(HGraph * graph,std::ostream & output,const char * pass_name,bool is_after_pass,bool graph_in_bad_state,const CodeGenerator * codegen,const BlockNamer & namer,const DisassemblyInformation * disasm_info=nullptr)197 HGraphVisualizerPrinter(HGraph* graph,
198 std::ostream& output,
199 const char* pass_name,
200 bool is_after_pass,
201 bool graph_in_bad_state,
202 const CodeGenerator* codegen,
203 const BlockNamer& namer,
204 const DisassemblyInformation* disasm_info = nullptr)
205 : HGraphDelegateVisitor(graph),
206 output_(output),
207 pass_name_(pass_name),
208 is_after_pass_(is_after_pass),
209 graph_in_bad_state_(graph_in_bad_state),
210 codegen_(codegen),
211 disasm_info_(disasm_info),
212 namer_(namer),
213 disassembler_(disasm_info_ != nullptr
214 ? new HGraphVisualizerDisassembler(
215 codegen_->GetInstructionSet(),
216 codegen_->GetAssembler().CodeBufferBaseAddress(),
217 codegen_->GetAssembler().CodeBufferBaseAddress()
218 + codegen_->GetAssembler().CodeSize())
219 : nullptr),
220 indent_(0) {}
221
Flush()222 void Flush() {
223 // We use "\n" instead of std::endl to avoid implicit flushing which
224 // generates too many syscalls during debug-GC tests (b/27826765).
225 output_ << std::flush;
226 }
227
StartTag(const char * name)228 void StartTag(const char* name) {
229 AddIndent();
230 output_ << "begin_" << name << "\n";
231 indent_++;
232 }
233
EndTag(const char * name)234 void EndTag(const char* name) {
235 indent_--;
236 AddIndent();
237 output_ << "end_" << name << "\n";
238 }
239
PrintProperty(const char * name,HBasicBlock * blk)240 void PrintProperty(const char* name, HBasicBlock* blk) {
241 AddIndent();
242 output_ << name << " \"" << namer_.GetName(blk) << "\"\n";
243 }
244
PrintProperty(const char * name,const char * property)245 void PrintProperty(const char* name, const char* property) {
246 AddIndent();
247 output_ << name << " \"" << property << "\"\n";
248 }
249
PrintProperty(const char * name,const char * property,int id)250 void PrintProperty(const char* name, const char* property, int id) {
251 AddIndent();
252 output_ << name << " \"" << property << id << "\"\n";
253 }
254
PrintEmptyProperty(const char * name)255 void PrintEmptyProperty(const char* name) {
256 AddIndent();
257 output_ << name << "\n";
258 }
259
PrintTime(const char * name)260 void PrintTime(const char* name) {
261 AddIndent();
262 output_ << name << " " << time(nullptr) << "\n";
263 }
264
PrintInt(const char * name,int value)265 void PrintInt(const char* name, int value) {
266 AddIndent();
267 output_ << name << " " << value << "\n";
268 }
269
AddIndent()270 void AddIndent() {
271 for (size_t i = 0; i < indent_; ++i) {
272 output_ << " ";
273 }
274 }
275
PrintPredecessors(HBasicBlock * block)276 void PrintPredecessors(HBasicBlock* block) {
277 AddIndent();
278 output_ << "predecessors";
279 for (HBasicBlock* predecessor : block->GetPredecessors()) {
280 output_ << " \"" << namer_.GetName(predecessor) << "\" ";
281 }
282 if (block->IsEntryBlock() && (disasm_info_ != nullptr)) {
283 output_ << " \"" << kDisassemblyBlockFrameEntry << "\" ";
284 }
285 output_<< "\n";
286 }
287
PrintSuccessors(HBasicBlock * block)288 void PrintSuccessors(HBasicBlock* block) {
289 AddIndent();
290 output_ << "successors";
291 for (HBasicBlock* successor : block->GetNormalSuccessors()) {
292 output_ << " \"" << namer_.GetName(successor) << "\" ";
293 }
294 output_<< "\n";
295 }
296
PrintExceptionHandlers(HBasicBlock * block)297 void PrintExceptionHandlers(HBasicBlock* block) {
298 bool has_slow_paths = block->IsExitBlock() &&
299 (disasm_info_ != nullptr) &&
300 !disasm_info_->GetSlowPathIntervals().empty();
301 if (IsDebugDump() && block->GetExceptionalSuccessors().empty() && !has_slow_paths) {
302 return;
303 }
304 AddIndent();
305 output_ << "xhandlers";
306 for (HBasicBlock* handler : block->GetExceptionalSuccessors()) {
307 output_ << " \"" << namer_.GetName(handler) << "\" ";
308 }
309 if (has_slow_paths) {
310 output_ << " \"" << kDisassemblyBlockSlowPaths << "\" ";
311 }
312 output_<< "\n";
313 }
314
DumpLocation(std::ostream & stream,const Location & location)315 void DumpLocation(std::ostream& stream, const Location& location) {
316 DCHECK(codegen_ != nullptr);
317 if (location.IsRegister()) {
318 codegen_->DumpCoreRegister(stream, location.reg());
319 } else if (location.IsFpuRegister()) {
320 codegen_->DumpFloatingPointRegister(stream, location.reg());
321 } else if (location.IsConstant()) {
322 stream << "#";
323 HConstant* constant = location.GetConstant();
324 if (constant->IsIntConstant()) {
325 stream << constant->AsIntConstant()->GetValue();
326 } else if (constant->IsLongConstant()) {
327 stream << constant->AsLongConstant()->GetValue();
328 } else if (constant->IsFloatConstant()) {
329 stream << constant->AsFloatConstant()->GetValue();
330 } else if (constant->IsDoubleConstant()) {
331 stream << constant->AsDoubleConstant()->GetValue();
332 } else if (constant->IsNullConstant()) {
333 stream << "null";
334 }
335 } else if (location.IsInvalid()) {
336 stream << "invalid";
337 } else if (location.IsStackSlot()) {
338 stream << location.GetStackIndex() << "(sp)";
339 } else if (location.IsFpuRegisterPair()) {
340 codegen_->DumpFloatingPointRegister(stream, location.low());
341 stream << "|";
342 codegen_->DumpFloatingPointRegister(stream, location.high());
343 } else if (location.IsRegisterPair()) {
344 codegen_->DumpCoreRegister(stream, location.low());
345 stream << "|";
346 codegen_->DumpCoreRegister(stream, location.high());
347 } else if (location.IsUnallocated()) {
348 stream << "unallocated";
349 } else if (location.IsDoubleStackSlot()) {
350 stream << "2x" << location.GetStackIndex() << "(sp)";
351 } else {
352 DCHECK(location.IsSIMDStackSlot());
353 stream << "4x" << location.GetStackIndex() << "(sp)";
354 }
355 }
356
StartAttributeStream(const char * name=nullptr)357 std::ostream& StartAttributeStream(const char* name = nullptr) {
358 if (name == nullptr) {
359 output_ << " ";
360 } else {
361 DCHECK(!HasWhitespace(name)) << "Checker does not allow spaces in attributes";
362 output_ << " " << name << ":";
363 }
364 return output_;
365 }
366
VisitParallelMove(HParallelMove * instruction)367 void VisitParallelMove(HParallelMove* instruction) override {
368 StartAttributeStream("liveness") << instruction->GetLifetimePosition();
369 StringList moves;
370 for (size_t i = 0, e = instruction->NumMoves(); i < e; ++i) {
371 MoveOperands* move = instruction->MoveOperandsAt(i);
372 std::ostream& str = moves.NewEntryStream();
373 DumpLocation(str, move->GetSource());
374 str << "->";
375 DumpLocation(str, move->GetDestination());
376 }
377 StartAttributeStream("moves") << moves;
378 }
379
VisitParameterValue(HParameterValue * instruction)380 void VisitParameterValue(HParameterValue* instruction) override {
381 StartAttributeStream("is_this") << std::boolalpha << instruction->IsThis() << std::noboolalpha;
382 }
383
VisitIntConstant(HIntConstant * instruction)384 void VisitIntConstant(HIntConstant* instruction) override {
385 StartAttributeStream() << instruction->GetValue();
386 }
387
VisitLongConstant(HLongConstant * instruction)388 void VisitLongConstant(HLongConstant* instruction) override {
389 StartAttributeStream() << instruction->GetValue();
390 }
391
VisitFloatConstant(HFloatConstant * instruction)392 void VisitFloatConstant(HFloatConstant* instruction) override {
393 StartAttributeStream() << instruction->GetValue();
394 }
395
VisitDoubleConstant(HDoubleConstant * instruction)396 void VisitDoubleConstant(HDoubleConstant* instruction) override {
397 StartAttributeStream() << instruction->GetValue();
398 }
399
VisitPhi(HPhi * phi)400 void VisitPhi(HPhi* phi) override {
401 StartAttributeStream("reg") << phi->GetRegNumber();
402 StartAttributeStream("is_catch_phi") << std::boolalpha << phi->IsCatchPhi() << std::noboolalpha;
403 StartAttributeStream("is_live") << std::boolalpha << phi->IsLive() << std::noboolalpha;
404 }
405
VisitMemoryBarrier(HMemoryBarrier * barrier)406 void VisitMemoryBarrier(HMemoryBarrier* barrier) override {
407 StartAttributeStream("kind") << barrier->GetBarrierKind();
408 }
409
VisitMonitorOperation(HMonitorOperation * monitor)410 void VisitMonitorOperation(HMonitorOperation* monitor) override {
411 StartAttributeStream("kind") << (monitor->IsEnter() ? "enter" : "exit");
412 }
413
VisitLoadClass(HLoadClass * load_class)414 void VisitLoadClass(HLoadClass* load_class) override {
415 StartAttributeStream("load_kind") << load_class->GetLoadKind();
416 StartAttributeStream("in_image") << std::boolalpha << load_class->IsInImage();
417 StartAttributeStream("class_name")
418 << load_class->GetDexFile().PrettyType(load_class->GetTypeIndex());
419 StartAttributeStream("gen_clinit_check")
420 << std::boolalpha << load_class->MustGenerateClinitCheck() << std::noboolalpha;
421 StartAttributeStream("needs_access_check") << std::boolalpha
422 << load_class->NeedsAccessCheck() << std::noboolalpha;
423 }
424
VisitLoadMethodHandle(HLoadMethodHandle * load_method_handle)425 void VisitLoadMethodHandle(HLoadMethodHandle* load_method_handle) override {
426 StartAttributeStream("load_kind") << "RuntimeCall";
427 StartAttributeStream("method_handle_index") << load_method_handle->GetMethodHandleIndex();
428 }
429
VisitLoadMethodType(HLoadMethodType * load_method_type)430 void VisitLoadMethodType(HLoadMethodType* load_method_type) override {
431 StartAttributeStream("load_kind") << "RuntimeCall";
432 const DexFile& dex_file = load_method_type->GetDexFile();
433 if (dex_file.NumProtoIds() >= load_method_type->GetProtoIndex().index_) {
434 const dex::ProtoId& proto_id = dex_file.GetProtoId(load_method_type->GetProtoIndex());
435 StartAttributeStream("method_type") << dex_file.GetProtoSignature(proto_id);
436 } else {
437 StartAttributeStream("method_type")
438 << "<<Unknown proto-idx: " << load_method_type->GetProtoIndex() << ">>";
439 }
440 }
441
VisitLoadString(HLoadString * load_string)442 void VisitLoadString(HLoadString* load_string) override {
443 StartAttributeStream("load_kind") << load_string->GetLoadKind();
444 }
445
HandleTypeCheckInstruction(HTypeCheckInstruction * check)446 void HandleTypeCheckInstruction(HTypeCheckInstruction* check) {
447 StartAttributeStream("check_kind") << check->GetTypeCheckKind();
448 StartAttributeStream("must_do_null_check") << std::boolalpha
449 << check->MustDoNullCheck() << std::noboolalpha;
450 if (check->GetTypeCheckKind() == TypeCheckKind::kBitstringCheck) {
451 StartAttributeStream("path_to_root") << std::hex
452 << "0x" << check->GetBitstringPathToRoot() << std::dec;
453 StartAttributeStream("mask") << std::hex << "0x" << check->GetBitstringMask() << std::dec;
454 }
455 }
456
VisitCheckCast(HCheckCast * check_cast)457 void VisitCheckCast(HCheckCast* check_cast) override {
458 HandleTypeCheckInstruction(check_cast);
459 }
460
VisitInstanceOf(HInstanceOf * instance_of)461 void VisitInstanceOf(HInstanceOf* instance_of) override {
462 HandleTypeCheckInstruction(instance_of);
463 }
464
VisitArrayLength(HArrayLength * array_length)465 void VisitArrayLength(HArrayLength* array_length) override {
466 StartAttributeStream("is_string_length") << std::boolalpha
467 << array_length->IsStringLength() << std::noboolalpha;
468 if (array_length->IsEmittedAtUseSite()) {
469 StartAttributeStream("emitted_at_use") << "true";
470 }
471 }
472
VisitBoundsCheck(HBoundsCheck * bounds_check)473 void VisitBoundsCheck(HBoundsCheck* bounds_check) override {
474 StartAttributeStream("is_string_char_at") << std::boolalpha
475 << bounds_check->IsStringCharAt() << std::noboolalpha;
476 }
477
VisitSuspendCheck(HSuspendCheck * suspend_check)478 void VisitSuspendCheck(HSuspendCheck* suspend_check) override {
479 StartAttributeStream("is_no_op")
480 << std::boolalpha << suspend_check->IsNoOp() << std::noboolalpha;
481 }
482
VisitArrayGet(HArrayGet * array_get)483 void VisitArrayGet(HArrayGet* array_get) override {
484 StartAttributeStream("is_string_char_at") << std::boolalpha
485 << array_get->IsStringCharAt() << std::noboolalpha;
486 }
487
VisitArraySet(HArraySet * array_set)488 void VisitArraySet(HArraySet* array_set) override {
489 StartAttributeStream("value_can_be_null")
490 << std::boolalpha << array_set->GetValueCanBeNull() << std::noboolalpha;
491 StartAttributeStream("needs_type_check")
492 << std::boolalpha << array_set->NeedsTypeCheck() << std::noboolalpha;
493 StartAttributeStream("static_type_of_array_is_object_array")
494 << std::boolalpha << array_set->StaticTypeOfArrayIsObjectArray() << std::noboolalpha;
495 StartAttributeStream("can_trigger_gc")
496 << std::boolalpha << array_set->GetSideEffects().Includes(SideEffects::CanTriggerGC())
497 << std::noboolalpha;
498 StartAttributeStream("write_barrier_kind") << array_set->GetWriteBarrierKind();
499 }
500
VisitNewInstance(HNewInstance * new_instance)501 void VisitNewInstance(HNewInstance* new_instance) override {
502 StartAttributeStream("is_finalizable")
503 << std::boolalpha << new_instance->IsFinalizable() << std::noboolalpha;
504 StartAttributeStream("is_partial_materialization")
505 << std::boolalpha << new_instance->IsPartialMaterialization() << std::noboolalpha;
506 }
507
VisitCompare(HCompare * compare)508 void VisitCompare(HCompare* compare) override {
509 StartAttributeStream("bias") << compare->GetBias();
510 StartAttributeStream("comparison_type") << compare->GetComparisonType();
511 }
512
VisitCondition(HCondition * condition)513 void VisitCondition(HCondition* condition) override {
514 StartAttributeStream("bias") << condition->GetBias();
515 }
516
VisitIf(HIf * if_instr)517 void VisitIf(HIf* if_instr) override {
518 StartAttributeStream("true_count") << if_instr->GetTrueCount();
519 StartAttributeStream("false_count") << if_instr->GetFalseCount();
520 }
521
VisitInvoke(HInvoke * invoke)522 void VisitInvoke(HInvoke* invoke) override {
523 StartAttributeStream("dex_file_index") << invoke->GetMethodReference().index;
524 ArtMethod* method = invoke->GetResolvedMethod();
525 // We don't print signatures, which conflict with c1visualizer format.
526 static constexpr bool kWithSignature = false;
527 // Note that we can only use the graph's dex file for the unresolved case. The
528 // other invokes might be coming from inlined methods.
529 ScopedObjectAccess soa(Thread::Current());
530 std::string method_name = (method == nullptr)
531 ? invoke->GetMethodReference().PrettyMethod(kWithSignature)
532 : method->PrettyMethod(kWithSignature);
533 StartAttributeStream("method_name") << method_name;
534 StartAttributeStream("always_throws") << std::boolalpha
535 << invoke->AlwaysThrows()
536 << std::noboolalpha;
537 if (method != nullptr) {
538 StartAttributeStream("method_index") << method->GetMethodIndex();
539 }
540 StartAttributeStream("intrinsic") << invoke->GetIntrinsic();
541 }
542
VisitInvokeUnresolved(HInvokeUnresolved * invoke)543 void VisitInvokeUnresolved(HInvokeUnresolved* invoke) override {
544 VisitInvoke(invoke);
545 StartAttributeStream("invoke_type") << invoke->GetInvokeType();
546 }
547
VisitInvokeStaticOrDirect(HInvokeStaticOrDirect * invoke)548 void VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) override {
549 VisitInvoke(invoke);
550 StartAttributeStream("method_load_kind") << invoke->GetMethodLoadKind();
551 if (invoke->IsStatic()) {
552 StartAttributeStream("clinit_check") << invoke->GetClinitCheckRequirement();
553 }
554 }
555
VisitInvokeVirtual(HInvokeVirtual * invoke)556 void VisitInvokeVirtual(HInvokeVirtual* invoke) override {
557 VisitInvoke(invoke);
558 }
559
VisitInvokePolymorphic(HInvokePolymorphic * invoke)560 void VisitInvokePolymorphic(HInvokePolymorphic* invoke) override {
561 VisitInvoke(invoke);
562 StartAttributeStream("invoke_type") << "InvokePolymorphic";
563 }
564
VisitInstanceFieldGet(HInstanceFieldGet * iget)565 void VisitInstanceFieldGet(HInstanceFieldGet* iget) override {
566 StartAttributeStream("field_name") <<
567 iget->GetFieldInfo().GetDexFile().PrettyField(iget->GetFieldInfo().GetFieldIndex(),
568 /* with type */ false);
569 StartAttributeStream("field_type") << iget->GetFieldType();
570 }
571
VisitInstanceFieldSet(HInstanceFieldSet * iset)572 void VisitInstanceFieldSet(HInstanceFieldSet* iset) override {
573 StartAttributeStream("field_name") <<
574 iset->GetFieldInfo().GetDexFile().PrettyField(iset->GetFieldInfo().GetFieldIndex(),
575 /* with type */ false);
576 StartAttributeStream("field_type") << iset->GetFieldType();
577 StartAttributeStream("write_barrier_kind") << iset->GetWriteBarrierKind();
578 StartAttributeStream("value_can_be_null")
579 << std::boolalpha << iset->GetValueCanBeNull() << std::noboolalpha;
580 }
581
VisitStaticFieldGet(HStaticFieldGet * sget)582 void VisitStaticFieldGet(HStaticFieldGet* sget) override {
583 StartAttributeStream("field_name") <<
584 sget->GetFieldInfo().GetDexFile().PrettyField(sget->GetFieldInfo().GetFieldIndex(),
585 /* with type */ false);
586 StartAttributeStream("field_type") << sget->GetFieldType();
587 }
588
VisitStaticFieldSet(HStaticFieldSet * sset)589 void VisitStaticFieldSet(HStaticFieldSet* sset) override {
590 StartAttributeStream("field_name") <<
591 sset->GetFieldInfo().GetDexFile().PrettyField(sset->GetFieldInfo().GetFieldIndex(),
592 /* with type */ false);
593 StartAttributeStream("field_type") << sset->GetFieldType();
594 StartAttributeStream("write_barrier_kind") << sset->GetWriteBarrierKind();
595 StartAttributeStream("value_can_be_null")
596 << std::boolalpha << sset->GetValueCanBeNull() << std::noboolalpha;
597 }
598
VisitUnresolvedInstanceFieldGet(HUnresolvedInstanceFieldGet * field_access)599 void VisitUnresolvedInstanceFieldGet(HUnresolvedInstanceFieldGet* field_access) override {
600 StartAttributeStream("field_type") << field_access->GetFieldType();
601 }
602
VisitUnresolvedInstanceFieldSet(HUnresolvedInstanceFieldSet * field_access)603 void VisitUnresolvedInstanceFieldSet(HUnresolvedInstanceFieldSet* field_access) override {
604 StartAttributeStream("field_type") << field_access->GetFieldType();
605 }
606
VisitUnresolvedStaticFieldGet(HUnresolvedStaticFieldGet * field_access)607 void VisitUnresolvedStaticFieldGet(HUnresolvedStaticFieldGet* field_access) override {
608 StartAttributeStream("field_type") << field_access->GetFieldType();
609 }
610
VisitUnresolvedStaticFieldSet(HUnresolvedStaticFieldSet * field_access)611 void VisitUnresolvedStaticFieldSet(HUnresolvedStaticFieldSet* field_access) override {
612 StartAttributeStream("field_type") << field_access->GetFieldType();
613 }
614
VisitTryBoundary(HTryBoundary * try_boundary)615 void VisitTryBoundary(HTryBoundary* try_boundary) override {
616 StartAttributeStream("kind") << (try_boundary->IsEntry() ? "entry" : "exit");
617 }
618
VisitGoto(HGoto * instruction)619 void VisitGoto(HGoto* instruction) override {
620 StartAttributeStream("target") << namer_.GetName(instruction->GetBlock()->GetSingleSuccessor());
621 }
622
VisitDeoptimize(HDeoptimize * deoptimize)623 void VisitDeoptimize(HDeoptimize* deoptimize) override {
624 StartAttributeStream("kind") << deoptimize->GetKind();
625 }
626
VisitVecOperation(HVecOperation * vec_operation)627 void VisitVecOperation(HVecOperation* vec_operation) override {
628 StartAttributeStream("packed_type") << vec_operation->GetPackedType();
629 }
630
VisitVecMemoryOperation(HVecMemoryOperation * vec_mem_operation)631 void VisitVecMemoryOperation(HVecMemoryOperation* vec_mem_operation) override {
632 VisitVecOperation(vec_mem_operation);
633 StartAttributeStream("alignment") << vec_mem_operation->GetAlignment().ToString();
634 }
635
VisitVecHalvingAdd(HVecHalvingAdd * hadd)636 void VisitVecHalvingAdd(HVecHalvingAdd* hadd) override {
637 VisitVecBinaryOperation(hadd);
638 StartAttributeStream("rounded") << std::boolalpha << hadd->IsRounded() << std::noboolalpha;
639 }
640
VisitVecMultiplyAccumulate(HVecMultiplyAccumulate * instruction)641 void VisitVecMultiplyAccumulate(HVecMultiplyAccumulate* instruction) override {
642 VisitVecOperation(instruction);
643 StartAttributeStream("kind") << instruction->GetOpKind();
644 }
645
VisitVecDotProd(HVecDotProd * instruction)646 void VisitVecDotProd(HVecDotProd* instruction) override {
647 VisitVecOperation(instruction);
648 DataType::Type arg_type = instruction->InputAt(1)->AsVecOperation()->GetPackedType();
649 StartAttributeStream("type") << (instruction->IsZeroExtending() ?
650 DataType::ToUnsigned(arg_type) :
651 DataType::ToSigned(arg_type));
652 }
653
VisitBitwiseNegatedRight(HBitwiseNegatedRight * instruction)654 void VisitBitwiseNegatedRight(HBitwiseNegatedRight* instruction) override {
655 StartAttributeStream("kind") << instruction->GetOpKind();
656 }
657
658 #if defined(ART_ENABLE_CODEGEN_arm) || defined(ART_ENABLE_CODEGEN_arm64)
VisitMultiplyAccumulate(HMultiplyAccumulate * instruction)659 void VisitMultiplyAccumulate(HMultiplyAccumulate* instruction) override {
660 StartAttributeStream("kind") << instruction->GetOpKind();
661 }
662
VisitDataProcWithShifterOp(HDataProcWithShifterOp * instruction)663 void VisitDataProcWithShifterOp(HDataProcWithShifterOp* instruction) override {
664 StartAttributeStream("kind") << instruction->GetInstrKind() << "+" << instruction->GetOpKind();
665 if (HDataProcWithShifterOp::IsShiftOp(instruction->GetOpKind())) {
666 StartAttributeStream("shift") << instruction->GetShiftAmount();
667 }
668 }
669 #endif
670
671 #if defined(ART_ENABLE_CODEGEN_riscv64)
VisitRiscv64ShiftAdd(HRiscv64ShiftAdd * instruction)672 void VisitRiscv64ShiftAdd(HRiscv64ShiftAdd* instruction) override {
673 StartAttributeStream("distance") << instruction->GetDistance();
674 }
675 #endif
676
IsPass(const char * name)677 bool IsPass(const char* name) {
678 return strcmp(pass_name_, name) == 0;
679 }
680
IsDebugDump()681 bool IsDebugDump() {
682 return IsPass(kDebugDumpGraphName) || IsPass(kDebugDumpName);
683 }
684
PrintInstruction(HInstruction * instruction)685 void PrintInstruction(HInstruction* instruction) {
686 output_ << instruction->DebugName();
687 HConstInputsRef inputs = instruction->GetInputs();
688 if (!inputs.empty()) {
689 StringList input_list;
690 for (const HInstruction* input : inputs) {
691 input_list.NewEntryStream() << DataType::TypeId(input->GetType()) << input->GetId();
692 }
693 StartAttributeStream() << input_list;
694 }
695 if (instruction->GetDexPc() != kNoDexPc) {
696 StartAttributeStream("dex_pc") << instruction->GetDexPc();
697 } else {
698 StartAttributeStream("dex_pc") << "n/a";
699 }
700 HBasicBlock* block = instruction->GetBlock();
701 StartAttributeStream("block") << namer_.GetName(block);
702
703 instruction->Accept(this);
704 if (instruction->HasEnvironment()) {
705 StringList envs;
706 for (HEnvironment* environment = instruction->GetEnvironment();
707 environment != nullptr;
708 environment = environment->GetParent()) {
709 StringList vregs;
710 for (size_t i = 0, e = environment->Size(); i < e; ++i) {
711 HInstruction* insn = environment->GetInstructionAt(i);
712 if (insn != nullptr) {
713 vregs.NewEntryStream() << DataType::TypeId(insn->GetType()) << insn->GetId();
714 } else {
715 vregs.NewEntryStream() << "_";
716 }
717 }
718 envs.NewEntryStream() << vregs;
719 }
720 StartAttributeStream("env") << envs;
721 }
722 if (IsPass(SsaLivenessAnalysis::kLivenessPassName)
723 && is_after_pass_
724 && instruction->GetLifetimePosition() != kNoLifetime) {
725 StartAttributeStream("liveness") << instruction->GetLifetimePosition();
726 if (instruction->HasLiveInterval()) {
727 LiveInterval* interval = instruction->GetLiveInterval();
728 StartAttributeStream("ranges")
729 << StringList(interval->GetFirstRange(), StringList::kSetBrackets);
730 StartAttributeStream("uses") << StringList(interval->GetUses());
731 StartAttributeStream("env_uses") << StringList(interval->GetEnvironmentUses());
732 StartAttributeStream("is_fixed") << interval->IsFixed();
733 StartAttributeStream("is_split") << interval->IsSplit();
734 StartAttributeStream("is_low") << interval->IsLowInterval();
735 StartAttributeStream("is_high") << interval->IsHighInterval();
736 }
737 }
738
739 if (IsPass(RegisterAllocator::kRegisterAllocatorPassName) && is_after_pass_) {
740 StartAttributeStream("liveness") << instruction->GetLifetimePosition();
741 LocationSummary* locations = instruction->GetLocations();
742 if (locations != nullptr) {
743 StringList input_list;
744 for (size_t i = 0, e = locations->GetInputCount(); i < e; ++i) {
745 DumpLocation(input_list.NewEntryStream(), locations->InAt(i));
746 }
747 std::ostream& attr = StartAttributeStream("locations");
748 attr << input_list << "->";
749 DumpLocation(attr, locations->Out());
750 }
751 }
752
753 HLoopInformation* loop_info = (block != nullptr) ? block->GetLoopInformation() : nullptr;
754 if (loop_info == nullptr) {
755 StartAttributeStream("loop") << "none";
756 } else {
757 StartAttributeStream("loop") << namer_.GetName(loop_info->GetHeader());
758 HLoopInformation* outer = loop_info->GetPreHeader()->GetLoopInformation();
759 if (outer != nullptr) {
760 StartAttributeStream("outer_loop") << namer_.GetName(outer->GetHeader());
761 } else {
762 StartAttributeStream("outer_loop") << "none";
763 }
764 StartAttributeStream("irreducible")
765 << std::boolalpha << loop_info->IsIrreducible() << std::noboolalpha;
766 }
767
768 // For the builder and the inliner, we want to add extra information on HInstructions
769 // that have reference types, and also HInstanceOf/HCheckcast.
770 if ((IsPass(HGraphBuilder::kBuilderPassName)
771 || IsPass(HInliner::kInlinerPassName)
772 || IsDebugDump())
773 && (instruction->GetType() == DataType::Type::kReference ||
774 instruction->IsInstanceOf() ||
775 instruction->IsCheckCast())) {
776 ReferenceTypeInfo info = (instruction->GetType() == DataType::Type::kReference)
777 ? instruction->IsLoadClass()
778 ? instruction->AsLoadClass()->GetLoadedClassRTI()
779 : instruction->GetReferenceTypeInfo()
780 : instruction->IsInstanceOf()
781 ? instruction->AsInstanceOf()->GetTargetClassRTI()
782 : instruction->AsCheckCast()->GetTargetClassRTI();
783 ScopedObjectAccess soa(Thread::Current());
784 if (info.IsValid()) {
785 StartAttributeStream("klass")
786 << mirror::Class::PrettyDescriptor(info.GetTypeHandle().Get());
787 if (instruction->GetType() == DataType::Type::kReference) {
788 StartAttributeStream("can_be_null")
789 << std::boolalpha << instruction->CanBeNull() << std::noboolalpha;
790 }
791 StartAttributeStream("exact") << std::boolalpha << info.IsExact() << std::noboolalpha;
792 } else if (instruction->IsLoadClass() ||
793 instruction->IsInstanceOf() ||
794 instruction->IsCheckCast()) {
795 StartAttributeStream("klass") << "unresolved";
796 } else {
797 StartAttributeStream("klass") << "invalid";
798 }
799 }
800 if (disasm_info_ != nullptr) {
801 DCHECK(disassembler_ != nullptr);
802 // If the information is available, disassemble the code generated for
803 // this instruction.
804 auto it = disasm_info_->GetInstructionIntervals().find(instruction);
805 if (it != disasm_info_->GetInstructionIntervals().end()
806 && it->second.start != it->second.end) {
807 output_ << "\n";
808 disassembler_->Disassemble(output_, it->second.start, it->second.end);
809 }
810 }
811 }
812
PrintInstructions(const HInstructionList & list)813 void PrintInstructions(const HInstructionList& list) {
814 for (HInstructionIterator it(list); !it.Done(); it.Advance()) {
815 HInstruction* instruction = it.Current();
816 int bci = 0;
817 size_t num_uses = instruction->GetUses().SizeSlow();
818 AddIndent();
819 output_ << bci << " " << num_uses << " "
820 << DataType::TypeId(instruction->GetType()) << instruction->GetId() << " ";
821 PrintInstruction(instruction);
822 output_ << " " << kEndInstructionMarker << "\n";
823 }
824 }
825
DumpStartOfDisassemblyBlock(const char * block_name,int predecessor_index,int successor_index)826 void DumpStartOfDisassemblyBlock(const char* block_name,
827 int predecessor_index,
828 int successor_index) {
829 StartTag("block");
830 PrintProperty("name", block_name);
831 PrintInt("from_bci", -1);
832 PrintInt("to_bci", -1);
833 if (predecessor_index != -1) {
834 PrintProperty("predecessors", "B", predecessor_index);
835 } else {
836 PrintEmptyProperty("predecessors");
837 }
838 if (successor_index != -1) {
839 PrintProperty("successors", "B", successor_index);
840 } else {
841 PrintEmptyProperty("successors");
842 }
843 PrintEmptyProperty("xhandlers");
844 PrintEmptyProperty("flags");
845 StartTag("states");
846 StartTag("locals");
847 PrintInt("size", 0);
848 PrintProperty("method", "None");
849 EndTag("locals");
850 EndTag("states");
851 StartTag("HIR");
852 }
853
DumpEndOfDisassemblyBlock()854 void DumpEndOfDisassemblyBlock() {
855 EndTag("HIR");
856 EndTag("block");
857 }
858
DumpDisassemblyBlockForFrameEntry()859 void DumpDisassemblyBlockForFrameEntry() {
860 DumpStartOfDisassemblyBlock(kDisassemblyBlockFrameEntry,
861 -1,
862 GetGraph()->GetEntryBlock()->GetBlockId());
863 output_ << " 0 0 disasm " << kDisassemblyBlockFrameEntry << " ";
864 GeneratedCodeInterval frame_entry = disasm_info_->GetFrameEntryInterval();
865 if (frame_entry.start != frame_entry.end) {
866 output_ << "\n";
867 disassembler_->Disassemble(output_, frame_entry.start, frame_entry.end);
868 }
869 output_ << kEndInstructionMarker << "\n";
870 DumpEndOfDisassemblyBlock();
871 }
872
DumpDisassemblyBlockForSlowPaths()873 void DumpDisassemblyBlockForSlowPaths() {
874 if (disasm_info_->GetSlowPathIntervals().empty()) {
875 return;
876 }
877 // If the graph has an exit block we attach the block for the slow paths
878 // after it. Else we just add the block to the graph without linking it to
879 // any other.
880 DumpStartOfDisassemblyBlock(
881 kDisassemblyBlockSlowPaths,
882 GetGraph()->HasExitBlock() ? GetGraph()->GetExitBlock()->GetBlockId() : -1,
883 -1);
884 for (SlowPathCodeInfo info : disasm_info_->GetSlowPathIntervals()) {
885 output_ << " 0 0 disasm " << info.slow_path->GetDescription() << "\n";
886 disassembler_->Disassemble(output_, info.code_interval.start, info.code_interval.end);
887 output_ << kEndInstructionMarker << "\n";
888 }
889 DumpEndOfDisassemblyBlock();
890 }
891
Run()892 void Run() {
893 StartTag("cfg");
894 std::ostringstream oss;
895 oss << pass_name_;
896 if (!IsDebugDump()) {
897 oss << " (" << (GetGraph()->IsCompilingBaseline() ? "baseline " : "")
898 << (is_after_pass_ ? "after" : "before")
899 << (graph_in_bad_state_ ? ", bad_state" : "") << ")";
900 }
901 PrintProperty("name", oss.str().c_str());
902 if (disasm_info_ != nullptr) {
903 DumpDisassemblyBlockForFrameEntry();
904 }
905 VisitInsertionOrder();
906 if (disasm_info_ != nullptr) {
907 DumpDisassemblyBlockForSlowPaths();
908 }
909 EndTag("cfg");
910 Flush();
911 }
912
Run(HInstruction * instruction)913 void Run(HInstruction* instruction) {
914 output_ << DataType::TypeId(instruction->GetType()) << instruction->GetId() << " ";
915 PrintInstruction(instruction);
916 Flush();
917 }
918
VisitBasicBlock(HBasicBlock * block)919 void VisitBasicBlock(HBasicBlock* block) override {
920 StartTag("block");
921 PrintProperty("name", block);
922 if (block->GetLifetimeStart() != kNoLifetime) {
923 // Piggy back on these fields to show the lifetime of the block.
924 PrintInt("from_bci", block->GetLifetimeStart());
925 PrintInt("to_bci", block->GetLifetimeEnd());
926 } else if (!IsDebugDump()) {
927 // Don't print useless information to logcat.
928 PrintInt("from_bci", -1);
929 PrintInt("to_bci", -1);
930 }
931 PrintPredecessors(block);
932 PrintSuccessors(block);
933 PrintExceptionHandlers(block);
934
935 if (block->IsCatchBlock()) {
936 PrintProperty("flags", "catch_block");
937 } else if (block->IsTryBlock()) {
938 std::stringstream flags_properties;
939 flags_properties << "try_start "
940 << namer_.GetName(block->GetTryCatchInformation()->GetTryEntry().GetBlock());
941 PrintProperty("flags", flags_properties.str().c_str());
942 } else if (!IsDebugDump()) {
943 // Don't print useless information to logcat
944 PrintEmptyProperty("flags");
945 }
946
947 if (block->GetDominator() != nullptr) {
948 PrintProperty("dominator", block->GetDominator());
949 }
950
951 if (!IsDebugDump() || !block->GetPhis().IsEmpty()) {
952 StartTag("states");
953 StartTag("locals");
954 PrintInt("size", 0);
955 PrintProperty("method", "None");
956 for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
957 AddIndent();
958 HInstruction* instruction = it.Current();
959 output_ << instruction->GetId() << " " << DataType::TypeId(instruction->GetType())
960 << instruction->GetId() << "[ ";
961 for (const HInstruction* input : instruction->GetInputs()) {
962 output_ << input->GetId() << " ";
963 }
964 output_ << "]\n";
965 }
966 EndTag("locals");
967 EndTag("states");
968 }
969
970 StartTag("HIR");
971 PrintInstructions(block->GetPhis());
972 PrintInstructions(block->GetInstructions());
973 EndTag("HIR");
974 EndTag("block");
975 }
976
977 static constexpr const char* const kEndInstructionMarker = "<|@";
978 static constexpr const char* const kDisassemblyBlockFrameEntry = "FrameEntry";
979 static constexpr const char* const kDisassemblyBlockSlowPaths = "SlowPaths";
980
981 private:
982 std::ostream& output_;
983 const char* pass_name_;
984 const bool is_after_pass_;
985 const bool graph_in_bad_state_;
986 const CodeGenerator* codegen_;
987 const DisassemblyInformation* disasm_info_;
988 const BlockNamer& namer_;
989 std::unique_ptr<HGraphVisualizerDisassembler> disassembler_;
990 size_t indent_;
991
992 DISALLOW_COPY_AND_ASSIGN(HGraphVisualizerPrinter);
993 };
994
PrintName(std::ostream & os,HBasicBlock * blk) const995 std::ostream& HGraphVisualizer::OptionalDefaultNamer::PrintName(std::ostream& os,
996 HBasicBlock* blk) const {
997 if (namer_) {
998 return namer_->get().PrintName(os, blk);
999 } else {
1000 return BlockNamer::PrintName(os, blk);
1001 }
1002 }
1003
HGraphVisualizer(std::ostream * output,HGraph * graph,const CodeGenerator * codegen,std::optional<std::reference_wrapper<const BlockNamer>> namer)1004 HGraphVisualizer::HGraphVisualizer(std::ostream* output,
1005 HGraph* graph,
1006 const CodeGenerator* codegen,
1007 std::optional<std::reference_wrapper<const BlockNamer>> namer)
1008 : output_(output), graph_(graph), codegen_(codegen), namer_(namer) {}
1009
PrintHeader(const char * method_name) const1010 void HGraphVisualizer::PrintHeader(const char* method_name) const {
1011 DCHECK(output_ != nullptr);
1012 HGraphVisualizerPrinter printer(graph_, *output_, "", true, false, codegen_, namer_);
1013 printer.StartTag("compilation");
1014 printer.PrintProperty("name", method_name);
1015 printer.PrintProperty("method", method_name);
1016 printer.PrintTime("date");
1017 printer.EndTag("compilation");
1018 printer.Flush();
1019 }
1020
InsertMetaDataAsCompilationBlock(const std::string & meta_data)1021 std::string HGraphVisualizer::InsertMetaDataAsCompilationBlock(const std::string& meta_data) {
1022 std::string time_str = std::to_string(time(nullptr));
1023 std::string quoted_meta_data = "\"" + meta_data + "\"";
1024 return StringPrintf("begin_compilation\n"
1025 " name %s\n"
1026 " method %s\n"
1027 " date %s\n"
1028 "end_compilation\n",
1029 quoted_meta_data.c_str(),
1030 quoted_meta_data.c_str(),
1031 time_str.c_str());
1032 }
1033
DumpGraphDebug() const1034 void HGraphVisualizer::DumpGraphDebug() const {
1035 DumpGraph(/* pass_name= */ kDebugDumpGraphName,
1036 /* is_after_pass= */ false,
1037 /* graph_in_bad_state= */ true);
1038 }
1039
DumpGraph(const char * pass_name,bool is_after_pass,bool graph_in_bad_state) const1040 void HGraphVisualizer::DumpGraph(const char* pass_name,
1041 bool is_after_pass,
1042 bool graph_in_bad_state) const {
1043 DCHECK(output_ != nullptr);
1044 if (!graph_->GetBlocks().empty()) {
1045 HGraphVisualizerPrinter printer(graph_,
1046 *output_,
1047 pass_name,
1048 is_after_pass,
1049 graph_in_bad_state,
1050 codegen_,
1051 namer_);
1052 printer.Run();
1053 }
1054 }
1055
DumpGraphWithDisassembly() const1056 void HGraphVisualizer::DumpGraphWithDisassembly() const {
1057 DCHECK(output_ != nullptr);
1058 if (!graph_->GetBlocks().empty()) {
1059 HGraphVisualizerPrinter printer(graph_,
1060 *output_,
1061 "disassembly",
1062 /* is_after_pass= */ true,
1063 /* graph_in_bad_state= */ false,
1064 codegen_,
1065 namer_,
1066 codegen_->GetDisassemblyInformation());
1067 printer.Run();
1068 }
1069 }
1070
DumpInstruction(std::ostream * output,HGraph * graph,HInstruction * instruction)1071 void HGraphVisualizer::DumpInstruction(std::ostream* output,
1072 HGraph* graph,
1073 HInstruction* instruction) {
1074 BlockNamer namer;
1075 HGraphVisualizerPrinter printer(graph,
1076 *output,
1077 /* pass_name= */ kDebugDumpName,
1078 /* is_after_pass= */ false,
1079 /* graph_in_bad_state= */ false,
1080 /* codegen= */ nullptr,
1081 /* namer= */ namer);
1082 printer.Run(instruction);
1083 }
1084
1085 } // namespace art
1086