Hi, I'm writing a frontend and I'd like to be able to provide names to struct types that mirror the names of the classes in the source language. Unfortunately, some of these generated structs are sometimes identical for distinct classes, and so LLVM forces them to have the same type and same name. This makes debugging kind of confusing. Is there some way to get the behavior I want without having to add bogus extra components to my structs to distinguish them? Thanks, Ben
I think you'd have to change VMCore to make that happen and it could cause problems with linking, etc. LLVM counts structurally equivalent types as identical and I think violating that premise would break things. This is probably a question best answered by Chris. He'll be back tomorrow. Reid. On Wed, 2005-01-26 at 11:10, Ben Payne wrote:> Hi, > > I'm writing a frontend and I'd like to be able to provide > names to struct types that mirror the names of the classes in > the source language. Unfortunately, some of these generated > structs are sometimes identical for distinct classes, and so > LLVM forces them to have the same type and same name. > > This makes debugging kind of confusing. Is there some way to > get the behavior I want without having to add bogus extra > components to my structs to distinguish them? > > Thanks, > Ben > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050126/005dbdaf/attachment.sig>
LLVM uses structural equivalence to distinguish types, so there's no direct way to retain multiple types with identical contents. The C++ front-end generates a single struct for two such classes, and simply initializes their vtables differently to get the right function pointers. You would need some hack like you said to create distinct structs, which may be ok if you use it only for debugging. (For those who are interested, this is a technical limitation because we lose some precision in analyses like pointer analysis, compared with a compiler that tracked distinct source types.) --Vikram http://www.cs.uiuc.edu/~vadve http://llvm.cs.uiuc.edu/ On Jan 26, 2005, at 1:10 PM, Ben Payne wrote:> Hi, > > I'm writing a frontend and I'd like to be able to provide > names to struct types that mirror the names of the classes in > the source language. Unfortunately, some of these generated > structs are sometimes identical for distinct classes, and so > LLVM forces them to have the same type and same name. > > This makes debugging kind of confusing. Is there some way to > get the behavior I want without having to add bogus extra > components to my structs to distinguish them? > > Thanks, > Ben > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: text/enriched Size: 1437 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050126/fabe8253/attachment.bin>
On Wednesday 26 January 2005 13:10, Ben Payne wrote:> Hi, > > I'm writing a frontend and I'd like to be able to provide > names to struct types that mirror the names of the classes in > the source language. Unfortunately, some of these generated > structs are sometimes identical for distinct classes, and so > LLVM forces them to have the same type and same name. > > This makes debugging kind of confusing. Is there some way to > get the behavior I want without having to add bogus extra > components to my structs to distinguish them?Currently there is not, as LLVM distinguishes types using structural equivalence. This is a problem the C++ and Java frontends face as well. -- Alkis
On Wed, 26 Jan 2005, Vikram Adve wrote:> LLVM uses structural equivalence to distinguish types, so there's no direct > way to retain multiple types with identical contents. The C++ front-end > generates a single struct for two such classes, and simply initializes their > vtables differently to get the right function pointers. You would need some > hack like you said to create distinct structs, which may be ok if you use it > only for debugging.Yup, as others have said, there isn't a great way to do this. The basic deal is that names in LLVM (except for globals) are purely "best effort to make compiler debugging easier", they have no guarantees.> (For those who are interested, this is a technical limitation because we lose > some precision in analyses like pointer analysis, compared with a compiler > that tracked distinct source types.)Hrm, that issue is much bigger than just structural vs named equivalence, but I guess it is tangentially related. -Chris> --Vikram > http://www.cs.uiuc.edu/~vadve > http://llvm.cs.uiuc.edu/ > > On Jan 26, 2005, at 1:10 PM, Ben Payne wrote: > >> Hi, >> >> I'm writing a frontend and I'd like to be able to provide >> names to struct types that mirror the names of the classes in >> the source language. Unfortunately, some of these generated >> structs are sometimes identical for distinct classes, and so >> LLVM forces them to have the same type and same name. >> >> This makes debugging kind of confusing. Is there some way to >> get the behavior I want without having to add bogus extra >> components to my structs to distinguish them? >> >> Thanks, >> Ben >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >-Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/