Skip to content

llvm pass looking for unneeded malloc(9) return value checks

Notifications You must be signed in to change notification settings

roachspray/mwaitok-unneeded-rv-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llvm pass to look for the following pattern:

foo = malloc(..., M_WAITOK)
if (foo == NULL) {
 ...
}

for malloc, mallocarray, realloc, and reallocf FreeBSD kernel functions. M_WAITOK implies the non-return of NULL and makes that code path un-needed.

In llvm, it's looking roughly (after mem2reg):

%a = malloc(...., %v) # where %v is a ConstantInt that has the M_WAITOK bit set
%b = bitcast .. %a ..
%c = cmp %b, null

meant for LLVM 6.0 and needs gmake

See pr240545 for this applied to some of the 12.0 kernel

About

llvm pass looking for unneeded malloc(9) return value checks

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published