diff options
| author | Ivan A. Kosarev <ikosarev@accesssoftek.com> | 2017-10-20 12:35:17 +0000 |
|---|---|---|
| committer | Ivan A. Kosarev <ikosarev@accesssoftek.com> | 2017-10-20 12:35:17 +0000 |
| commit | f761d0e514c593c49f9dde7eebd293e97b80b8b4 (patch) | |
| tree | 6be84a0897b41a4c5b379e729db6e02cdbae106b /clang/lib/CodeGen/CGExpr.cpp | |
| parent | 3d34d877cb9e682d321dd818d90178da68054ba6 (diff) | |
| download | bcm5719-llvm-f761d0e514c593c49f9dde7eebd293e97b80b8b4.tar.gz bcm5719-llvm-f761d0e514c593c49f9dde7eebd293e97b80b8b4.zip | |
[CodeGen] Fix generation of TBAA info for array-to-pointer conversions
Resolves:
Fatal error: Offset not zero at the point of scalar access.
http://llvm.org/PR34992
Differential Revision: https://reviews.llvm.org/D39083
llvm-svn: 316211
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 158baf75862..2eb6d0a0c00 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3072,8 +3072,6 @@ Address CodeGenFunction::EmitArrayToPointerDecay(const Expr *E, // Expressions of array type can't be bitfields or vector elements. LValue LV = EmitLValue(E); Address Addr = LV.getAddress(); - if (BaseInfo) *BaseInfo = LV.getBaseInfo(); - if (TBAAInfo) *TBAAInfo = LV.getTBAAInfo(); // If the array type was an incomplete type, we need to make sure // the decay ends up being the right type. @@ -3088,7 +3086,15 @@ Address CodeGenFunction::EmitArrayToPointerDecay(const Expr *E, Addr = Builder.CreateStructGEP(Addr, 0, CharUnits::Zero(), "arraydecay"); } + // The result of this decay conversion points to an array element within the + // base lvalue. However, since TBAA currently does not support representing + // accesses to elements of member arrays, we conservatively represent accesses + // to the pointee object as if it had no any base lvalue specified. + // TODO: Support TBAA for member arrays. QualType EltType = E->getType()->castAsArrayTypeUnsafe()->getElementType(); + if (BaseInfo) *BaseInfo = LV.getBaseInfo(); + if (TBAAInfo) *TBAAInfo = CGM.getTBAAAccessInfo(EltType); + return Builder.CreateElementBitCast(Addr, ConvertTypeForMem(EltType)); } |

