search for: dontescap

Displaying 4 results from an estimated 4 matches for "dontescap".

Did you mean: dontescape
2010 Jul 12
3
[LLVMdev] Promoting malloc to alloca
...or basically all data. I was rather hoping that these mallocs would be converted to allocas if the pointers didn't escape. This would require an escape analysis, and I'm not sure if LLVM has such a thing. For instance, consider this code (typical of the output of my compiler): define i32 @dontescape(i32 %x) { entry:   %t = tail call i8* @malloc(i32 4)   %t1 = bitcast i8* %t to i32*   store i32 %x, i32* %t1   %t2 = load i32* %t1   ret i32 %t2 } Running with opt --std-compile-opts, LLVM is smart enough to figure out that the result is actually %x. So it generates: define i32 @dontescape(i32 %...
2010 Jul 12
0
[LLVMdev] Promoting malloc to alloca
...rather hoping that these mallocs would be > converted to allocas if the pointers didn't escape. This would require > an escape analysis, and I'm not sure if LLVM has such a thing. > > For instance, consider this code (typical of the output of my compiler): > > define i32 @dontescape(i32 %x) { > entry: > %t = tail call i8* @malloc(i32 4) > %t1 = bitcast i8* %t to i32* > store i32 %x, i32* %t1 > %t2 = load i32* %t1 > ret i32 %t2 > } When do you free it? Why not just use an alloca? > Running with opt --std-compile-opts, LLVM is smart enou...
2010 Jul 13
3
[LLVMdev] Promoting malloc to alloca
...cas. Now I can see why LLVM doesn't do this -- it would be unsafe in general. In my language (and many other high-level garbage-collected languages which don't generate free() calls), it would be useful, but LLVM itself can't guarantee that it's safe. >> >> define i32 @dontescape(i32 %x) { >> entry: >>   %t = tail call i8* @malloc(i32 4) >>   %t1 = bitcast i8* %t to i32* >>   store i32 %x, i32* %t1 >>   %t2 = load i32* %t1 >>   ret i32 %t2 >> } > > When do you free it? Why not just use an alloca? Well I can't use an allo...
2010 Jul 13
0
[LLVMdev] Promoting malloc to alloca
...M doesn't do this -- it would be unsafe in > general. In my language (and many other high-level garbage-collected > languages which don't generate free() calls), it would be useful, but > LLVM itself can't guarantee that it's safe. > >>> >>> define i32 @dontescape(i32 %x) { >>> entry: >>> %t = tail call i8* @malloc(i32 4) >>> %t1 = bitcast i8* %t to i32* >>> store i32 %x, i32* %t1 >>> %t2 = load i32* %t1 >>> ret i32 %t2 >>> } >> >> When do you free it? Why not just use...