[PATCH] D117180: [BasicAliasAnalysis] Switch from isMallocOrCallocLikeFn to onlyAccessesInaccessibleMemory
Bryce Wilson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 13 12:14:07 PST 2022
Bryce-MW added a comment.
Thanks, like I said, I'm not super knowledgeable about the standards (especially for C++, I'm mostly a C person). One thing I will note is that isMallocOrCallocLikeFn does return true for op new as far as I can tell.
The test it does is
(FnData->AllocTy & MallocOrCallocLike) != FnData->AllocTy // returns true when they type doesn't match and false when it does
MallocOrCallocLike = MallocLike | CallocLike | AlignedAllocLike
MallocLike = 1<<1 | OpNewLike
OpNewLike = 1<<0
CallocLike = 1<<3
AlignedAllocLike = 1<<2
so MallocOrCallocLike = 0b1111
an OpNewLike function will be tagged OpNewLike = 1
so the test becomes:
(1 & 0b1111) != 1
(1) != 1
false
If it were true then getAllocationDataForFunction would return None causing isMallocOrCallocLikeFn to return false. But it returns false, so as long as the arguments match the check, then getAllocationDataForFunction will return some data making isMallocOrCallocLikeFn return true. This also means that for similar reasons, isAllocRemovable is going to return true for op new but it sounds like you are saying that it should not.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117180/new/
https://reviews.llvm.org/D117180
More information about the llvm-commits
mailing list