From f7e498138f2f15b9391274d0c062fa62ab2e86fc Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 12 Jun 2009 05:20:12 +0000 Subject: [PATCH] Don't remove aggregate-typed module level constants before encoding functions since functions may contain aggregate constants too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73220 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Writer/BitcodeWriter.cpp | 10 ---------- lib/Bitcode/Writer/ValueEnumerator.cpp | 16 ---------------- lib/Bitcode/Writer/ValueEnumerator.h | 5 ----- .../2009-06-11-FirstClassAggregateConstant.ll | 12 ++++++++++++ 4 files changed, 12 insertions(+), 31 deletions(-) create mode 100644 test/Bitcode/2009-06-11-FirstClassAggregateConstant.ll diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 9f16728d492..6dcddedef1c 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1308,16 +1308,6 @@ static void WriteModule(const Module *M, BitstreamWriter &Stream) { // Emit constants. WriteModuleConstants(VE, Stream); - // If we have any aggregate values in the value table, purge them - these can - // only be used to initialize global variables. Doing so makes the value - // namespace smaller for code in functions. - int NumNonAggregates = VE.PurgeAggregateValues(); - if (NumNonAggregates != -1) { - SmallVector Vals; - Vals.push_back(NumNonAggregates); - Stream.EmitRecord(bitc::MODULE_CODE_PURGEVALS, Vals); - } - // Emit function bodies. for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) if (!I->isDeclaration()) diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index 8002a36b474..32b2819762d 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -277,22 +277,6 @@ void ValueEnumerator::EnumerateAttributes(const AttrListPtr &PAL) { } -/// PurgeAggregateValues - If there are any aggregate values at the end of the -/// value list, remove them and return the count of the remaining values. If -/// there are none, return -1. -int ValueEnumerator::PurgeAggregateValues() { - // If there are no aggregate values at the end of the list, return -1. - if (Values.empty() || Values.back().first->getType()->isSingleValueType()) - return -1; - - // Otherwise, remove aggregate values... - while (!Values.empty() && !Values.back().first->getType()->isSingleValueType()) - Values.pop_back(); - - // ... and return the new size. - return Values.size(); -} - void ValueEnumerator::incorporateFunction(const Function &F) { NumModuleValues = Values.size(); diff --git a/lib/Bitcode/Writer/ValueEnumerator.h b/lib/Bitcode/Writer/ValueEnumerator.h index bb0324b1c57..40eeabb2b6a 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.h +++ b/lib/Bitcode/Writer/ValueEnumerator.h @@ -99,11 +99,6 @@ public: return Attributes; } - /// PurgeAggregateValues - If there are any aggregate values at the end of the - /// value list, remove them and return the count of the remaining values. If - /// there are none, return -1. - int PurgeAggregateValues(); - /// incorporateFunction/purgeFunction - If you'd like to deal with a function, /// use these two methods to get its data into the ValueEnumerator! /// diff --git a/test/Bitcode/2009-06-11-FirstClassAggregateConstant.ll b/test/Bitcode/2009-06-11-FirstClassAggregateConstant.ll new file mode 100644 index 00000000000..415f88e1637 --- /dev/null +++ b/test/Bitcode/2009-06-11-FirstClassAggregateConstant.ll @@ -0,0 +1,12 @@ +; RUN: llvm-as < %s | llvm-dis -disable-output +; PR4373 + +@foo = weak global { i32 } zeroinitializer +@bar = weak global i32 0 + +define void @test() { +entry: + store { i32 } zeroinitializer, { i32 }* @foo + store i32 1, i32* @bar + ret void +}