summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Writer/Writer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-01-14 23:36:54 +0000
committerChris Lattner <sabre@nondot.org>2004-01-14 23:36:54 +0000
commit6229fbf3287d72b9caae78db43b2f8fd52641409 (patch)
treeda67ce40ffe8f77d1023d1576c6721070f726e48 /llvm/lib/Bytecode/Writer/Writer.cpp
parent394afe0f903e57d311ab43d4bbec8c50e0c30403 (diff)
downloadbcm5719-llvm-6229fbf3287d72b9caae78db43b2f8fd52641409.tar.gz
bcm5719-llvm-6229fbf3287d72b9caae78db43b2f8fd52641409.zip
The new bytecode format supports emitting strings a special case. This is
intended to save size (and does on small programs), but on big programs it actually increases the size of the program slightly. The deal is that many functions end up using the characters that the string contained, and the characters are no longer in the global constant table, so they have to be emitted in function specific constant pools. This pessimization will be fixed in subsequent patches. llvm-svn: 10864
Diffstat (limited to 'llvm/lib/Bytecode/Writer/Writer.cpp')
-rw-r--r--llvm/lib/Bytecode/Writer/Writer.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp
index ca50b5a7bd3..2020a3a2bd6 100644
--- a/llvm/lib/Bytecode/Writer/Writer.cpp
+++ b/llvm/lib/Bytecode/Writer/Writer.cpp
@@ -24,9 +24,10 @@
#include "WriterInternals.h"
#include "llvm/Bytecode/WriteBytecodePass.h"
+#include "llvm/Constants.h"
+#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
-#include "llvm/DerivedTypes.h"
#include "Support/STLExtras.h"
#include "Support/Statistic.h"
#include "Support/Debug.h"
@@ -54,7 +55,9 @@ ModuleInfoBytes("bytecodewriter", "Bytes of module info");
BytecodeWriter::BytecodeWriter(std::deque<unsigned char> &o, const Module *M)
: Out(o), Table(M, true) {
- outputSignature();
+ // Emit the signature...
+ static const unsigned char *Sig = (const unsigned char*)"llvm";
+ output_data(Sig, Sig+4, Out);
// Emit the top level CLASS block.
BytecodeBlock ModuleBlock(BytecodeFormat::Module, Out);
@@ -111,9 +114,12 @@ void BytecodeWriter::outputConstantsInPlane(const std::vector<const Value*>
&Plane, unsigned StartNo) {
unsigned ValNo = StartNo;
- // Scan through and ignore function arguments/global values...
- for (; ValNo < Plane.size() && (isa<Argument>(Plane[ValNo]) ||
- isa<GlobalValue>(Plane[ValNo])); ValNo++)
+ // Scan through and ignore function arguments, global values, and constant
+ // strings.
+ for (; ValNo < Plane.size() &&
+ (isa<Argument>(Plane[ValNo]) || isa<GlobalValue>(Plane[ValNo]) ||
+ (isa<ConstantArray>(Plane[ValNo]) &&
+ cast<ConstantArray>(Plane[ValNo])->isString())); ValNo++)
/*empty*/;
unsigned NC = ValNo; // Number of constants
@@ -171,6 +177,10 @@ void BytecodeWriter::outputConstants(bool isFunction) {
}
}
+ // Output module-level string constants before any other constants.x
+ if (!isFunction)
+ outputConstantStrings();
+
for (unsigned pno = 0; pno != NumPlanes; pno++)
if (pno != Type::TypeTyID) { // Type plane handled above.
const std::vector<const Value*> &Plane = Table.getPlane(pno);
OpenPOWER on IntegriCloud