[LLVMdev] Unique shape and types
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed Jun 20 09:26:36 PDT 2007
Hi all,
In its implementation of types, LLVM only has one instance of a given
shape, mostly for type equality (and I suppose projects like pool
allocation requires it).
However, this leads to a somehow misleading bytecode representation. For
example, consider the C++ program compiled with llvm-g++:
class AAA {
int b;
};
class FFF {
int a;
};
extern int foo(AAA * aaa);
extern int bar(FFF * aaa);
This gets compiled to
%struct.AAA = type { i32 }
%struct.FFF = type { i32 }
declare i32 @foo(AAA*)(%struct.AAA*)
declare i32 @bar(FFF*)(%struct.AAA*)
This is misleading because the bytecode tells us the argument type of
bar is AAA. I suppose the name "@bar(FFF*)" helps the programmer finding
that bar takes actually a FFF struct pointer.
Is this a non-issue for LLVM? Are types just considered as layouts?
The issue I'm facing is object inheritance and how to find from a LLVM
type what types it inherits. Currently this can't be implemented in LLVM
and I need to implement a higher representation for types.
Best,
Nicolas
More information about the llvm-dev
mailing list