aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode/NaCl/Writer
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Bitcode/NaCl/Writer')
-rw-r--r--lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp2
-rw-r--r--lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp6
-rw-r--r--lib/Bitcode/NaCl/Writer/NaClValueEnumerator.h3
3 files changed, 6 insertions, 5 deletions
diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
index 6432740ba2..923d0b2c1e 100644
--- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
+++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
@@ -550,7 +550,7 @@ static void EmitFnForwardTypeRef(const Value *V,
VE.InsertFnForwardTypeRef(ValID)) {
SmallVector<unsigned, 2> Vals;
Vals.push_back(ValID);
- Vals.push_back(VE.getTypeID(V->getType()));
+ Vals.push_back(VE.getTypeID(VE.NormalizeScalarType(V->getType())));
Stream.EmitRecord(naclbitc::FUNC_CODE_INST_FORWARDTYPEREF, Vals,
FUNCTION_INST_FORWARDTYPEREF_ABBREV);
}
diff --git a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp
index ca34ac9c77..cabdc420c6 100644
--- a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp
+++ b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp
@@ -298,7 +298,7 @@ void NaClValueEnumerator::EnumerateValue(const Value *VIn) {
}
-Type *NaClValueEnumerator::NormalizeParamType(Type *Ty) const {
+Type *NaClValueEnumerator::NormalizeScalarType(Type *Ty) const {
// Strip pointer types.
if (Ty->isPointerTy() && PNaClVersion >= 2)
Ty = IntPtrType;
@@ -309,8 +309,8 @@ Type *NaClValueEnumerator::NormalizeType(Type *Ty) const {
if (FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
SmallVector<Type *, 8> ArgTypes;
for (unsigned I = 0, E = FTy->getNumParams(); I < E; ++I)
- ArgTypes.push_back(NormalizeParamType(FTy->getParamType(I)));
- Ty = FunctionType::get(NormalizeParamType(FTy->getReturnType()),
+ ArgTypes.push_back(NormalizeScalarType(FTy->getParamType(I)));
+ Ty = FunctionType::get(NormalizeScalarType(FTy->getReturnType()),
ArgTypes, false);
}
return Ty;
diff --git a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.h b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.h
index 5f25039e30..e756beb2f2 100644
--- a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.h
+++ b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.h
@@ -154,11 +154,12 @@ public:
return T == IntPtrType;
}
+ Type *NormalizeScalarType(Type *Ty) const;
+
private:
void OptimizeTypes(const Module *M);
void OptimizeConstants(unsigned CstStart, unsigned CstEnd);
- Type *NormalizeParamType(Type *Ty) const;
Type *NormalizeType(Type *Ty) const;
void EnumerateValue(const Value *V);