David Meyer
2011-Jan-28 20:58 UTC
[LLVMdev] Call to non-constant memset() being generated where libc is not available
I am compiling something without standard libraries, including no libc. Somehow, this bitcode is being generated by plain array manipulation code: %12 = add i8 %11, -19 %tmp35 = icmp sgt i32 %9, 1 %smax36 = select i1 %tmp35, i32 %9, i32 1 call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([100 x i8]* @global_array_char, i32 0, i32 0), i8 %12, i32 %smax36, i32 1, i1 false) (global_array_char is an array of length 100, which only partially gets used.) This gets lowered by LLC to a library call to memset(), which cannot be satisfied. Any advice? Thanks, David Meyer -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110128/ec5ad6c5/attachment.html>
Duncan Sands
2011-Jan-29 11:24 UTC
[LLVMdev] Call to non-constant memset() being generated where libc is not available
Hi David,> I am compiling something without standard libraries, including no libc.compile with -fno-builtin That said, note that GCC for example requires memset to be available even in a freestanding environment. Ciao, Duncan.> > Somehow, this bitcode is being generated by plain array manipulation code: > > %12 = add i8 %11, -19 > %tmp35 = icmp sgt i32 %9, 1 > %smax36 = select i1 %tmp35, i32 %9, i32 1 > call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([100 x i8]* > @global_array_char, i32 0, i32 0), i8 %12, i32 %smax36, i32 1, i1 false) > > (global_array_char is an array of length 100, which only partially gets used.) > > This gets lowered by LLC to a library call to memset(), which cannot be satisfied. > > Any advice? > > Thanks, > David Meyer > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Nick Lewycky
2011-Jan-31 07:20 UTC
[LLVMdev] Call to non-constant memset() being generated where libc is not available
David Meyer wrote:> I am compiling something without standard libraries, including no libc. > > Somehow, this bitcode is being generated by plain array manipulation code: > > %12 = add i8 %11, -19 > %tmp35 = icmp sgt i32 %9, 1 > %smax36 = select i1 %tmp35, i32 %9, i32 1 > call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([100 x > i8]* @global_array_char, i32 0, i32 0), i8 %12, i32 %smax36, i32 1, i1 > false) > > (global_array_char is an array of length 100, which only partially gets > used.)That's not quite enough to go on. What's the original code, and what is this? Are we looking at an array initialization here?> This gets lowered by LLC to a library call to memset(), which cannot be > satisfied. > > Any advice?As Duncan pointed out, memset may be generated as part of the ABI even in a freestanding (ie., no libc) environment. I think memcpy is in the same boat. If you have a different target with a different ABI that doesn't provide memset/memcpy, you could try writing your own generic lowering in Target/X86. Or you could always link against something native that provides memset/memcpy, which is what I strongly recommend.> Thanks, > David Meyer > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Jason Kim
2011-Feb-03 01:57 UTC
[LLVMdev] Call to non-constant memset() being generated where libc is not available
On Sun, Jan 30, 2011 at 11:20 PM, Nick Lewycky <nicholas at mxc.ca> wrote:> David Meyer wrote: >> I am compiling something without standard libraries, including no libc. >> >> Somehow, this bitcode is being generated by plain array manipulation code: >> >> %12 = add i8 %11, -19 >> %tmp35 = icmp sgt i32 %9, 1 >> %smax36 = select i1 %tmp35, i32 %9, i32 1 >> call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([100 x >> i8]* @global_array_char, i32 0, i32 0), i8 %12, i32 %smax36, i32 1, i1 >> false) >> >> (global_array_char is an array of length 100, which only partially gets >> used.) > > That's not quite enough to go on. What's the original code, and what is > this? Are we looking at an array initialization here? > >> This gets lowered by LLC to a library call to memset(), which cannot be >> satisfied. >> >> Any advice?Pdox, is this happening on ARM as well?> > As Duncan pointed out, memset may be generated as part of the ABI even > in a freestanding (ie., no libc) environment. I think memcpy is in the > same boat.> > If you have a different target with a different ABI that doesn't provide > memset/memcpy, you could try writing your own generic lowering in > Target/X86. Or you could always link against something native that > provides memset/memcpy, which is what I strongly recommend. > >> Thanks, >> David Meyer
Apparently Analagous Threads
- [LLVMdev] Call to non-constant memset() being generated where libc is not available
- [LLVMdev] bitcast function calls
- [RFC][clang/llvm] Allow efficient implementation of libc's memory functions in C/C++
- [LLVMdev] spilling & xmm register usage
- [LLVMdev] "-march" trashing ARM triple