<div dir="ltr">Yep: <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/3640/steps/check-llvm%20asan/logs/stdio">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/3640/steps/check-llvm%20asan/logs/stdio</a></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 10, 2014 at 12:00 PM, Alexander Potapenko <span dir="ltr"><<a href="mailto:glider@google.com" target="_blank">glider@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Eric,<br>
<br>
Looks like you're forgetting to free JITInfo in ~X86Subtarget().<br>
<div class="HOEnZb"><div class="h5"><br>
On Mon, Jun 9, 2014 at 9:08 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br>
> Author: echristo<br>
> Date: Mon Jun  9 12:08:19 2014<br>
> New Revision: 210479<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=210479&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=210479&view=rev</a><br>
> Log:<br>
> Move all of the x86 subtarget initialized variables down into the x86 subtarget<br>
> from the x86 target machine. Should be no functional change.<br>
><br>
> Modified:<br>
>     llvm/trunk/lib/Target/X86/X86ISelLowering.cpp<br>
>     llvm/trunk/lib/Target/X86/X86ISelLowering.h<br>
>     llvm/trunk/lib/Target/X86/X86JITInfo.h<br>
>     llvm/trunk/lib/Target/X86/X86Subtarget.cpp<br>
>     llvm/trunk/lib/Target/X86/X86Subtarget.h<br>
>     llvm/trunk/lib/Target/X86/X86TargetMachine.cpp<br>
>     llvm/trunk/lib/Target/X86/X86TargetMachine.h<br>
><br>
> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=210479&r1=210478&r2=210479&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=210479&r1=210478&r2=210479&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)<br>
> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Jun  9 12:08:19 2014<br>
> @@ -21606,3 +21606,7 @@ int X86TargetLowering::getScalingFactorC<br>
>      return AM.Scale != 0;<br>
>    return -1;<br>
>  }<br>
> +<br>
> +bool X86TargetLowering::isTargetFTOL() const {<br>
> +  return Subtarget->isTargetKnownWindowsMSVC() && !Subtarget->is64Bit();<br>
> +}<br>
><br>
> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=210479&r1=210478&r2=210479&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=210479&r1=210478&r2=210479&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original)<br>
> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Mon Jun  9 12:08:19 2014<br>
> @@ -15,13 +15,13 @@<br>
>  #ifndef X86ISELLOWERING_H<br>
>  #define X86ISELLOWERING_H<br>
><br>
> -#include "X86Subtarget.h"<br>
>  #include "llvm/CodeGen/CallingConvLower.h"<br>
>  #include "llvm/CodeGen/SelectionDAG.h"<br>
>  #include "llvm/Target/TargetLowering.h"<br>
>  #include "llvm/Target/TargetOptions.h"<br>
><br>
>  namespace llvm {<br>
> +  class X86Subtarget;<br>
>    class X86TargetMachine;<br>
><br>
>    namespace X86ISD {<br>
> @@ -766,9 +766,7 @@ namespace llvm {<br>
><br>
>      /// isTargetFTOL - Return true if the target uses the MSVC _ftol2 routine<br>
>      /// for fptoui.<br>
> -    bool isTargetFTOL() const {<br>
> -      return Subtarget->isTargetKnownWindowsMSVC() && !Subtarget->is64Bit();<br>
> -    }<br>
> +    bool isTargetFTOL() const;<br>
><br>
>      /// isIntegerTypeFTOL - Return true if the MSVC _ftol2 routine should be<br>
>      /// used for fptoui to the given type.<br>
><br>
> Modified: llvm/trunk/lib/Target/X86/X86JITInfo.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.h?rev=210479&r1=210478&r2=210479&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.h?rev=210479&r1=210478&r2=210479&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/Target/X86/X86JITInfo.h (original)<br>
> +++ llvm/trunk/lib/Target/X86/X86JITInfo.h Mon Jun  9 12:08:19 2014<br>
> @@ -23,7 +23,7 @@ namespace llvm {<br>
><br>
>    class X86JITInfo : public TargetJITInfo {<br>
>      uintptr_t PICBase;<br>
> -    char* TLSOffset;<br>
> +    char *TLSOffset;<br>
>      bool useSSE;<br>
>    public:<br>
>      explicit X86JITInfo(bool UseSSE);<br>
><br>
> Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=210479&r1=210478&r2=210479&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=210479&r1=210478&r2=210479&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original)<br>
> +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Mon Jun  9 12:08:19 2014<br>
> @@ -297,8 +297,47 @@ void X86Subtarget::initializeEnvironment<br>
>    MaxInlineSizeThreshold = 128;<br>
>  }<br>
><br>
> +static std::string computeDataLayout(const X86Subtarget &ST) {<br>
> +  // X86 is little endian<br>
> +  std::string Ret = "e";<br>
> +<br>
> +  Ret += DataLayout::getManglingComponent(ST.getTargetTriple());<br>
> +  // X86 and x32 have 32 bit pointers.<br>
> +  if (ST.isTarget64BitILP32() || !ST.is64Bit())<br>
> +    Ret += "-p:32:32";<br>
> +<br>
> +  // Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.<br>
> +  if (ST.is64Bit() || ST.isOSWindows() || ST.isTargetNaCl())<br>
> +    Ret += "-i64:64";<br>
> +  else<br>
> +    Ret += "-f64:32:64";<br>
> +<br>
> +  // Some ABIs align long double to 128 bits, others to 32.<br>
> +  if (ST.isTargetNaCl())<br>
> +    ; // No f80<br>
> +  else if (ST.is64Bit() || ST.isTargetDarwin())<br>
> +    Ret += "-f80:128";<br>
> +  else<br>
> +    Ret += "-f80:32";<br>
> +<br>
> +  // The registers can hold 8, 16, 32 or, in x86-64, 64 bits.<br>
> +  if (ST.is64Bit())<br>
> +    Ret += "-n8:16:32:64";<br>
> +  else<br>
> +    Ret += "-n8:16:32";<br>
> +<br>
> +  // The stack is aligned to 32 bits on some ABIs and 128 bits on others.<br>
> +  if (!ST.is64Bit() && ST.isOSWindows())<br>
> +    Ret += "-S32";<br>
> +  else<br>
> +    Ret += "-S128";<br>
> +<br>
> +  return Ret;<br>
> +}<br>
> +<br>
>  X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,<br>
> -                           const std::string &FS, unsigned StackAlignOverride)<br>
> +                           const std::string &FS, X86TargetMachine &TM,<br>
> +                           unsigned StackAlignOverride)<br>
>      : X86GenSubtargetInfo(TT, CPU, FS), X86ProcFamily(Others),<br>
>        PICStyle(PICStyles::None), TargetTriple(TT),<br>
>        StackAlignOverride(StackAlignOverride),<br>
> @@ -306,9 +345,24 @@ X86Subtarget::X86Subtarget(const std::st<br>
>        In32BitMode(TargetTriple.getArch() == Triple::x86 &&<br>
>                    TargetTriple.getEnvironment() != Triple::CODE16),<br>
>        In16BitMode(TargetTriple.getArch() == Triple::x86 &&<br>
> -                  TargetTriple.getEnvironment() == Triple::CODE16) {<br>
> +                  TargetTriple.getEnvironment() == Triple::CODE16),<br>
> +      DL(computeDataLayout(*this)), TSInfo(DL) {<br>
>    initializeEnvironment();<br>
>    resetSubtargetFeatures(CPU, FS);<br>
> +  // Ordering here is important. X86InstrInfo initializes X86RegisterInfo which<br>
> +  // X86TargetLowering needs.<br>
> +  InstrInfo = new X86InstrInfo(TM);<br>
> +  TLInfo = new X86TargetLowering(TM);<br>
> +  FrameLowering = new X86FrameLowering(TargetFrameLowering::StackGrowsDown,<br>
> +                                       getStackAlignment(),<br>
> +                                       is64Bit() ? -8 : -4);<br>
> +  JITInfo = new X86JITInfo(hasSSE1());<br>
> +}<br>
> +<br>
> +X86Subtarget::~X86Subtarget() {<br>
> +  delete TLInfo;<br>
> +  delete InstrInfo;<br>
> +  delete FrameLowering;<br>
>  }<br>
><br>
>  bool<br>
><br>
> Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=210479&r1=210478&r2=210479&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=210479&r1=210478&r2=210479&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original)<br>
> +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Mon Jun  9 12:08:19 2014<br>
> @@ -14,6 +14,11 @@<br>
>  #ifndef X86SUBTARGET_H<br>
>  #define X86SUBTARGET_H<br>
><br>
> +#include "X86FrameLowering.h"<br>
> +#include "X86ISelLowering.h"<br>
> +#include "X86InstrInfo.h"<br>
> +#include "X86JITInfo.h"<br>
> +#include "X86SelectionDAGInfo.h"<br>
>  #include "llvm/ADT/Triple.h"<br>
>  #include "llvm/IR/CallingConv.h"<br>
>  #include "llvm/Target/TargetSubtargetInfo.h"<br>
> @@ -40,6 +45,7 @@ enum Style {<br>
>  }<br>
><br>
>  class X86Subtarget final : public X86GenSubtargetInfo {<br>
> +<br>
>  protected:<br>
>    enum X86SSEEnum {<br>
>      NoMMXSSE, MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, AVX, AVX2, AVX512F<br>
> @@ -220,13 +226,29 @@ private:<br>
>    /// In16BitMode - True if compiling for 16-bit, false for 32-bit or 64-bit.<br>
>    bool In16BitMode;<br>
><br>
> +  // Calculates type size & alignment<br>
> +  const DataLayout DL;<br>
> +  X86SelectionDAGInfo TSInfo;<br>
> +  X86TargetLowering *TLInfo;<br>
> +  X86InstrInfo *InstrInfo;<br>
> +  X86FrameLowering *FrameLowering;<br>
> +  X86JITInfo *JITInfo;<br>
> +<br>
>  public:<br>
>    /// This constructor initializes the data members to match that<br>
>    /// of the specified triple.<br>
>    ///<br>
>    X86Subtarget(const std::string &TT, const std::string &CPU,<br>
> -               const std::string &FS,<br>
> +               const std::string &FS, X86TargetMachine &TM,<br>
>                 unsigned StackAlignOverride);<br>
> +  ~X86Subtarget();<br>
> +<br>
> +  const X86TargetLowering *getTargetLowering() const { return TLInfo; }<br>
> +  const X86InstrInfo *getInstrInfo() const { return InstrInfo; }<br>
> +  const DataLayout *getDataLayout() const { return &DL; }<br>
> +  const X86FrameLowering *getFrameLowering() const { return FrameLowering; }<br>
> +  const X86SelectionDAGInfo *getSelectionDAGInfo() const { return &TSInfo; }<br>
> +  X86JITInfo *getJITInfo() { return JITInfo; }<br>
><br>
>    /// getStackAlignment - Returns the minimum alignment known to hold of the<br>
>    /// stack frame on entry to the function and which must be maintained by every<br>
><br>
> Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=210479&r1=210478&r2=210479&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=210479&r1=210478&r2=210479&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)<br>
> +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Mon Jun  9 12:08:19 2014<br>
> @@ -29,44 +29,6 @@ extern "C" void LLVMInitializeX86Target(<br>
><br>
>  void X86TargetMachine::anchor() { }<br>
><br>
> -static std::string computeDataLayout(const X86Subtarget &ST) {<br>
> -  // X86 is little endian<br>
> -  std::string Ret = "e";<br>
> -<br>
> -  Ret += DataLayout::getManglingComponent(ST.getTargetTriple());<br>
> -  // X86 and x32 have 32 bit pointers.<br>
> -  if (ST.isTarget64BitILP32() || !ST.is64Bit())<br>
> -    Ret += "-p:32:32";<br>
> -<br>
> -  // Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.<br>
> -  if (ST.is64Bit() || ST.isOSWindows() || ST.isTargetNaCl())<br>
> -    Ret += "-i64:64";<br>
> -  else<br>
> -    Ret += "-f64:32:64";<br>
> -<br>
> -  // Some ABIs align long double to 128 bits, others to 32.<br>
> -  if (ST.isTargetNaCl())<br>
> -    ; // No f80<br>
> -  else if (ST.is64Bit() || ST.isTargetDarwin())<br>
> -    Ret += "-f80:128";<br>
> -  else<br>
> -    Ret += "-f80:32";<br>
> -<br>
> -  // The registers can hold 8, 16, 32 or, in x86-64, 64 bits.<br>
> -  if (ST.is64Bit())<br>
> -    Ret += "-n8:16:32:64";<br>
> -  else<br>
> -    Ret += "-n8:16:32";<br>
> -<br>
> -  // The stack is aligned to 32 bits on some ABIs and 128 bits on others.<br>
> -  if (!ST.is64Bit() && ST.isOSWindows())<br>
> -    Ret += "-S32";<br>
> -  else<br>
> -    Ret += "-S128";<br>
> -<br>
> -  return Ret;<br>
> -}<br>
> -<br>
>  /// X86TargetMachine ctor - Create an X86 target.<br>
>  ///<br>
>  X86TargetMachine::X86TargetMachine(const Target &T, StringRef TT, StringRef CPU,<br>
> @@ -74,12 +36,7 @@ X86TargetMachine::X86TargetMachine(const<br>
>                                     Reloc::Model RM, CodeModel::Model CM,<br>
>                                     CodeGenOpt::Level OL)<br>
>      : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),<br>
> -      Subtarget(TT, CPU, FS, Options.StackAlignmentOverride),<br>
> -      FrameLowering(TargetFrameLowering::StackGrowsDown,<br>
> -                    Subtarget.getStackAlignment(),<br>
> -                    Subtarget.is64Bit() ? -8 : -4),<br>
> -      DL(computeDataLayout(*getSubtargetImpl())), InstrInfo(*this),<br>
> -      TLInfo(*this), TSInfo(DL), JITInfo(Subtarget.hasSSE1()) {<br>
> +      Subtarget(TT, CPU, FS, *this, Options.StackAlignmentOverride) {<br>
>    // Determine the PICStyle based on the target selected.<br>
>    if (getRelocationModel() == Reloc::Static) {<br>
>      // Unless we're in PIC or DynamicNoPIC mode, set the PIC style to None.<br>
><br>
> Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.h?rev=210479&r1=210478&r2=210479&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.h?rev=210479&r1=210478&r2=210479&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/Target/X86/X86TargetMachine.h (original)<br>
> +++ llvm/trunk/lib/Target/X86/X86TargetMachine.h Mon Jun  9 12:08:19 2014<br>
> @@ -18,7 +18,6 @@<br>
>  #include "X86ISelLowering.h"<br>
>  #include "X86InstrInfo.h"<br>
>  #include "X86JITInfo.h"<br>
> -#include "X86SelectionDAGInfo.h"<br>
>  #include "X86Subtarget.h"<br>
>  #include "llvm/IR/DataLayout.h"<br>
>  #include "llvm/Target/TargetMachine.h"<br>
> @@ -30,12 +29,6 @@ class StringRef;<br>
>  class X86TargetMachine final : public LLVMTargetMachine {<br>
>    virtual void anchor();<br>
>    X86Subtarget       Subtarget;<br>
> -  X86FrameLowering   FrameLowering;<br>
> -  const DataLayout   DL; // Calculates type size & alignment<br>
> -  X86InstrInfo       InstrInfo;<br>
> -  X86TargetLowering  TLInfo;<br>
> -  X86SelectionDAGInfo TSInfo;<br>
> -  X86JITInfo         JITInfo;<br>
><br>
>  public:<br>
>    X86TargetMachine(const Target &T, StringRef TT,<br>
> @@ -43,22 +36,22 @@ public:<br>
>                     Reloc::Model RM, CodeModel::Model CM,<br>
>                     CodeGenOpt::Level OL);<br>
><br>
> -  const DataLayout *getDataLayout() const override { return &DL; }<br>
> +  const DataLayout *getDataLayout() const override {<br>
> +    return getSubtargetImpl()->getDataLayout();<br>
> +  }<br>
>    const X86InstrInfo *getInstrInfo() const override {<br>
> -    return &InstrInfo;<br>
> +    return getSubtargetImpl()->getInstrInfo();<br>
>    }<br>
>    const TargetFrameLowering *getFrameLowering() const override {<br>
> -    return &FrameLowering;<br>
> -  }<br>
> -  X86JITInfo *getJITInfo() override {<br>
> -    return &JITInfo;<br>
> +    return getSubtargetImpl()->getFrameLowering();<br>
>    }<br>
> +  X86JITInfo *getJITInfo() override { return Subtarget.getJITInfo(); }<br>
>    const X86Subtarget *getSubtargetImpl() const override { return &Subtarget; }<br>
>    const X86TargetLowering *getTargetLowering() const override {<br>
> -    return &TLInfo;<br>
> +    return getSubtargetImpl()->getTargetLowering();<br>
>    }<br>
>    const X86SelectionDAGInfo *getSelectionDAGInfo() const override {<br>
> -    return &TSInfo;<br>
> +    return getSubtargetImpl()->getSelectionDAGInfo();<br>
>    }<br>
>    const X86RegisterInfo  *getRegisterInfo() const override {<br>
>      return &getInstrInfo()->getRegisterInfo();<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Alexander Potapenko<br>
Software Engineer<br>
Google Moscow<br>
</font></span></blockquote></div><br></div>