aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp
diff options
context:
space:
mode:
authorKarl Schimpf <kschimpf@google.com>2013-09-03 14:04:17 -0700
committerKarl Schimpf <kschimpf@google.com>2013-09-03 14:04:17 -0700
commiteb10318143cc0045a053a1973e4aeaf246e53984 (patch)
treecc1b6e097abc12a5532e61a14429f04ece95e37a /lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp
parent30aa17affbfa35a9d32895ff6f4b5f5fbfc9575a (diff)
Remove generating STRUCT_ANON records in PNaCl bitcode files.
Don't generate types for elided cast instructions, since they are never put into the bitcode file. In addition, do not generate a type id for the types of global variables, because they are never needed. Don't allow STRUCT_ANON in bitcode files PNaClVersion==2. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3648 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/23455023
Diffstat (limited to 'lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp')
-rw-r--r--lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp
index 5dbc525eec..be31779a3a 100644
--- a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp
+++ b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp
@@ -90,6 +90,10 @@ NaClValueEnumerator::NaClValueEnumerator(const Module *M, uint32_t PNaClVersion)
for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I){
+ // Don't generate types for elided pointer casts!
+ if (IsElidedCast(I))
+ continue;
+
for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
OI != E; ++OI) {
EnumerateOperandType(*OI);
@@ -357,6 +361,11 @@ void NaClValueEnumerator::EnumerateType(Type *Ty, bool InsideOptimizeTypes) {
// Enumerate the types for the specified value. If the value is a constant,
// walk through it, enumerating the types of the constant.
void NaClValueEnumerator::EnumerateOperandType(const Value *V) {
+ // Note: We intentionally don't create a type id for global variables,
+ // since the type is automatically generated by the reader before any
+ // use of the global variable.
+ if (isa<GlobalVariable>(V)) return;
+
EnumerateType(V->getType());
if (const Constant *C = dyn_cast<Constant>(V)) {