[PATCH] D60047: [CaptureTracking] Pointer comparisons cannot escape
Sanjoy Das via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 31 10:29:37 PDT 2019
sanjoy requested changes to this revision.
sanjoy added a comment.
This revision now requires changes to proceed.
Things that are UB in C++ are not necessarily UB in LLVM. For instance you could capture a pointer by doing something like this:
int global;
void f() {
int* ptr = new int;
// Probably UB in C++? But not UB in LLVM if the GEP is not
// an inbounds GEP.
if ((ptr+4096) == &global) {
intptr_t addr = ((intptr_t)&global) - 4096;
escape((int*)addr)
}
}
> However, I found that since inserting these null checks, escape analysis suffers badly because all icmp instructions are seen as captures.motivation:
A more extreme version of the example above could be written to just use a comparison against `null`:
void f() {
int* ptr = new int;
if ((ptr-4096) == nullptr) {
escape((int*)4096)
}
}
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60047/new/
https://reviews.llvm.org/D60047
More information about the llvm-commits
mailing list