]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/commitdiff
Revert r201751 and solve the const problem a different way - by
authorEric Christopher <echristo@gmail.com>
Thu, 27 Feb 2014 18:36:10 +0000 (18:36 +0000)
committerEric Christopher <echristo@gmail.com>
Thu, 27 Feb 2014 18:36:10 +0000 (18:36 +0000)
making the cache mutable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202417 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DIE.cpp
lib/CodeGen/AsmPrinter/DIE.h
lib/CodeGen/AsmPrinter/DwarfUnit.cpp

index cf8cbd5b7eae0e77417d7e1511e7bfe37126a252..4722d2b5501161198492d537256eb233d07722d1 100644 (file)
@@ -426,15 +426,13 @@ void DIETypeSignature::dump() const { print(dbgs()); }
 /// ComputeSize - calculate the size of the location expression.
 ///
 unsigned DIELoc::ComputeSize(AsmPrinter *AP) const {
-  if (Size)
-    return Size;
-
-  unsigned Sz = 0;
-  const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
-  for (unsigned i = 0, N = Values.size(); i < N; ++i)
-    Sz += Values[i]->SizeOf(AP, AbbrevData[i].getForm());
+  if (!Size) {
+    const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
+    for (unsigned i = 0, N = Values.size(); i < N; ++i)
+      Size += Values[i]->SizeOf(AP, AbbrevData[i].getForm());
+  }
 
-  return Sz;
+  return Size;
 }
 
 /// EmitValue - Emit location data.
@@ -483,15 +481,13 @@ void DIELoc::print(raw_ostream &O) const {
 /// ComputeSize - calculate the size of the block.
 ///
 unsigned DIEBlock::ComputeSize(AsmPrinter *AP) const {
-  if (Size)
-    return Size;
-
-  unsigned Sz = 0;
-  const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
-  for (unsigned i = 0, N = Values.size(); i < N; ++i)
-    Sz += Values[i]->SizeOf(AP, AbbrevData[i].getForm());
+  if (!Size) {
+    const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
+    for (unsigned i = 0, N = Values.size(); i < N; ++i)
+      Size += Values[i]->SizeOf(AP, AbbrevData[i].getForm());
+  }
 
-  return Sz;
+  return Size;
 }
 
 /// EmitValue - Emit block data.
index d4f3154d15c7725ba277f3de7b5214ffedb0b0ed..0a60859b7e56775a53b157fe9a71d405a56d8d95 100644 (file)
@@ -445,7 +445,7 @@ namespace llvm {
   /// DIELoc - Represents an expression location.
   //
   class DIELoc : public DIEValue, public DIE {
-    unsigned Size;                // Size in bytes excluding size header.
+    mutable unsigned Size;                // Size in bytes excluding size header.
   public:
     DIELoc() : DIEValue(isLoc), DIE(0), Size(0) {}
 
@@ -453,10 +453,6 @@ namespace llvm {
     ///
     unsigned ComputeSize(AsmPrinter *AP) const;
 
-    /// setSize - Set the size of the location entry.
-    ///
-    void setSize(unsigned Sz) { Size = Sz; }
-
     /// BestForm - Choose the best form for data.
     ///
     dwarf::Form BestForm(unsigned DwarfVersion) const {
@@ -488,7 +484,7 @@ namespace llvm {
   /// DIEBlock - Represents a block of values.
   //
   class DIEBlock : public DIEValue, public DIE {
-    unsigned Size;                // Size in bytes excluding size header.
+    mutable unsigned Size;                // Size in bytes excluding size header.
   public:
     DIEBlock() : DIEValue(isBlock), DIE(0), Size(0) {}
 
@@ -496,10 +492,6 @@ namespace llvm {
     ///
     unsigned ComputeSize(AsmPrinter *AP) const;
 
-    /// setSize - Set the size of the block.
-    ///
-    void setSize(unsigned Sz) { Size = Sz; }
-
     /// BestForm - Choose the best form for data.
     ///
     dwarf::Form BestForm() const {
index 2ac9f0194f4b08da4140eef0337feb59a3298c2a..b42869bbe0be335a28405d3514ab2c9d5523e52c 100644 (file)
@@ -348,14 +348,14 @@ DIE *DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, DIDescriptor N) {
 /// addBlock - Add block data.
 ///
 void DwarfUnit::addBlock(DIE *Die, dwarf::Attribute Attribute, DIELoc *Loc) {
-  Loc->setSize(Loc->ComputeSize(Asm));
+  Loc->ComputeSize(Asm);
   DIELocs.push_back(Loc); // Memoize so we can call the destructor later on.
   Die->addValue(Attribute, Loc->BestForm(DD->getDwarfVersion()), Loc);
 }
 
 void DwarfUnit::addBlock(DIE *Die, dwarf::Attribute Attribute,
                          DIEBlock *Block) {
-  Block->setSize(Block->ComputeSize(Asm));
+  Block->ComputeSize(Asm);
   DIEBlocks.push_back(Block); // Memoize so we can call the destructor later on.
   Die->addValue(Attribute, Block->BestForm(), Block);
 }