diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-22 21:30:43 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-22 21:30:43 +0000 |
| commit | 1fa07ebd929383f769994818c3f8c55919bf0a0e (patch) | |
| tree | 1f68cf27e569af8a9ce77a0faaac3edfa641e60d /clang/lib | |
| parent | 780c374b2056afb5665377690183cdd50bf97f09 (diff) | |
| download | bcm5719-llvm-1fa07ebd929383f769994818c3f8c55919bf0a0e.tar.gz bcm5719-llvm-1fa07ebd929383f769994818c3f8c55919bf0a0e.zip | |
Fix TBAA representation for zero-sized fields and unnamed bit-fields.
Unnamed bit-fields should not be represented in the TBAA metadata
because they do not represent storage fields (they only affect layout).
Zero-sized fields should not be represented in the TBAA metadata
because by definition they have no associated storage (so we will never
emit a load or store through them), and they might not appear in
declaration order within the struct layout.
Fixes a verifier failure when emitting a TBAA-enabled load through a
class type containing a zero-sized field.
llvm-svn: 364140
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenTBAA.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp index a41cfcee4c2..09de9591de7 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.cpp +++ b/clang/lib/CodeGen/CodeGenTBAA.cpp @@ -257,6 +257,8 @@ CodeGenTBAA::CollectFields(uint64_t BaseOffset, unsigned idx = 0; for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end(); i != e; ++i, ++idx) { + if ((*i)->isZeroSize(Context) || (*i)->isUnnamedBitfield()) + continue; uint64_t Offset = BaseOffset + Layout.getFieldOffset(idx) / Context.getCharWidth(); QualType FieldQTy = i->getType(); @@ -297,6 +299,8 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeInfoHelper(const Type *Ty) { const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD); SmallVector<llvm::MDBuilder::TBAAStructField, 4> Fields; for (FieldDecl *Field : RD->fields()) { + if (Field->isZeroSize(Context) || Field->isUnnamedBitfield()) + continue; QualType FieldQTy = Field->getType(); llvm::MDNode *TypeNode = isValidBaseType(FieldQTy) ? getBaseTypeInfo(FieldQTy) : getTypeInfo(FieldQTy); |

