[PATCH] D45122: [DebugInfo] Add a new DI flag to record if a C++ record is a trivial type

Aaron Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 31 08:17:39 PDT 2018


asmith created this revision.
asmith added reviewers: rnk, zturner, llvm-commits.
Herald added subscribers: JDevlieghere, aprantl.

This flag is only used when emitting Codeview debug info and is needed to initialize subprogram and member function attributes (function options) which are Codeview specific. These function options are used to create an accurate compiler type for UDT symbols (class/struct/union) when parsing the symbols in a PDB.

It is not easy to determine if a C++ record is trivial or not based on the current DICompositeType flags and other accessible debug information from Codeview. For example, without this flag the metadata for a non-trivial C++ record with user-defined ctor and a trivial one with a defaulted ctor are the same.

  struct S { S(); }
  struct S { S() = default; }

Therefore, we introduce this new DI flag and corresponding clang::CXXRecordDecl::isTrivial method to set the flag in the frontend.


Repository:
  rL LLVM

https://reviews.llvm.org/D45122

Files:
  llvm-c/DebugInfo.h
  llvm/IR/DebugInfoFlags.def


Index: llvm/IR/DebugInfoFlags.def
===================================================================
--- llvm/IR/DebugInfoFlags.def
+++ llvm/IR/DebugInfoFlags.def
@@ -45,7 +45,8 @@
 HANDLE_DI_FLAG((1 << 21), MainSubprogram)
 HANDLE_DI_FLAG((1 << 22), TypePassByValue)
 HANDLE_DI_FLAG((1 << 23), TypePassByReference)
-HANDLE_DI_FLAG((1 << 24), FixedEnum)
+HANDLE_DI_FLAG((1 << 24), Trivial)
+HANDLE_DI_FLAG((1 << 25), FixedEnum)
 
 // To avoid needing a dedicated value for IndirectVirtualBase, we use
 // the bitwise or of Virtual and FwdDecl, which does not otherwise
@@ -55,7 +56,7 @@
 #ifdef DI_FLAG_LARGEST_NEEDED
 // intended to be used with ADT/BitmaskEnum.h
 // NOTE: always must be equal to largest flag, check this when adding new flag
-HANDLE_DI_FLAG((1 << 24), Largest)
+HANDLE_DI_FLAG((1 << 25), Largest)
 #undef DI_FLAG_LARGEST_NEEDED
 #endif
 
Index: llvm-c/DebugInfo.h
===================================================================
--- llvm-c/DebugInfo.h
+++ llvm-c/DebugInfo.h
@@ -54,6 +54,7 @@
   LLVMDIFlagMainSubprogram = 1 << 21,
   LLVMDIFlagTypePassByValue = 1 << 22,
   LLVMDIFlagTypePassByReference = 1 << 23,
+  LLVMDIFlagTrivial = 1 << 24,
   LLVMDIFlagIndirectVirtualBase = (1 << 2) | (1 << 5),
   LLVMDIFlagAccessibility = LLVMDIFlagPrivate | LLVMDIFlagProtected |
                             LLVMDIFlagPublic,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45122.140540.patch
Type: text/x-patch
Size: 1346 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180331/cdc92510/attachment.bin>


More information about the llvm-commits mailing list