From 5d503b5deb29780e5bc4ac6e5f185ec708c3ad07 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 20 Feb 2014 02:40:45 +0000 Subject: Make DIELoc/DIEBlock's ComputeSize method const. Add a setSize method to actually set it in the class to avoid computing it multiple times. llvm-svn: 201751 --- llvm/lib/CodeGen/AsmPrinter/DIE.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/DIE.cpp') diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp index 79c4b438f8e..845bb4610a2 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp @@ -424,14 +424,16 @@ void DIETypeSignature::dump() const { print(dbgs()); } /// ComputeSize - calculate the size of the location expression. /// -unsigned DIELoc::ComputeSize(AsmPrinter *AP) { - if (!Size) { - const SmallVectorImpl &AbbrevData = Abbrev.getData(); - for (unsigned i = 0, N = Values.size(); i < N; ++i) - Size += Values[i]->SizeOf(AP, AbbrevData[i].getForm()); - } +unsigned DIELoc::ComputeSize(AsmPrinter *AP) const { + if (Size) + return Size; + + unsigned Sz = 0; + const SmallVectorImpl &AbbrevData = Abbrev.getData(); + for (unsigned i = 0, N = Values.size(); i < N; ++i) + Sz += Values[i]->SizeOf(AP, AbbrevData[i].getForm()); - return Size; + return Sz; } /// EmitValue - Emit location data. @@ -479,14 +481,16 @@ void DIELoc::print(raw_ostream &O) const { /// ComputeSize - calculate the size of the block. /// -unsigned DIEBlock::ComputeSize(AsmPrinter *AP) { - if (!Size) { - const SmallVectorImpl &AbbrevData = Abbrev.getData(); - for (unsigned i = 0, N = Values.size(); i < N; ++i) - Size += Values[i]->SizeOf(AP, AbbrevData[i].getForm()); - } +unsigned DIEBlock::ComputeSize(AsmPrinter *AP) const { + if (Size) + return Size; + + unsigned Sz = 0; + const SmallVectorImpl &AbbrevData = Abbrev.getData(); + for (unsigned i = 0, N = Values.size(); i < N; ++i) + Sz += Values[i]->SizeOf(AP, AbbrevData[i].getForm()); - return Size; + return Sz; } /// EmitValue - Emit block data. -- cgit v1.2.3