@@ -138,9 +138,16 @@ static size_t getNumDisplayWidth(size_t N) {
138138 return L;
139139}
140140
141- LLVM_DUMP_METHOD void Function::dump () const { dump (llvm::errs ()); }
141+ LLVM_DUMP_METHOD void Function::dump (CodePtr PC) const {
142+ dump (llvm::errs (), PC);
143+ }
142144
143- LLVM_DUMP_METHOD void Function::dump (llvm::raw_ostream &OS) const {
145+ LLVM_DUMP_METHOD void Function::dump (llvm::raw_ostream &OS,
146+ CodePtr OpPC) const {
147+ if (OpPC) {
148+ assert (OpPC >= getCodeBegin ());
149+ assert (OpPC <= getCodeEnd ());
150+ }
144151 {
145152 ColorScope SC (OS, true , {llvm::raw_ostream::BRIGHT_GREEN, true });
146153 OS << getName () << " " << (const void *)this << " \n " ;
@@ -154,6 +161,7 @@ LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {
154161 size_t Addr;
155162 std::string Op;
156163 bool IsJump;
164+ bool CurrentOp = false ;
157165 llvm::SmallVector<std::string> Args;
158166 };
159167
@@ -171,6 +179,7 @@ LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {
171179 auto Op = PC.read <Opcode>();
172180 Text.Addr = Addr;
173181 Text.IsJump = isJumpOpcode (Op);
182+ Text.CurrentOp = (PC == OpPC);
174183 switch (Op) {
175184#define GET_DISASM
176185#include " Opcodes.inc"
@@ -198,9 +207,15 @@ LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {
198207 Text.reserve (Code.size ());
199208 size_t LongestLine = 0 ;
200209 // Print code to a string, one at a time.
201- for (auto C : Code) {
210+ for (const auto & C : Code) {
202211 std::string Line;
203212 llvm::raw_string_ostream LS (Line);
213+ if (OpPC) {
214+ if (C.CurrentOp )
215+ LS << " * " ;
216+ else
217+ LS << " " ;
218+ }
204219 LS << C.Addr ;
205220 LS.indent (LongestAddr - getNumDisplayWidth (C.Addr ) + 4 );
206221 LS << C.Op ;
0 commit comments