On Wed, Sep 23, 2009 at 2:27 PM, Talin <viridia at gmail.com> wrote:> On Wed, Sep 23, 2009 at 1:51 PM, Dan Gohman <gohman at apple.com> wrote: >> >> On Sep 22, 2009, at 4:49 PM, Talin wrote: >>> >>> // Calculate the size of the specified LLVM type. >>> Constant * DebugInfoBuilder::getSize(const Type * type) { >>> Constant * one = ConstantInt::get(Type::Int32Ty, 1); >>> return ConstantExpr::getPtrToInt( >>> ConstantExpr::getGetElementPtr( >>> ConstantPointerNull::get(PointerType::getUnqual(type)), >>> &one, 1), Type::Int32Ty); >>> } >>> >>> Constant * DebugInfoBuilder::getAlignment(const Type * type) { >>> // Calculates the alignment of T using "sizeof({i8, T}) - sizeof(T)" >>> return ConstantExpr::getSub( >>> getSize(StructType::get(Type::Int8Ty, type, NULL)), >>> getSize(type)); >>> } >> >> Are ConstantExpr::getAlignOf, getSizeOf, and getOffsetOf what >> you're looking for? >> > That will work. Now all I need is for the methods of DIFactory to take a > Constant* instead of uint64.ok. Feel free to add /// CreateBasicType - Create a basic type like int, float, etc. DIBasicType CreateBasicType(DIDescriptor Context, const std::string &Name, DICompileUnit CompileUnit, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, unsigned Encoding); variants that take Constant*, for example, /// CreateBasicType - Create a basic type like int, float, etc. DIBasicType CreateBasicType(DIDescriptor Context, const std::string &Name, DICompileUnit CompileUnit, unsigned LineNumber, Constant *SizeInBits, Constant *AlignInBits, Constant *OffsetInBits, unsigned Flags, unsigned Encoding); and so on. - Devang
Here is a patch that does just that. On Wed, Sep 23, 2009 at 3:38 PM, Devang Patel <devang.patel at gmail.com>wrote:> On Wed, Sep 23, 2009 at 2:27 PM, Talin <viridia at gmail.com> wrote: > > On Wed, Sep 23, 2009 at 1:51 PM, Dan Gohman <gohman at apple.com> wrote: > >> > >> On Sep 22, 2009, at 4:49 PM, Talin wrote: > >>> > >>> // Calculate the size of the specified LLVM type. > >>> Constant * DebugInfoBuilder::getSize(const Type * type) { > >>> Constant * one = ConstantInt::get(Type::Int32Ty, 1); > >>> return ConstantExpr::getPtrToInt( > >>> ConstantExpr::getGetElementPtr( > >>> ConstantPointerNull::get(PointerType::getUnqual(type)), > >>> &one, 1), Type::Int32Ty); > >>> } > >>> > >>> Constant * DebugInfoBuilder::getAlignment(const Type * type) { > >>> // Calculates the alignment of T using "sizeof({i8, T}) - sizeof(T)" > >>> return ConstantExpr::getSub( > >>> getSize(StructType::get(Type::Int8Ty, type, NULL)), > >>> getSize(type)); > >>> } > >> > >> Are ConstantExpr::getAlignOf, getSizeOf, and getOffsetOf what > >> you're looking for? > >> > > That will work. Now all I need is for the methods of DIFactory to take a > > Constant* instead of uint64. > > ok. Feel free to add > /// CreateBasicType - Create a basic type like int, float, etc. > DIBasicType CreateBasicType(DIDescriptor Context, const std::string > &Name, > DICompileUnit CompileUnit, unsigned > LineNumber, > uint64_t SizeInBits, uint64_t AlignInBits, > uint64_t OffsetInBits, unsigned Flags, > unsigned Encoding); > > variants that take Constant*, for example, > > /// CreateBasicType - Create a basic type like int, float, etc. > DIBasicType CreateBasicType(DIDescriptor Context, const std::string > &Name, > DICompileUnit CompileUnit, unsigned > LineNumber, > Constant *SizeInBits, Constant *AlignInBits, > Constant *OffsetInBits, unsigned Flags, > unsigned Encoding); > > and so on. > - > Devang >-- -- Talin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091001/b01836fa/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: debug_constants.patch Type: application/octet-stream Size: 7712 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091001/b01836fa/attachment.obj>
On Thu, Oct 1, 2009 at 8:34 PM, Talin <viridia at gmail.com> wrote:> Here is a patch that does just that.This does not work. I'm getting llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp: In member function ‘llvm::DIType clang::CodeGen::CGDebugInfo::CreateQualifiedType(clang::QualType, llvm::DICompileUnit)’: /Users/yash/clean/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:225: error: call of overloaded ‘CreateDerivedType(unsigned int&, llvm::DICompileUnit&, const char [1], llvm::DICompileUnit, int, int, int, int, int, llvm::DIType&)’ is ambiguous llvm/include/llvm/Analysis/DebugInfo.h:530: note: candidates are: llvm::DIDerivedType llvm::DIFactory::CreateDerivedType(unsigned int, llvm::DIDescriptor, llvm::StringRef, llvm::DICompileUnit, unsigned int, uint64_t, uint64_t, uint64_t, unsigned int, llvm::DIType) llvm/include/llvm/Analysis/DebugInfo.h:540: note: llvm::DIDerivedType llvm::DIFactory::CreateDerivedType(unsigned int, llvm::DIDescriptor, const std::string&, llvm::DICompileUnit, unsigned int, llvm::Constant*, llvm::Constant*, llvm::Constant*, unsigned int, llvm::DIType) - Devang