diff options
author | Ivan A. Kosarev <ikosarev@accesssoftek.com> | 2017-11-27 09:39:29 +0000 |
---|---|---|
committer | Ivan A. Kosarev <ikosarev@accesssoftek.com> | 2017-11-27 09:39:29 +0000 |
commit | 4e50e707bfd9aedb6cfda45b4a36089bd2086717 (patch) | |
tree | 273983365df3faa2184c3206f2e8963e6812c916 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | b833bf6ae14f55272c642a5d5200fabb9f29bf69 (diff) | |
download | bcm5719-llvm-4e50e707bfd9aedb6cfda45b4a36089bd2086717.tar.gz bcm5719-llvm-4e50e707bfd9aedb6cfda45b4a36089bd2086717.zip |
[CodeGen] Collect information about sizes of accesses and access types for TBAA
The information about access and type sizes is necessary for
producing TBAA metadata in the new size-aware format. With this
patch, D39955 and D39956 in place we should be able to change
CodeGenTBAA::createScalarTypeNode() and
CodeGenTBAA::getBaseTypeInfo() to generate metadata in the new
format under the -new-struct-path-tbaa command-line option. For
now, this new information remains unused.
Differential Revision: https://reviews.llvm.org/D40176
llvm-svn: 319012
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8d29022b96b..885d1e901b9 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -136,7 +136,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, const HeaderSearchOptions &HSO, // Enable TBAA unless it's suppressed. ThreadSanitizer needs TBAA even at O0. if (LangOpts.Sanitize.has(SanitizerKind::Thread) || (!CodeGenOpts.RelaxedAliasing && CodeGenOpts.OptimizationLevel > 0)) - TBAA.reset(new CodeGenTBAA(Context, VMContext, CodeGenOpts, getLangOpts(), + TBAA.reset(new CodeGenTBAA(Context, TheModule, CodeGenOpts, getLangOpts(), getCXXABI().getMangleContext())); // If debug info or coverage generation is enabled, create the CGDebugInfo @@ -579,13 +579,20 @@ llvm::MDNode *CodeGenModule::getTBAATypeInfo(QualType QTy) { } TBAAAccessInfo CodeGenModule::getTBAAAccessInfo(QualType AccessType) { - return TBAAAccessInfo(getTBAATypeInfo(AccessType)); + // Pointee values may have incomplete types, but they shall never be + // dereferenced. + if (AccessType->isIncompleteType()) + return TBAAAccessInfo::getIncompleteInfo(); + + uint64_t Size = Context.getTypeSizeInChars(AccessType).getQuantity(); + return TBAAAccessInfo(getTBAATypeInfo(AccessType), Size); } -TBAAAccessInfo CodeGenModule::getTBAAVTablePtrAccessInfo() { +TBAAAccessInfo +CodeGenModule::getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType) { if (!TBAA) return TBAAAccessInfo(); - return TBAA->getVTablePtrAccessInfo(); + return TBAA->getVTablePtrAccessInfo(VTablePtrType); } llvm::MDNode *CodeGenModule::getTBAAStructInfo(QualType QTy) { |