[llvm-commits] [llvm] r130375 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/MC/MCDwarf.cpp

Daniel Dunbar daniel at zuster.org
Tue May 3 14:41:27 PDT 2011


Hi Rafael,

On Wed, Apr 27, 2011 at 7:46 PM, Rafael Espindola
<rafael.espindola at gmail.com> wrote:
> Author: rafael
> Date: Wed Apr 27 21:46:42 2011
> New Revision: 130375
>
> URL: http://llvm.org/viewvc/llvm-project?rev=130375&view=rev
> Log:
> Forward isFunctionEHFrameSymbolPrivate. If it is false, produce the foo.eh
> symbols.
>
> Modified:
>    llvm/trunk/include/llvm/Target/TargetAsmInfo.h
>    llvm/trunk/lib/MC/MCDwarf.cpp
>
> Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=130375&r1=130374&r2=130375&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Wed Apr 27 21:46:42 2011
> @@ -62,6 +62,10 @@
>     return TLOF->getFDEEncoding();
>   }
>
> +  bool isFunctionEHFrameSymbolPrivate() const {
> +    return TLOF->isFunctionEHFrameSymbolPrivate();
> +  }
> +
>   unsigned getDwarfRARegNum(bool isEH) const {
>     return TRI->getDwarfRegNum(TRI->getRARegister(), isEH);
>   }
>
> Modified: llvm/trunk/lib/MC/MCDwarf.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130375&r1=130374&r2=130375&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCDwarf.cpp (original)
> +++ llvm/trunk/lib/MC/MCDwarf.cpp Wed Apr 27 21:46:42 2011
> @@ -17,6 +17,7 @@
>  #include "llvm/MC/MCContext.h"
>  #include "llvm/MC/MCObjectWriter.h"
>  #include "llvm/ADT/SmallString.h"
> +#include "llvm/ADT/Twine.h"
>  #include "llvm/Support/Debug.h"
>  #include "llvm/Support/ErrorHandling.h"
>  #include "llvm/Support/raw_ostream.h"
> @@ -713,6 +714,12 @@
>   MCSymbol *fdeEnd = context.CreateTempSymbol();
>   const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
>
> +  if (!asmInfo.isFunctionEHFrameSymbolPrivate()) {
> +    Twine EHName = frame.Function->getName() + Twine(".eh");
> +    MCSymbol *EHSym = context.GetOrCreateSymbol(EHName);
> +    streamer.EmitLabel(EHSym);

Note that this use of Twine is not safe (I fixed in r130793). You can
almost never safely store local variables of Twine type.

>From Twine.h:
--
  /// A Twine is not intended for use directly and should not be stored, its
  /// implementation relies on the ability to store pointers to temporary stack
  /// objects which may be deallocated at the end of a statement. Twines should
  /// only be used accepted as const references in arguments, when an API wishes
  /// to accept possibly-concatenated strings.
--

 - Daniel

> +  }
> +
>   // Length
>   const MCExpr *Length = MakeStartMinusEndExpr(streamer, *fdeStart, *fdeEnd, 0);
>   streamer.EmitAbsValue(Length, 4);
>
>
> _______________________________________________
> 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