https://bugs.llvm.org/show_bug.cgi?id=41039
Bug ID: 41039
Summary: instcombine incorrectly removes "dead" malloc/operator
delete pair
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedb...@nondot.org
Reporter: efrie...@quicinc.com
CC: llvm-bugs@lists.llvm.org
Testcase:
#include <cstddef>
#include <cstdio>
#include <cstdlib>
void* operator new(size_t sz) {
printf("Calling new\n");
return malloc(sz);
}
__attribute__((noinline))
void operator delete(void* ptr) noexcept {
printf("Calling delete\n");
return free(ptr);
}
int* f() { return new int; }
int main() { delete f(); }
With "clang -O2", outputs "Calling new", but not "Calling delete". I think
this is a bug according to the standard: we're allowed to remove dead
new/delete pairs, but we have to either remove a complete pair, or nothing at
all.
I think this is a bug in instcombine, that it considers any pair of
allocation/deallocation function to be dead, even if that pair is something
like malloc/operator delete.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs