diff options
author | Karl Schimpf <kschimpf@google.com> | 2013-07-02 14:36:36 -0700 |
---|---|---|
committer | Karl Schimpf <kschimpf@google.com> | 2013-07-02 14:36:36 -0700 |
commit | 4390b1a9ac86937b9f9886119b5fa0ffc77295eb (patch) | |
tree | 0ed3cbe3018c87f90bb55627066f6bdd5cfae9e0 /lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp | |
parent | bdad02d55969b0963ac23e05578d28def5636ebd (diff) |
Simplify globals in PNaCl wire format based on normalized constants.
Generates simple global variable records, followed by list of records defining
byte initialization and relocations.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3504
R=mseaborn@chromium.org
Review URL: https://codereview.chromium.org/18111002
Diffstat (limited to 'lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp')
-rw-r--r-- | lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp index feb14cdb0c..393c5bc934 100644 --- a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp +++ b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp @@ -42,16 +42,21 @@ NaClValueEnumerator::NaClValueEnumerator(const Module *M) { // constructor completes. TypeCountMapType count_map; TypeCountMap = &count_map; - // Enumerate the global variables. - for (Module::const_global_iterator I = M->global_begin(), - E = M->global_end(); I != E; ++I) - EnumerateValue(I); - // Enumerate the functions. + // Enumerate the functions. Note: We do this before global + // variables, so that global variable initializations can refer to + // the functions without a forward reference. for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) { EnumerateValue(I); } + // Enumerate the global variables. + FirstGlobalVarID = Values.size(); + for (Module::const_global_iterator I = M->global_begin(), + E = M->global_end(); I != E; ++I) + EnumerateValue(I); + NumGlobalVarIDs = Values.size() - FirstGlobalVarID; + // Enumerate the aliases. for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end(); I != E; ++I) @@ -60,11 +65,8 @@ NaClValueEnumerator::NaClValueEnumerator(const Module *M) { // Remember what is the cutoff between globalvalue's and other constants. unsigned FirstConstant = Values.size(); - // Enumerate the global variable initializers. - for (Module::const_global_iterator I = M->global_begin(), - E = M->global_end(); I != E; ++I) - if (I->hasInitializer()) - EnumerateValue(I->getInitializer()); + // Skip global variable initializers since they are handled within + // WriteGlobalVars of file NaClBitcodeWriter.cpp. // Enumerate the aliasees. for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end(); |