diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-09-06 15:34:50 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-09-06 15:34:50 -0700 |
commit | 083eeaf1e9fc4e929b8f805deb4d3d3d0be038fc (patch) | |
tree | 8458b12bd1b72f3746e81d16ef475dc0b5f2e473 /lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp | |
parent | 68cb3f7eca7536d85301f92314dbb5db6757cd94 (diff) |
PNaCl bitcode: Use function type not ptr-to-function type to declare function
This is a step towards removing TYPE_CODE_POINTER from the types
table. This will make the format simpler. It will also make bitcode
files a little smaller, because we won't need to use type IDs for
referring to pointer types.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3671
TEST=test/NaCl/Bitcode/*.ll
Review URL: https://codereview.chromium.org/24049002
Diffstat (limited to 'lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp')
-rw-r--r-- | lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp index 8b8e9072a8..276d1d59b3 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp @@ -945,12 +945,16 @@ bool NaClBitcodeReader::ParseModule(bool Resume) { return Error("Invalid MODULE_CODE_FUNCTION record"); Type *Ty = getTypeByID(Record[0]); if (!Ty) return Error("Invalid MODULE_CODE_FUNCTION record"); - if (!Ty->isPointerTy()) - return Error("Function not a pointer type!"); - FunctionType *FTy = - dyn_cast<FunctionType>(cast<PointerType>(Ty)->getElementType()); + FunctionType *FTy; + if (GetPNaClVersion() == 1) { + if (!Ty->isPointerTy()) + return Error("Function not a pointer type!"); + FTy = dyn_cast<FunctionType>(cast<PointerType>(Ty)->getElementType()); + } else { + FTy = dyn_cast<FunctionType>(Ty); + } if (!FTy) - return Error("Function not a pointer to function type!"); + return Error("Function not declared with a function type!"); Function *Func = Function::Create(FTy, GlobalValue::ExternalLinkage, "", TheModule); |