[llvm-commits] [llvm] r112830 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h include/llvm/MC/MCAsmInfo.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/MC/MCAsmInfo.cpp lib/MC/MCAsmInfoDarwin.cpp

Chris Lattner clattner at apple.com
Thu Sep 2 10:02:30 PDT 2010


On Sep 2, 2010, at 9:43 AM, Devang Patel wrote:

> Author: dpatel
> Date: Thu Sep  2 11:43:44 2010
> New Revision: 112830
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=112830&view=rev
> Log:
> Fix .debug_range for linux. Patch by Krister Wombell.

Thanks Devang,

FWIW, I don't think it ever makes sense to use .set here.  You can't get an absolute number with LFoo+42, only LFoo-LBar

-Chris

> 
> Modified:
>    llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
>    llvm/trunk/include/llvm/MC/MCAsmInfo.h
>    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>    llvm/trunk/lib/MC/MCAsmInfo.cpp
>    llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
> 
> Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=112830&r1=112829&r2=112830&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Thu Sep  2 11:43:44 2010
> @@ -328,6 +328,12 @@
>     void EmitLabelOffsetDifference(const MCSymbol *Hi, uint64_t Offset,
>                                    const MCSymbol *Lo, unsigned Size) const;
> 
> +    /// EmitLabelPlusOffset - Emit something like ".long Label+Offset"
> +    /// where the size in bytes of the directive is specified by Size and Label
> +    /// specifies the label.  This implicitly uses .set if it is available.
> +    void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
> +                                   unsigned Size) const;
> +
>     //===------------------------------------------------------------------===//
>     // Dwarf Emission Helper Routines
>     //===------------------------------------------------------------------===//
> 
> Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=112830&r1=112829&r2=112830&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original)
> +++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Thu Sep  2 11:43:44 2010
> @@ -259,6 +259,10 @@
>     /// absolute label instead of offset.
>     bool DwarfUsesAbsoluteLabelForStmtList;  // Defaults to true;
> 
> +    // DwarfUsesLabelOffsetDifference - True if Dwarf2 output can
> +    // use EmitLabelOffsetDifference.
> +    bool DwarfUsesLabelOffsetForRanges;
> +
>     //===--- CBE Asm Translation Table -----------------------------------===//
> 
>     const char *const *AsmTransCBE;          // Defaults to empty
> @@ -424,6 +428,9 @@
>     bool doesDwarfUsesAbsoluteLabelForStmtList() const {
>       return DwarfUsesAbsoluteLabelForStmtList;
>     }
> +    bool doesDwarfUsesLabelOffsetForRanges() const {
> +      return DwarfUsesLabelOffsetForRanges;
> +    }
>     const char *const *getAsmCBE() const {
>       return AsmTransCBE;
>     }
> 
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=112830&r1=112829&r2=112830&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Sep  2 11:43:44 2010
> @@ -1218,6 +1218,29 @@
>     OutStreamer.EmitSymbolValue(SetLabel, 4, 0/*AddrSpace*/);
>   }
> }
> +
> +/// EmitLabelPlusOffset - Emit something like ".long Label+Offset" 
> +/// where the size in bytes of the directive is specified by Size and Label
> +/// specifies the label.  This implicitly uses .set if it is available.
> +void AsmPrinter::EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
> +                                      unsigned Size) 
> +  const {
> +  
> +  // Emit Label+Offset
> +  const MCExpr *Plus =
> +    MCBinaryExpr::CreateAdd(MCSymbolRefExpr::Create(Label, OutContext), 
> +                            MCConstantExpr::Create(Offset, OutContext),
> +                            OutContext);
> +  
> +  if (!MAI->hasSetDirective()) 
> +    OutStreamer.EmitValue(Plus, 4, 0/*AddrSpace*/);
> +  else {
> +    // Otherwise, emit with .set (aka assignment).
> +    MCSymbol *SetLabel = GetTempSymbol("set", SetCounter++);
> +    OutStreamer.EmitAssignment(SetLabel, Plus);
> +    OutStreamer.EmitSymbolValue(SetLabel, 4, 0/*AddrSpace*/);
> +  }
> +}
> 
> 
> //===----------------------------------------------------------------------===//
> 
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=112830&r1=112829&r2=112830&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Sep  2 11:43:44 2010
> @@ -3130,10 +3130,17 @@
>     case dwarf::DW_AT_ranges: {
>       // DW_AT_range Value encodes offset in debug_range section.
>       DIEInteger *V = cast<DIEInteger>(Values[i]);
> -      Asm->EmitLabelOffsetDifference(DwarfDebugRangeSectionSym,
> -                                     V->getValue(),
> -                                     DwarfDebugRangeSectionSym,
> -                                     4);
> +
> +      if (Asm->MAI->doesDwarfUsesLabelOffsetForRanges()) {
> +        Asm->EmitLabelPlusOffset(DwarfDebugRangeSectionSym,
> +                                 V->getValue(),
> +                                 4);
> +      } else {
> +        Asm->EmitLabelOffsetDifference(DwarfDebugRangeSectionSym,
> +                                       V->getValue(),
> +                                       DwarfDebugRangeSectionSym,
> +                                       4);
> +      }
>       break;
>     }
>     case dwarf::DW_AT_location: {
> 
> Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=112830&r1=112829&r2=112830&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original)
> +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Thu Sep  2 11:43:44 2010
> @@ -70,6 +70,7 @@
>   DwarfUsesInlineInfoSection = false;
>   DwarfUsesAbsoluteLabelForStmtList = true;
>   DwarfSectionOffsetDirective = 0;
> +  DwarfUsesLabelOffsetForRanges = true;
>   HasMicrosoftFastStdCallMangling = false;
> 
>   AsmTransCBE = 0;
> 
> Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=112830&r1=112829&r2=112830&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original)
> +++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Thu Sep  2 11:43:44 2010
> @@ -46,5 +46,6 @@
>   HasNoDeadStrip = true;
> 
>   DwarfUsesAbsoluteLabelForStmtList = false;
> +  DwarfUsesLabelOffsetForRanges = false;
> }
> 
> 
> 
> _______________________________________________
> 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