[LLVMdev] Kinda noob questions
Judison
judison at gmail.com
Mon Mar 14 17:52:54 PDT 2011
Hi all,
I have 2 simple questions...
First, just for you to know, I'm making a compiler (kinda obvious) and the
language definition is mine, so there is no much constraint for me, it's
written in Java (it generates a .ll file as output) and it's just for fun by
now, maybe a serious project after I learn all the stuff needed...
and sorry bad english
1) I want to know if when I do this kind of thing:
entry:
%x = alloca i32
%y = alloca i32
... normal instructions...
other_block:
%z = alloca i32
....
br .... label %other_block
the stack "grows" when alloca is "called", or its the same as putting "%z =
alloca" in the beggining?
or... if alloca is in a loop, the stack grows every time it iterates??
2) does the LLVM optimizes this:
; this code (arg -> var) is very similar to what gcc generates
define void @foo(i32 %arg0) {
entry:
%var0 = alloca i32
store i32 %arg0, i32* var0
...
%x = load i32* %var0
....
; never more stores to %var0 or pass it to any function
}
to something like:
define void @foo(i32 arg0) {
entry:
; no alloca
....
%x = %arg0
....
}
does it???
I'm asking because I can check in my compiler if some arg is only readed or
if its used as a var before generate the IR, an then only create (alloca) a
%var if the arg is used for read-write :P (my language is "safe" (no
pointers))
If LLVM optimizes it, I'll let it... if not, I'll do this optimization
Thanks in advance :P
--
Judison
judison at gmail.com
"A wise man first thinks and then speaks and a fool speaks first and then
thinks." Imam Ali (as)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110314/1906fed8/attachment.html>
More information about the llvm-dev
mailing list