Hi all, I used to use llvm-g++ to transform C++ source to LLVM IR. Now I am trying to switch to using DragonEgg, but I faced some problems because of the way DragonEgg is naming types in the resulting IR file. An example: LLVM-GCC: %"struct.Vector<ARPResponder::Entry>" = type { %"struct.ARPResponder::Entry"*, i32, i32 } %"struct.Vector<String>" = type { %struct.String*, i32, i32 } %"struct.Vector<int>" = type { i32*, i32, i32 } DragonEgg: %struct.Vector = type { %struct.Entry*, i32, i32 } %2 = type { %struct.String*, i32, i32 } %3 = type { i32*, i32, i32 } With the LLVM-GCC version I could easily get type for "struct.Vector<String>". With the DragonEgg version I would need another mapping from that name to "2". The same problem can be seen with the "struct.ARPResponder::Entry" becoming just "struct.Entry". Is there a way to make DragonEgg name the types the same way LLVM-GCC does, preserving C++ naming a bit more? BR, Teemu
Anton Korobeynikov
2011-Apr-28 10:58 UTC
[LLVMdev] Naming of types by DragonEgg vs. LLVM-GCC
Hello> With the LLVM-GCC version I could easily get type for "struct.Vector<String>". With the > DragonEgg version I would need another mapping from that name to "2". The same problem > can be seen with the "struct.ARPResponder::Entry" becoming just "struct.Entry".This is pretty much expected.> Is there a way to make DragonEgg name the types the same way LLVM-GCC does, preserving > C++ naming a bit more?The naming of types is arbitrary, you should not rely on them at all. Use debug information if you really want to know the name of underlying type, etc. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Hi Teemu,> I used to use llvm-g++ to transform C++ source to LLVM IR. Now I am trying to > switch to using DragonEgg, but I faced some problems because of the way DragonEgg > is naming types in the resulting IR file. An example: > > LLVM-GCC: > > %"struct.Vector<ARPResponder::Entry>" = type { %"struct.ARPResponder::Entry"*, i32, i32 } > %"struct.Vector<String>" = type { %struct.String*, i32, i32 } > %"struct.Vector<int>" = type { i32*, i32, i32 } > > DragonEgg: > > %struct.Vector = type { %struct.Entry*, i32, i32 } > %2 = type { %struct.String*, i32, i32 } > %3 = type { i32*, i32, i32 } > > With the LLVM-GCC version I could easily get type for "struct.Vector<String>". With the > DragonEgg version I would need another mapping from that name to "2". The same problem > can be seen with the "struct.ARPResponder::Entry" becoming just "struct.Entry". > > Is there a way to make DragonEgg name the types the same way LLVM-GCC does, preserving > C++ naming a bit more?no, it is not possible. Modern gcc's have a special pass that destroys all language specific information, thus ensuring that the middle end is only using generic information and not accidentally using language specific stuff (this matters for link time optimization). The extra detail in type names produced by llvm-gcc comes from language specific data and has been destroyed in gcc-4.5 before reaching the dragonegg plugin. I suggest you use debug info instead. Ciao, Duncan.