diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-09-09 10:32:47 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-09-09 10:32:47 -0700 |
commit | b63e4bfe73188f7d68065f5b274e169491e593d2 (patch) | |
tree | ac29183c92f4d361752d478435e6b31e68910ca4 /lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp | |
parent | 1c0cea6c1fc807794f0d785392e05b19d0c70210 (diff) |
PNaCl bitcode: Remove TYPE_CODE_POINTER entries from type table
There are now no uses of pointer type IDs in PNaCl bitcode, so we can
stop outputting pointer types into the type table.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3671
TEST=test/NaCl/Bitcode/*.ll
Review URL: https://codereview.chromium.org/23600013
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 cabdc420c6..f1ae2584e1 100644 --- a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp +++ b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp @@ -298,25 +298,27 @@ void NaClValueEnumerator::EnumerateValue(const Value *VIn) { } -Type *NaClValueEnumerator::NormalizeScalarType(Type *Ty) const { - // Strip pointer types. - if (Ty->isPointerTy() && PNaClVersion >= 2) - Ty = IntPtrType; - return Ty; -} - Type *NaClValueEnumerator::NormalizeType(Type *Ty) const { + if (PNaClVersion == 1) + return Ty; + + if (Ty->isPointerTy()) + return IntPtrType; if (FunctionType *FTy = dyn_cast<FunctionType>(Ty)) { SmallVector<Type *, 8> ArgTypes; for (unsigned I = 0, E = FTy->getNumParams(); I < E; ++I) - ArgTypes.push_back(NormalizeScalarType(FTy->getParamType(I))); - Ty = FunctionType::get(NormalizeScalarType(FTy->getReturnType()), - ArgTypes, false); + ArgTypes.push_back(NormalizeType(FTy->getParamType(I))); + return FunctionType::get(NormalizeType(FTy->getReturnType()), + ArgTypes, false); } return Ty; } void NaClValueEnumerator::EnumerateType(Type *Ty, bool InsideOptimizeTypes) { + // Pointer types do not need to be given type IDs. + if (Ty->isPointerTy() && PNaClVersion >= 2) + Ty = Ty->getPointerElementType(); + Ty = NormalizeType(Ty); // The label type does not need to be given a type ID. |