diff options
| author | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2009-04-08 04:16:39 +0000 |
|---|---|---|
| committer | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2009-04-08 04:16:39 +0000 |
| commit | 75c47a5cdf480571a71935cf80d49f802fec15a3 (patch) | |
| tree | c30a97af0ca74ad99bfccd6f08747eed4a8d5684 /lib/CodeGen/CGExpr.cpp | |
| parent | 837e897660a527cfe2b443ae7303f6cc8ba99a83 (diff) | |
Pointer width on targets like PIC16 is 16-bit, while the valid index size to GEP is only 32 or 64. So promote index to 32 in such cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68590 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 9067787f32..4a7171ebd8 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -799,8 +799,11 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) { QualType IdxTy = E->getIdx()->getType(); bool IdxSigned = IdxTy->isSignedIntegerType(); unsigned IdxBitwidth = cast<llvm::IntegerType>(Idx->getType())->getBitWidth(); - if (IdxBitwidth != LLVMPointerWidth) - Idx = Builder.CreateIntCast(Idx, llvm::IntegerType::get(LLVMPointerWidth), + + // If Pointer width is less than 32 than extend to 32. + unsigned IdxValidWidth = (LLVMPointerWidth < 32 ) ? 32 : LLVMPointerWidth; + if (IdxBitwidth != IdxValidWidth) + Idx = Builder.CreateIntCast(Idx, llvm::IntegerType::get(IdxValidWidth), IdxSigned, "idxprom"); // We know that the pointer points to a type of the correct size, unless the |
