Displaying 2 results from an estimated 2 matches for "canwemallocwithsize".
2015 Apr 01
3
[LLVMdev] why we assume malloc() always returns a non-null pointer in instruction combing?
...thout -ffreestanding, user defined malloc/free
should be compatible with std library. It makes sense to me.
My point is, in std library, malloc is allowed to return null if this
malloc failed. Why compiler knows it must succeed at compile time? I
slightly modified the regression case,
define i1 @CanWeMallocWithSize(i32 a) {
; CHECK-LABEL: @foo(
; CHECK-NEXT: ret i1 false
%m = call i8* @malloc(i32 a)
%z = icmp eq i8* %m, null
call void @free(i8* %m)
ret i1 %z
}
It's possible that this function is used to detect whether the runtime
environment can malloc a block of memory with size a. Besides, this...
2015 Apr 01
2
[LLVMdev] why we assume malloc() always returns a non-null pointer in instruction combing?
Hi Mats,
I think Kevin's point is malloc can return 0, if malloc/free pair is
optimized way, the semantic of the original would be changed.
On the other hand, malloc/free are special functions, but programmers can
still define their own versions by not linking std library, so we must
assume malloc/free always have side-effect like other common functions,
unless we know we will link std