[llvm] r238457 - [Objdump] Allow instruction pretty printing to be specialized by the target triple.

Hans Wennborg hans at chromium.org
Thu May 28 14:25:51 PDT 2015


Thanks!

On Thu, May 28, 2015 at 2:03 PM, Colin LeMahieu <colinl at codeaurora.org> wrote:
> My apologies, I just committed this fix.
>
> -----Original Message-----
> From: hwennborg at google.com [mailto:hwennborg at google.com] On Behalf Of Hans Wennborg
> Sent: Thursday, May 28, 2015 4:00 PM
> To: Colin LeMahieu
> Cc: Rafael EspĂ­ndola; llvm-commits
> Subject: Re: [llvm] r238457 - [Objdump] Allow instruction pretty printing to be specialized by the target triple.
>
> On Thu, May 28, 2015 at 1:39 PM, Colin LeMahieu <colinl at codeaurora.org> wrote:
>> I'll add the virtual destructor.
>
> Please expedite this if possible; it's breaking my builds.
>
>
>> -----Original Message-----
>> From: Rafael EspĂ­ndola [mailto:rafael.espindola at gmail.com]
>> Sent: Thursday, May 28, 2015 3:28 PM
>> To: Colin LeMahieu
>> Cc: llvm-commits
>> Subject: Re: [llvm] r238457 - [Objdump] Allow instruction pretty printing to be specialized by the target triple.
>>
>> /home/espindola/llvm/llvm/tools/llvm-objdump/llvm-objdump.cpp:205:7:
>> warning: '(anonymous namespace)::PrettyPrinter' has virtual functions but non-virtual destructor [-Wnon-virtual-dtor] class PrettyPrinter {
>>       ^
>> 1 warning generated.
>>
>> Also, this class is just a function pointer, no?
>>
>>
>> On 28 May 2015 at 15:07, Colin LeMahieu <colinl at codeaurora.org> wrote:
>>> Author: colinl
>>> Date: Thu May 28 14:07:14 2015
>>> New Revision: 238457
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=238457&view=rev
>>> Log:
>>> [Objdump] Allow instruction pretty printing to be specialized by the target triple.
>>>
>>> Differential Revision: http://reviews.llvm.org/D8427
>>>
>>> Modified:
>>>     llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
>>>
>>> Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llv
>>> m -objdump.cpp?rev=238457&r1=238456&r2=238457&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
>>> +++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Thu May 28
>>> +++ 14:07:14
>>> +++ 2015
>>> @@ -201,6 +201,30 @@ bool llvm::RelocAddressLess(RelocationRe
>>>    return a_addr < b_addr;
>>>  }
>>>
>>> +namespace {
>>> +class PrettyPrinter {
>>> +public:
>>> +  virtual void printInst(MCInstPrinter &IP, const MCInst *MI, bool ShowRawInsn,
>>> +                         ArrayRef<uint8_t> Bytes, uint64_t Address,
>>> +                         raw_ostream &OS, StringRef Annot,
>>> +                         MCSubtargetInfo const &STI) {
>>> +    outs() << format("%8" PRIx64 ":", Address);
>>> +    if (!NoShowRawInsn) {
>>> +      outs() << "\t";
>>> +      dumpBytes(Bytes, outs());
>>> +    }
>>> +    IP.printInst(MI, outs(), "", STI);
>>> +  }
>>> +};
>>> +PrettyPrinter PrettyPrinterInst;
>>> +PrettyPrinter &selectPrettyPrinter(Triple const &Triple,
>>> +MCInstPrinter &IP) {
>>> +  switch(Triple.getArch()) {
>>> +  default:
>>> +    return PrettyPrinterInst;
>>> +  }
>>> +}
>>> +}
>>> +
>>>  static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
>>>    const Target *TheTarget = getTarget(Obj);
>>>    // getTarget() will have already issued a diagnostic if necessary,
>>> so @@ -267,6 +291,7 @@ static void DisassembleObject(const Obje
>>>        << '\n';
>>>      return;
>>>    }
>>> +  PrettyPrinter &PIP = selectPrettyPrinter(Triple(TripleName), *IP);
>>>
>>>    StringRef Fmt = Obj->getBytesInAddress() > 4 ? "\t\t%016" PRIx64 ":  " :
>>>                                                   "\t\t\t%08" PRIx64
>>> ":  "; @@ -383,12 +408,9 @@ static void DisassembleObject(const Obje
>>>          if (DisAsm->getInstruction(Inst, Size, Bytes.slice(Index),
>>>                                     SectionAddr + Index, DebugOut,
>>>                                     CommentStream)) {
>>> -          outs() << format("%8" PRIx64 ":", SectionAddr + Index);
>>> -          if (!NoShowRawInsn) {
>>> -            outs() << "\t";
>>> -            dumpBytes(ArrayRef<uint8_t>(Bytes.data() + Index, Size), outs());
>>> -          }
>>> -          IP->printInst(&Inst, outs(), "", *STI);
>>> +          PIP.printInst(*IP, &Inst, !NoShowRawInsn,
>>> +                        Bytes.slice(Index, Size),
>>> +                        SectionAddr + Index, outs(), "", *STI);
>>>            outs() << CommentStream.str();
>>>            Comments.clear();
>>>            outs() << "\n";
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list