File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,18 @@ struct Uncommon {
124
124
};
125
125
126
126
struct Header {
127
+ // / Version number of the symtab format. This number should be incremented
128
+ // / when the format changes, but it does not need to be incremented if a
129
+ // / change to LLVM would cause it to create a different symbol table.
130
+ Word Version;
131
+ enum { kCurrentVersion = 0 };
132
+
133
+ // / The producer's version string (LLVM_VERSION_STRING " " LLVM_REVISION).
134
+ // / Consumers should rebuild the symbol table from IR if the producer's
135
+ // / version does not match the consumer's version due to potential differences
136
+ // / in symbol table format, symbol enumeration order and so on.
137
+ Str Producer;
138
+
127
139
Range<Module> Modules;
128
140
Range<Comdat> Comdats;
129
141
Range<Symbol> Symbols;
Original file line number Diff line number Diff line change 32
32
#include " llvm/Support/Casting.h"
33
33
#include " llvm/Support/Error.h"
34
34
#include " llvm/Support/StringSaver.h"
35
+ #include " llvm/Support/VCSRevision.h"
35
36
#include " llvm/Support/raw_ostream.h"
36
37
#include < cassert>
37
38
#include < string>
@@ -43,6 +44,21 @@ using namespace irsymtab;
43
44
44
45
namespace {
45
46
47
+ const char *getExpectedProducerName () {
48
+ static char DefaultName[] = LLVM_VERSION_STRING
49
+ #ifdef LLVM_REVISION
50
+ " " LLVM_REVISION
51
+ #endif
52
+ ;
53
+ // Allows for testing of the irsymtab writer and upgrade mechanism. This
54
+ // environment variable should not be set by users.
55
+ if (char *OverrideName = getenv (" LLVM_OVERRIDE_PRODUCER" ))
56
+ return OverrideName;
57
+ return DefaultName;
58
+ }
59
+
60
+ const char *kExpectedProducerName = getExpectedProducerName();
61
+
46
62
// / Stores the temporary state that is required to build an IR symbol table.
47
63
struct Builder {
48
64
SmallVector<char , 0 > &Symtab;
@@ -231,6 +247,8 @@ Error Builder::build(ArrayRef<Module *> IRMods) {
231
247
storage::Header Hdr;
232
248
233
249
assert (!IRMods.empty ());
250
+ Hdr.Version = storage::Header::kCurrentVersion ;
251
+ setStr (Hdr.Producer , kExpectedProducerName );
234
252
setStr (Hdr.TargetTriple , IRMods[0 ]->getTargetTriple ());
235
253
setStr (Hdr.SourceFileName , IRMods[0 ]->getSourceFileName ());
236
254
TT = Triple (IRMods[0 ]->getTargetTriple ());
You can’t perform that action at this time.
0 commit comments