[PATCH] D109170: [Attributor] Look through allocated heap memory
Kuter Dinel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 7 20:47:33 PDT 2021
kuter added a comment.
Note: Some tests seem broken (heap_to_stack.ll) and clang format is needed.
Also, do you think we can optimize nested stuff ? for example if a pointer was stored to memory.
I think `checkForAllUses` can look through values that escape to memory, right ?
================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:210
return UndefValue::get(&Ty);
+ if (isNoAliasFn(&Obj, TLI)) {
+ if (isMallocLikeFn(&Obj, TLI) || isAlignedAllocLikeFn(&Obj, TLI))
----------------
I don't think this check is needed. `isNoAliasFn` seems to always return true if this is a allocation function.
Source code for `isNoAliasFn`
```
/// Tests if a value is a call or invoke to a function that returns a
/// NoAlias pointer (including malloc/calloc/realloc/strdup-like functions).
bool llvm::isNoAliasFn(const Value *V, const TargetLibraryInfo *TLI,
bool LookThroughBitCast) {
// it's safe to consider realloc as noalias since accessing the original
// pointer is undefined behavior
return isAllocationFn(V, TLI, LookThroughBitCast) ||
hasNoAliasAttr(V, LookThroughBitCast);
}
```
================
Comment at: llvm/lib/Transforms/IPO/AttributorAttributes.cpp:2344
AANoRecurseImpl::initialize(A);
+ // TODO: We should build a call graph ourselves to enable this in the module pass as well.
if (const Function *F = getAnchorScope())
----------------
Do you think we should use the `AAReachability` here ?
If the function can reach itself, then it is recursive.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109170/new/
https://reviews.llvm.org/D109170
More information about the llvm-commits
mailing list