diff options
author | Karl Schimpf <kschimpf@google.com> | 2013-07-03 11:02:54 -0700 |
---|---|---|
committer | Karl Schimpf <kschimpf@google.com> | 2013-07-03 11:02:54 -0700 |
commit | c68c47198c0e0a610e49eaf072429b9214fca04f (patch) | |
tree | cfa16f856e7debe229f1d18da1e874057743d36d | |
parent | c5f0da9f2a5ffb5d9e8803839655f2f3d6972d83 (diff) |
Don't generate Type ID's for global variable fields.
Also removed local MaxGlobalType in WriteModuleInfo because it calls VE.getTypeID(GV->getTYpe(), which is no longer defined for globals.
Also noted that MaxAlignment in WriteModuleInfo was no longer used and removed it.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3541
R=mseaborn@chromium.org
Review URL: https://codereview.chromium.org/18185005
-rw-r--r-- | lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp | 6 | ||||
-rw-r--r-- | lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp | 6 | ||||
-rw-r--r-- | test/NaCl/Bitcode/globalvars.ll | 10 |
3 files changed, 14 insertions, 8 deletions
diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp index 44aaeb3f0e..33d0d84cb5 100644 --- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp +++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp @@ -546,14 +546,11 @@ static void WriteModuleInfo(const Module *M, const NaClValueEnumerator &VE, // Emit information about sections and GC, computing how many there are. Also // compute the maximum alignment value. + // TODO(kschimpf): Remove code for SectionMap and GCMap. std::map<std::string, unsigned> SectionMap; std::map<std::string, unsigned> GCMap; - unsigned MaxAlignment = 0; - unsigned MaxGlobalType = 0; for (Module::const_global_iterator GV = M->global_begin(),E = M->global_end(); GV != E; ++GV) { - MaxAlignment = std::max(MaxAlignment, GV->getAlignment()); - MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV->getType())); if (GV->hasSection()) { // Give section names unique ID's. unsigned &Entry = SectionMap[GV->getSection()]; @@ -565,7 +562,6 @@ static void WriteModuleInfo(const Module *M, const NaClValueEnumerator &VE, } } for (Module::const_iterator F = M->begin(), E = M->end(); F != E; ++F) { - MaxAlignment = std::max(MaxAlignment, F->getAlignment()); if (F->hasSection()) { // Give section names unique ID's. unsigned &Entry = SectionMap[F->getSection()]; diff --git a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp index 393c5bc934..5e2484a3f3 100644 --- a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp +++ b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp @@ -243,8 +243,10 @@ void NaClValueEnumerator::EnumerateValue(const Value *V) { return; } - // Enumerate the type of this value. - EnumerateType(V->getType()); + // Enumerate the type of this value. Skip global values since no + // types are dumped for global variables. + if (!isa<GlobalVariable>(V)) + EnumerateType(V->getType()); if (const Constant *C = dyn_cast<Constant>(V)) { if (isa<GlobalValue>(C)) { diff --git a/test/NaCl/Bitcode/globalvars.ll b/test/NaCl/Bitcode/globalvars.ll index c6e6f2f17a..fd1f8eead2 100644 --- a/test/NaCl/Bitcode/globalvars.ll +++ b/test/NaCl/Bitcode/globalvars.ll @@ -4,9 +4,17 @@ ; Test that we generate appropriate bitcode values for global variables. +; Make sure that no struct/array types are generated by the global variables. +; BC: <TYPE_BLOCK_ID +; BC-NEXT: <NUMENTRY +; BC-NEXT: <VOID/> +; BC-NEXT: <FUNCTION +; BC-NEXT: <POINTER +; BC-NEXT: </TYPE_BLOCK_ID> + ; Make sure that the function declaration for function func (below) ; appears before the global variables block. -; BC: <FUNCTION op0=5 op1=0 op2=0 op3=0/> +; BC: <FUNCTION op0=2 op1=0 op2=0 op3=0/> ; Make sure we begin the globals block after function declarations. ; BC-NEXT: <GLOBALVAR_BLOCK |