[LLVMdev] Alias Analysis: zero terminated strings

Carl-Philip Hänsch cphaensch at googlemail.com
Mon Sep 12 06:57:42 PDT 2011


I'm developing a programming language that is optimized for strings. A first
hello world program shows me that llvm needs a lot more work on zero
terminated strings.
In the following example, I have an auto generated hello world example
optimized with -O3. The problem is, that the constant string is copied into
a malloced mem area, then puts is called and then the memory is freed. There
is also some leftover from the reference counters. These are found by the
dead code eliminaton after the puts call. But before the puts call, the
constant folded number is put into the memory and is never used. I was told
that llvm assumes that a function also can read below the pointer, so dead
code elimination does not work here. The second thing i would like to have
there is to tell LLVM that the interesting memory ends after the zero
termination. I think these two flags: dont_read_below and
dont_read_above_zero should be enough to make LLVM optimze that example.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110912/a990e36f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.ll
Type: application/octet-stream
Size: 1228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110912/a990e36f/attachment.obj>

More information about the llvm-dev mailing list