diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-07-29 17:34:39 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-07-29 17:34:39 +0000 |
| commit | 3f76342cfcbec5b9804503b8c3114c470c59a44d (patch) | |
| tree | 29bb7039d4cad434c31f71489cb669ff11aa1e90 /clang/lib | |
| parent | 44f9c3b3f1529e57f7c8a61daa6bc67e85740cec (diff) | |
| download | bcm5719-llvm-3f76342cfcbec5b9804503b8c3114c470c59a44d.tar.gz bcm5719-llvm-3f76342cfcbec5b9804503b8c3114c470c59a44d.zip | |
handle a case where we could access off the end of a function
that Eli pointed out, rdar://8249586
llvm-svn: 109762
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 0d8d3a9dff3..67f8a201440 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -1358,18 +1358,15 @@ Get8ByteTypeAtOffset(const llvm::Type *IRType, unsigned IROffset, // Okay, we don't have any better idea of what to pass, so we pass this in an // integer register that isn't too big to fit the rest of the struct. - uint64_t TySizeInBytes = - getContext().getTypeSizeInChars(SourceTy).getQuantity(); + unsigned TySizeInBytes = + (unsigned)getContext().getTypeSizeInChars(SourceTy).getQuantity(); + assert(TySizeInBytes != SourceOffset && "Empty field?"); + // It is always safe to classify this as an integer type up to i64 that // isn't larger than the structure. - switch (unsigned(TySizeInBytes-SourceOffset)) { - case 1: return llvm::Type::getInt8Ty(getVMContext()); - case 2: return llvm::Type::getInt16Ty(getVMContext()); - case 3: - case 4: return llvm::Type::getInt32Ty(getVMContext()); - default: return llvm::Type::getInt64Ty(getVMContext()); - } + return llvm::IntegerType::get(getVMContext(), + std::min(TySizeInBytes-SourceOffset, 8U)*8); } ABIArgInfo X86_64ABIInfo:: |

