[PATCH] D25621: DebugInfo: use DIAlignment type.
vleschuk updated this revision to Diff 74899. vleschuk added a comment. - Use uint32_t directly for alignment instead of creating typedef ofr it - Get rid of DebugInfo dependency in AST https://reviews.llvm.org/D25621 Files: include/clang/AST/ASTContext.h include/clang/AST/DeclBase.h lib/AST/DeclBase.cpp lib/CodeGen/CGDebugInfo.cpp Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -596,7 +596,7 @@ } // Bit size, align and offset of the type. uint64_t Size = CGM.getContext().getTypeSize(BT); - uint64_t Align = CGM.getContext().getTypeAlign(BT); + auto Align = CGM.getContext().getTypeAlign(BT); return DBuilder.createBasicType(BTName, Size, Align, Encoding); } @@ -607,7 +607,7 @@ Encoding = llvm::dwarf::DW_ATE_lo_user; uint64_t Size = CGM.getContext().getTypeSize(Ty); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + auto Align = CGM.getContext().getTypeAlign(Ty); return DBuilder.createBasicType("complex", Size, Align, Encoding); } @@ -721,7 +721,7 @@ StringRef RDName = getClassName(RD); uint64_t Size = 0; - uint64_t Align = 0; + uint32_t Align = 0; const RecordDecl *D = RD->getDefinition(); if (D && D->isCompleteDefinition()) { @@ -749,7 +749,7 @@ // because that does not return the correct value for references. unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy); uint64_t Size = CGM.getTarget().getPointerWidth(AS); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + auto Align = CGM.getContext().getTypeAlign(Ty); if (Tag == llvm::dwarf::DW_TAG_reference_type || Tag == llvm::dwarf::DW_TAG_rvalue_reference_type) @@ -776,7 +776,7 @@ SmallVector EltTys; QualType FType; uint64_t FieldSize, FieldOffset; - unsigned FieldAlign; + uint32_t FieldAlign; llvm::DINodeArray Elements; FieldOffset = 0; @@ -965,7 +965,7 @@ CGM.getTypes().getCGRecordLayout(RD).getBitFieldInfo(BitFieldDecl); uint64_t SizeInBits = BitFieldInfo.Size; assert(SizeInBits > 0 && "found named 0-width bitfield"); - unsigned AlignInBits = CGM.getContext().getTypeAlign(Ty); + auto AlignInBits = CGM.getContext().getTypeAlign(Ty); uint64_t StorageOffsetInBits = CGM.getContext().toBits(BitFieldInfo.StorageOffset); uint64_t OffsetInBits = StorageOffsetInBits + BitFieldInfo.Offset; @@ -987,7 +987,7 @@ unsigned line = getLineNumber(loc); uint64_t SizeInBits = 0; - unsigned AlignInBits = 0; + uint32_t AlignInBits = 0; if (!type->isIncompleteArrayType()) { TypeInfo TI = CGM.getContext().getTypeInfo(type); SizeInBits = TI.Width; @@ -1181,7 +1181,7 @@ QualType PointeeTy = ThisPtrTy->getPointeeType(); unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy); uint64_t Size = CGM.getTarget().getPointerWidth(AS); -uint64_t Align = CGM.getContext().getTypeAlign(ThisPtrTy); +auto Align = CGM.getContext().getTypeAlign(ThisPtrTy); llvm::DIType *PointeeType = getOrCreateType(PointeeTy, Unit); llvm::DIType *ThisPtrType = DBuilder.createPointerType(PointeeType, Size, Align); @@ -1968,7 +1968,7 @@ // Bit size, align and offset of the type. uint64_t Size = CGM.getContext().getTypeSize(Ty); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + auto Align = CGM.getContext().getTypeAlign(Ty); llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero; if (ID->getImplementation()) @@ -2052,7 +2052,7 @@ unsigned FieldLine = getLineNumber(Field->getLocation()); QualType FType = Field->getType(); uint64_t FieldSize = 0; -unsigned FieldAlign = 0; +uint32_t FieldAlign = 0; if (!FType->isIncompleteArrayType()) { @@ -2134,14 +2134,14 @@ llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript); uint64_t Size = CGM.getContext().getTypeSize(Ty); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + auto Align = CGM.getContext().getTypeAlign(Ty); return DBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray); } llvm::DIType *CGDebugInfo::CreateType(const ArrayType *Ty, llvm::DIFile *Unit) { uint64_t Size; - uint64_t Align; + uint32_t Align; // FIXME: make getTypeAlign() aware of VLAs and incomplete array types if (const auto *VAT = dyn_cast(Ty)) { @@ -2264,7 +2264,7 @@ const EnumDecl *ED = Ty->getDecl(); uint64_t Size = 0; - uint64_t Align = 0; + uint32_t Align = 0; if (!ED->getTypeForDecl()->isIncompleteType()) { Size = CGM.getContext().getTypeSize(ED->getTypeForDecl()); Align = CGM.getContext().getTypeAlign(ED->getTypeForDecl()); @@ -2307,7 +2307,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) { const EnumDecl *ED = Ty->getDecl(); uint64_t Size = 0; - uint64_t Align = 0; + uint32_t Align = 0; if (!ED->getTypeForDecl()->isIncompleteType()) { Size =
[PATCH] D25621: DebugInfo: use DIAlignment type.
vleschuk marked an inline comment as done. vleschuk added inline comments. Comment at: include/clang/AST/ASTContext.h:83 uint64_t Width; -unsigned Align; +llvm::DIAlignment Align; bool AlignIsRequired : 1; vleschuk wrote: > aprantl wrote: > > I'm not sure we want to use a debug info type inside the AST. I think we > > only want to use them in CGDebugInfo.cpp. > We use TypeInfo and related functions heavily in CGDebugInfo.cpp, leaving > this field as "unsigned" will make us to perform conversions from "unsigned" > to llvm::DIAlignment, I think having this changed will result in simpler code. @dblaikie wrote: > It'd still be a layering violation to have AST depend on debug info > types/concepts. If it makes sense to change it to uint32_t in AST, that'd > probably be reasonable. We are discussing the possibility of changing this to "unsigned" in https://reviews.llvm.org/D25620, after we come to consensus I'll update both patches. Thanks for the advice, I agree that using DebugInfo types in AST was a bad idea. https://reviews.llvm.org/D25621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D25621: DebugInfo: use DIAlignment type.
On Mon, Oct 17, 2016 at 4:37 AM Victor Leschukwrote: > vleschuk marked an inline comment as done. > vleschuk added inline comments. > > > > Comment at: include/clang/AST/ASTContext.h:83 > uint64_t Width; > -unsigned Align; > +llvm::DIAlignment Align; > bool AlignIsRequired : 1; > > aprantl wrote: > > I'm not sure we want to use a debug info type inside the AST. I think we > only want to use them in CGDebugInfo.cpp. > We use TypeInfo and related functions heavily in CGDebugInfo.cpp, leaving > this field as "unsigned" will make us to perform conversions from > "unsigned" to llvm::DIAlignment, I think having this changed will result in > simpler code. > It'd still be a layering violation to have AST depend on debug info types/concepts. If it makes sense to change it to uint32_t in AST, that'd probably be reasonable. - Dave > > > https://reviews.llvm.org/D25621 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25621: DebugInfo: use DIAlignment type.
vleschuk marked an inline comment as done. vleschuk added inline comments. Comment at: include/clang/AST/ASTContext.h:83 uint64_t Width; -unsigned Align; +llvm::DIAlignment Align; bool AlignIsRequired : 1; aprantl wrote: > I'm not sure we want to use a debug info type inside the AST. I think we only > want to use them in CGDebugInfo.cpp. We use TypeInfo and related functions heavily in CGDebugInfo.cpp, leaving this field as "unsigned" will make us to perform conversions from "unsigned" to llvm::DIAlignment, I think having this changed will result in simpler code. https://reviews.llvm.org/D25621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25621: DebugInfo: use DIAlignment type.
aprantl added inline comments. Comment at: include/clang/AST/ASTContext.h:83 uint64_t Width; -unsigned Align; +llvm::DIAlignment Align; bool AlignIsRequired : 1; I'm not sure we want to use a debug info type inside the AST. I think we only want to use them in CGDebugInfo.cpp. https://reviews.llvm.org/D25621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25621: DebugInfo: use DIAlignment type.
vleschuk created this revision. vleschuk added reviewers: aprantl, mehdi_amini, dblaikie, echristo. vleschuk added a subscriber: cfe-commits. Use DIAlignment type introduced in https://reviews.llvm.org/D25620 https://reviews.llvm.org/D25621 Files: include/clang/AST/ASTContext.h include/clang/AST/DeclBase.h lib/AST/DeclBase.cpp lib/CodeGen/CGDebugInfo.cpp Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -596,7 +596,7 @@ } // Bit size, align and offset of the type. uint64_t Size = CGM.getContext().getTypeSize(BT); - uint64_t Align = CGM.getContext().getTypeAlign(BT); + llvm::DIAlignment Align = CGM.getContext().getTypeAlign(BT); return DBuilder.createBasicType(BTName, Size, Align, Encoding); } @@ -607,7 +607,7 @@ Encoding = llvm::dwarf::DW_ATE_lo_user; uint64_t Size = CGM.getContext().getTypeSize(Ty); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + llvm::DIAlignment Align = CGM.getContext().getTypeAlign(Ty); return DBuilder.createBasicType("complex", Size, Align, Encoding); } @@ -721,7 +721,7 @@ StringRef RDName = getClassName(RD); uint64_t Size = 0; - uint64_t Align = 0; + llvm::DIAlignment Align = 0; const RecordDecl *D = RD->getDefinition(); if (D && D->isCompleteDefinition()) { @@ -749,7 +749,7 @@ // because that does not return the correct value for references. unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy); uint64_t Size = CGM.getTarget().getPointerWidth(AS); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + llvm::DIAlignment Align = CGM.getContext().getTypeAlign(Ty); if (Tag == llvm::dwarf::DW_TAG_reference_type || Tag == llvm::dwarf::DW_TAG_rvalue_reference_type) @@ -1181,7 +1181,7 @@ QualType PointeeTy = ThisPtrTy->getPointeeType(); unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy); uint64_t Size = CGM.getTarget().getPointerWidth(AS); -uint64_t Align = CGM.getContext().getTypeAlign(ThisPtrTy); +llvm::DIAlignment Align = CGM.getContext().getTypeAlign(ThisPtrTy); llvm::DIType *PointeeType = getOrCreateType(PointeeTy, Unit); llvm::DIType *ThisPtrType = DBuilder.createPointerType(PointeeType, Size, Align); @@ -1968,12 +1968,12 @@ // Bit size, align and offset of the type. uint64_t Size = CGM.getContext().getTypeSize(Ty); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + llvm::DIAlignment Align = CGM.getContext().getTypeAlign(Ty); llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero; if (ID->getImplementation()) Flags |= llvm::DINode::FlagObjcClassComplete; - + llvm::DIScope *Mod = getParentModuleOrNull(ID); llvm::DICompositeType *RealDecl = DBuilder.createStructType( Mod ? Mod : Unit, ID->getName(), DefUnit, Line, Size, Align, Flags, @@ -2134,14 +2134,14 @@ llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript); uint64_t Size = CGM.getContext().getTypeSize(Ty); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + llvm::DIAlignment Align = CGM.getContext().getTypeAlign(Ty); return DBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray); } llvm::DIType *CGDebugInfo::CreateType(const ArrayType *Ty, llvm::DIFile *Unit) { uint64_t Size; - uint64_t Align; + llvm::DIAlignment Align; // FIXME: make getTypeAlign() aware of VLAs and incomplete array types if (const auto *VAT = dyn_cast(Ty)) { @@ -2264,7 +2264,7 @@ const EnumDecl *ED = Ty->getDecl(); uint64_t Size = 0; - uint64_t Align = 0; + llvm::DIAlignment Align = 0; if (!ED->getTypeForDecl()->isIncompleteType()) { Size = CGM.getContext().getTypeSize(ED->getTypeForDecl()); Align = CGM.getContext().getTypeAlign(ED->getTypeForDecl()); @@ -2307,7 +2307,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) { const EnumDecl *ED = Ty->getDecl(); uint64_t Size = 0; - uint64_t Align = 0; + llvm::DIAlignment Align = 0; if (!ED->getTypeForDecl()->isIncompleteType()) { Size = CGM.getContext().getTypeSize(ED->getTypeForDecl()); Align = CGM.getContext().getTypeAlign(ED->getTypeForDecl()); @@ -2607,7 +2607,7 @@ return getOrCreateRecordFwdDecl(Ty, RDContext); uint64_t Size = CGM.getContext().getTypeSize(Ty); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + llvm::DIAlignment Align = CGM.getContext().getTypeAlign(Ty); SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU); Index: lib/AST/DeclBase.cpp === --- lib/AST/DeclBase.cpp +++ lib/AST/DeclBase.cpp @@ -327,11 +327,11 @@ return getASTContext().getASTMutationListener(); } -unsigned Decl::getMaxAlignment() const { +llvm::DIAlignment Decl::getMaxAlignment() const { if (!hasAttrs()) return 0; - unsigned Align = 0; + llvm::DIAlignment Align = 0; const