[PATCH] D14933: Add the allocsize attribute to LLVM
Ahmed Bougacha via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 16 17:18:24 PST 2016
ab added a subscriber: ab.
ab added a comment.
http://reviews.llvm.org/D16390 is indeed quite repulsive; what do you think of annotating the callsites instead?
It does increase bitcode size, but perhaps something like this would feel more natural:
define i8* @checked_malloc(i32 %N) {
%1 = call i8* @object_malloc(i32 %N)
%2 = call i32 @llvm.objectsize.i32.p0i8(i8* %1)
%max = add i32 %N, 8
%c = icmp ule %max, %2
call void @llvm.assume(i1 %c)
%3 = icmp lt %2, %N
br i1 %3, label %Trap, label %Return
...
}
You could also introduce dedicated intrinsics (and maybe even wrap the calls with them, to make the lookup trivial).
http://reviews.llvm.org/D14933
More information about the llvm-commits
mailing list