<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Is this required for 2.6? I'd rather not have code keep going in thats experimental and breaking buildbots.<div><br></div><div>-Tanya<br><div><br><div><div>On Aug 20, 2009, at 4:14 PM, Owen Anderson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Author: resistor<br>Date: Thu Aug 20 18:14:20 2009<br>New Revision: 79572<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=79572&view=rev">http://llvm.org/viewvc/llvm-project?rev=79572&view=rev</a><br>Log:<br>Reapply r79555 for testing.  Daniel's trying to work out some buildbot weirdnesss.<br><br>Modified:<br>    llvm/trunk/include/llvm/Target/TargetData.h<br>    llvm/trunk/lib/Target/TargetData.cpp<br><br>Modified: llvm/trunk/include/llvm/Target/TargetData.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=79572&r1=79571&r2=79572&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=79572&r1=79571&r2=79572&view=diff</a><br><br>==============================================================================<br>--- llvm/trunk/include/llvm/Target/TargetData.h (original)<br>+++ llvm/trunk/include/llvm/Target/TargetData.h Thu Aug 20 18:14:20 2009<br>@@ -91,6 +91,9 @@<br>    */<br>   static const TargetAlignElem InvalidAlignmentElem;<br><br>+  /// Opaque pointer for the StructType -> StructLayout map<br>+  void* LayoutMap;<br>+<br>   //! Set/initialize target alignments<br>   void setAlignment(AlignTypeEnum align_type, unsigned char abi_align,<br>                     unsigned char pref_align, uint32_t bit_width);<br>@@ -107,6 +110,9 @@<br>     return (&align != &InvalidAlignmentElem);<br>   }<br><br>+  // DO NOT IMPLEMENT<br>+  void operator=(const TargetData&);<br>+  <br> public:<br>   /// Default ctor.<br>   ///<br>@@ -118,22 +124,11 @@<br>   }<br><br>   /// Constructs a TargetData from a specification string. See init().<br>-  explicit TargetData(const std::string &TargetDescription)<br>-    : ImmutablePass(&ID) {<br>-    init(TargetDescription);<br>-  }<br>+  explicit TargetData(const std::string &TargetDescription);<br><br>   /// Initialize target data from properties stored in the module.<br>   explicit TargetData(const Module *M);<br>-<br>-  TargetData(const TargetData &TD) :<br>-    ImmutablePass(&ID),<br>-    LittleEndian(TD.isLittleEndian()),<br>-    PointerMemSize(TD.PointerMemSize),<br>-    PointerABIAlign(TD.PointerABIAlign),<br>-    PointerPrefAlign(TD.PointerPrefAlign),<br>-    Alignments(TD.Alignments)<br>-  { }<br>+  TargetData(const TargetData &TD);<br><br>   ~TargetData();  // Not virtual, do not subclass this class<br><br><br>Modified: llvm/trunk/lib/Target/TargetData.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=79572&r1=79571&r2=79572&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=79572&r1=79571&r2=79572&view=diff</a><br><br>==============================================================================<br>--- llvm/trunk/lib/Target/TargetData.cpp (original)<br>+++ llvm/trunk/lib/Target/TargetData.cpp Thu Aug 20 18:14:20 2009<br>@@ -24,7 +24,6 @@<br> #include "llvm/Support/MathExtras.h"<br> #include "llvm/Support/ManagedStatic.h"<br> #include "llvm/Support/ErrorHandling.h"<br>-#include "llvm/System/Mutex.h"<br> #include "llvm/ADT/DenseMap.h"<br> #include "llvm/ADT/StringExtras.h"<br> #include <algorithm><br>@@ -132,6 +131,8 @@<br> //                       TargetData Class Implementation<br> //===----------------------------------------------------------------------===//<br><br>+typedef DenseMap<const StructType*, StructLayout*> LayoutInfoTy;<br>+<br> /*!<br>  A TargetDescription string consists of a sequence of hyphen-delimited<br>  specifiers for target endianness, pointer size and alignments, and various<br>@@ -170,6 +171,7 @@<br>  alignment will be used.<br>  */ <br> void TargetData::init(const std::string &TargetDescription) {<br>+  LayoutMap = static_cast<void*>(new LayoutInfoTy());<br>   std::string temp = TargetDescription;<br><br>   LittleEndian = false;<br>@@ -234,11 +236,28 @@<br>   }<br> }<br><br>+TargetData::TargetData(const std::string &TargetDescription)<br>+  : ImmutablePass(&ID) {<br>+  init(TargetDescription);<br>+}<br>+<br> TargetData::TargetData(const Module *M) <br>   : ImmutablePass(&ID) {<br>   init(M->getDataLayout());<br> }<br><br>+TargetData::TargetData(const TargetData &TD) :<br>+    ImmutablePass(&ID),<br>+    LittleEndian(TD.isLittleEndian()),<br>+    PointerMemSize(TD.PointerMemSize),<br>+    PointerABIAlign(TD.PointerABIAlign),<br>+    PointerPrefAlign(TD.PointerPrefAlign),<br>+    Alignments(TD.Alignments) {<br>+  LayoutInfoTy *Other = static_cast<LayoutInfoTy*>(TD.LayoutMap);<br>+  LayoutMap = static_cast<void*>(new LayoutInfoTy(*Other));<br>+}<br>+<br>+<br> void<br> TargetData::setAlignment(AlignTypeEnum align_type, unsigned char abi_align,<br>                          unsigned char pref_align, uint32_t bit_width) {<br>@@ -317,61 +336,26 @@<br>                  : Alignments[BestMatchIdx].PrefAlign;<br> }<br><br>-namespace {<br>-<br>-/// LayoutInfo - The lazy cache of structure layout information maintained by<br>-/// TargetData.  Note that the struct types must have been free'd before<br>-/// llvm_shutdown is called (and thus this is deallocated) because all the<br>-/// targets with cached elements should have been destroyed.<br>-///<br>-typedef std::pair<const TargetData*,const StructType*> LayoutKey;<br>-<br>-struct DenseMapLayoutKeyInfo {<br>-  static inline LayoutKey getEmptyKey() { return LayoutKey(0, 0); }<br>-  static inline LayoutKey getTombstoneKey() {<br>-    return LayoutKey((TargetData*)(intptr_t)-1, 0);<br>-  }<br>-  static unsigned getHashValue(const LayoutKey &Val) {<br>-    return DenseMapInfo<void*>::getHashValue(Val.first) ^<br>-           DenseMapInfo<void*>::getHashValue(Val.second);<br>-  }<br>-  static bool isEqual(const LayoutKey &LHS, const LayoutKey &RHS) {<br>-    return LHS == RHS;<br>-  }<br>-<br>-  static bool isPod() { return true; }<br>-};<br>-<br>-typedef DenseMap<LayoutKey, StructLayout*, DenseMapLayoutKeyInfo> LayoutInfoTy;<br>-<br>-}<br>-<br>-static ManagedStatic<LayoutInfoTy> LayoutInfo;<br>-static ManagedStatic<sys::SmartMutex<true> > LayoutLock;<br>-<br> TargetData::~TargetData() {<br>-  if (!LayoutInfo.isConstructed())<br>-    return;<br>-  <br>-  sys::SmartScopedLock<true> Lock(*LayoutLock);<br>+  assert(LayoutMap && "LayoutMap not initialized?");<br>+  LayoutInfoTy &TheMap = *static_cast<LayoutInfoTy*>(LayoutMap);<br>+<br>   // Remove any layouts for this TD.<br>-  LayoutInfoTy &TheMap = *LayoutInfo;<br>   for (LayoutInfoTy::iterator I = TheMap.begin(), E = TheMap.end(); I != E; ) {<br>-    if (I->first.first == this) {<br>-      I->second->~StructLayout();<br>-      free(I->second);<br>-      TheMap.erase(I++);<br>-    } else {<br>-      ++I;<br>-    }<br>+    I->second->~StructLayout();<br>+    free(I->second);<br>+    TheMap.erase(I++);<br>   }<br>+  <br>+  delete static_cast<LayoutInfoTy*>(LayoutMap);<br>+  LayoutMap = 0;<br> }<br><br> const StructLayout *TargetData::getStructLayout(const StructType *Ty) const {<br>-  LayoutInfoTy &TheMap = *LayoutInfo;<br>+  assert(LayoutMap && "LayoutMap not initialized?");<br>+  LayoutInfoTy &TheMap = *static_cast<LayoutInfoTy*>(LayoutMap);<br><br>-  sys::SmartScopedLock<true> Lock(*LayoutLock);<br>-  StructLayout *&SL = TheMap[LayoutKey(this, Ty)];<br>+  StructLayout *&SL = TheMap[Ty];<br>   if (SL) return SL;<br><br>   // Otherwise, create the struct layout.  Because it is variable length, we <br>@@ -393,10 +377,9 @@<br> /// removed, this method must be called whenever a StructType is removed to<br> /// avoid a dangling pointer in this cache.<br> void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const {<br>-  if (!LayoutInfo.isConstructed()) return;  // No cache.<br>-  <br>-  sys::SmartScopedLock<true> Lock(*LayoutLock);<br>-  LayoutInfoTy::iterator I = LayoutInfo->find(LayoutKey(this, Ty));<br>+  assert(LayoutMap && "LayoutMap not initialized?");<br>+  LayoutInfoTy *LayoutInfo = static_cast<LayoutInfoTy*>(LayoutMap);<br>+  LayoutInfoTy::iterator I = LayoutInfo->find(Ty);<br>   if (I == LayoutInfo->end()) return;<br><br>   I->second->~StructLayout();<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">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br></div></blockquote></div><br></div></div></body></html>