[LLVMdev] gcc like attributes and annotations

Jakob Praher jp at hapra.at
Fri Feb 24 04:03:17 PST 2006


hi all,

out of a matter of fact I am still using llvm version 1.5. I don't know
how 1.6 works in this matter.

When translating a complex c application to llvm bytecodes, some
semantics are lost:

Take for isntance the interesting attribute to put a variable in the
thread local data section (.tdata), this would be interesting to have in
llvm.

like in GCC you write:

int x __attribute__((section(".tdata")));

however the llvm bytecode (llvm-gcc -S) does not show anything like this
attribute.

There is this Annotable base class, which is used to annotate a
MachineFunction to a LLVM Function. Function support Annotable but
GlobalVariable as of 1.5 not.

I would generally be interested and could contribute to extending LLVM
by allowing more Annotatinons than currently possible.

Why not make things like Instructions Annotable too?
For instance pointer creating Instructions, like alloca, malloc, ..
would be nice if they could be Annotable and so one could add symbolic
information to the type beeing used.

For instance:

struct A {
   int x;
};

struct B {
   int y;
};

get mapped to the same type -> { int }

%struct.A = type { int }
%struct.B = type { int }

BTW: How would one generate a type alias like the above through the LLVM
API?

	Is there a Type like TypeAlias - I couldn't find one. Here I
	have no ability to set a name with a Type:

	vector< const Type * > tvec = { Type::IntTy };
	Type * ty = StructType::get( tvec );

	

But what I wanted to say is that they are the same type.
This structural type system (compared to nominal typesystems) is very
intersting and has good support for optimizations.

But sometimes it would be interesting to actually get symbol information
about a type beeing used, without the need for full featured debug
information ala DWARF.

This could be also solved by introducing Annotable.
For instance if the alloca/malloc/.. instruction would get an Anntation
about a symbolic type which could look like:

{ ("x",int) }

One could use the DEF/USE and operand information in the byte code to
know which symbolic field was accessed for instance through getelementptr.

I don't know how you feel about that, but I there would be many
circumstances where Annotations could help getting more information out
of the bytecode.

thanks in advance
-- Jakob




More information about the llvm-dev mailing list