summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Writer/ValueEnumerator.h
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-03-27 23:17:54 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-03-27 23:17:54 +0000
commit6565a0d4b2c98722eb8fee9093cdde4f37928986 (patch)
tree9a98af7c4407ac1b6d74a183c4cf30bec6919fc4 /llvm/lib/Bitcode/Writer/ValueEnumerator.h
parent376fa2606069cdd5840fd035312bad027d8b2428 (diff)
downloadbcm5719-llvm-6565a0d4b2c98722eb8fee9093cdde4f37928986.tar.gz
bcm5719-llvm-6565a0d4b2c98722eb8fee9093cdde4f37928986.zip
Reapply ~"Bitcode: Collect all MDString records into a single blob"
Spiritually reapply commit r264409 (reverted in r264410), albeit with a bit of a redesign. Firstly, avoid splitting the big blob into multiple chunks of strings. r264409 imposed an arbitrary limit to avoid a massive allocation on the shared 'Record' SmallVector. The bug with that commit only reproduced when there were more than "chunk-size" strings. A test for this would have been useless long-term, since we're liable to adjust the chunk-size in the future. Thus, eliminate the motivation for chunk-ing by storing the string sizes in the blob. Here's the layout: vbr6: # of strings vbr6: offset-to-blob blob: [vbr6]: string lengths [char]: concatenated strings Secondly, make the output of llvm-bcanalyzer readable. I noticed when debugging r264409 that llvm-bcanalyzer was outputting a massive blob all in one line. Past a small number, the strings were impossible to split in my head, and the lines were way too long. This version adds support in llvm-bcanalyzer for pretty-printing. <STRINGS abbrevid=4 op0=3 op1=9/> num-strings = 3 { 'abc' 'def' 'ghi' } From the original commit: Inspired by Mehdi's similar patch, http://reviews.llvm.org/D18342, this should (a) slightly reduce bitcode size, since there is less record overhead, and (b) greatly improve reading speed, since blobs are super cheap to deserialize. llvm-svn: 264551
Diffstat (limited to 'llvm/lib/Bitcode/Writer/ValueEnumerator.h')
-rw-r--r--llvm/lib/Bitcode/Writer/ValueEnumerator.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.h b/llvm/lib/Bitcode/Writer/ValueEnumerator.h
index 7665210d014..fd09a695a99 100644
--- a/llvm/lib/Bitcode/Writer/ValueEnumerator.h
+++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.h
@@ -66,7 +66,7 @@ private:
SmallVector<const LocalAsMetadata *, 8> FunctionLocalMDs;
typedef DenseMap<const Metadata *, unsigned> MetadataMapType;
MetadataMapType MetadataMap;
- bool HasMDString;
+ unsigned NumMDStrings = 0;
bool ShouldPreserveUseListOrder;
typedef DenseMap<AttributeSet, unsigned> AttributeGroupMapType;
@@ -121,8 +121,6 @@ public:
}
unsigned numMDs() const { return MDs.size(); }
- bool hasMDString() const { return HasMDString; }
-
bool shouldPreserveUseListOrder() const { return ShouldPreserveUseListOrder; }
unsigned getTypeID(Type *T) const {
@@ -157,9 +155,16 @@ public:
const ValueList &getValues() const { return Values; }
const std::vector<const Metadata *> &getMDs() const { return MDs; }
+ ArrayRef<const Metadata *> getMDStrings() const {
+ return makeArrayRef(MDs).slice(0, NumMDStrings);
+ }
+ ArrayRef<const Metadata *> getNonMDStrings() const {
+ return makeArrayRef(MDs).slice(NumMDStrings);
+ }
const SmallVectorImpl<const LocalAsMetadata *> &getFunctionLocalMDs() const {
return FunctionLocalMDs;
}
+
const TypeList &getTypes() const { return Types; }
const std::vector<const BasicBlock*> &getBasicBlocks() const {
return BasicBlocks;
@@ -189,6 +194,10 @@ public:
private:
void OptimizeConstants(unsigned CstStart, unsigned CstEnd);
+ // Reorder the reachable metadata. This is not just an optimization, but is
+ // mandatory for emitting MDString correctly.
+ void organizeMetadata();
+
void EnumerateMDNodeOperands(const MDNode *N);
void EnumerateMetadata(const Metadata *MD);
void EnumerateFunctionLocalMetadata(const LocalAsMetadata *Local);
OpenPOWER on IntegriCloud