[PATCH] D40176: [CodeGen] Collect information about sizes of accesses and access types for TBAA

Ivan Kosarev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 22 01:58:51 PST 2017


kosarev added inline comments.


================
Comment at: lib/CodeGen/CGClass.cpp:2426
   llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField);
-  CGM.DecorateInstructionWithTBAA(Store, CGM.getTBAAVTablePtrAccessInfo());
+  TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy);
+  CGM.DecorateInstructionWithTBAA(Store, TBAAInfo);
----------------
Now that type and access descriptors include information about sizes, the function needs to know the type of the virtual table pointer to access.


================
Comment at: lib/CodeGen/CodeGenModule.cpp:139
       (!CodeGenOpts.RelaxedAliasing && CodeGenOpts.OptimizationLevel > 0))
-    TBAA.reset(new CodeGenTBAA(Context, VMContext, CodeGenOpts, getLangOpts(),
+    TBAA.reset(new CodeGenTBAA(Context, TheModule, CodeGenOpts, getLangOpts(),
                                getCXXABI().getMangleContext()));
----------------
To clarify why we pass the module instead of LLVM context: we need it to compute the size of virtual table pointers as their types are llvm::Type types and not clang::Type or QualType ones.


================
Comment at: lib/CodeGen/CodeGenModule.cpp:585
+  if (AccessType->isIncompleteType())
+    return TBAAAccessInfo::getIncompleteInfo();
+
----------------
getAccessTagInfo() will raise an assertion failure if such an access descriptor is passed to it. This way we explicitly claim that generating access tags for incomplete objects is not allowed.


Repository:
  rL LLVM

https://reviews.llvm.org/D40176





More information about the cfe-commits mailing list