Aiming to address the regression discussed in
https://reviews.llvm.org/D103009.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Also some notes from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83022
implementing a check to see if the only condition between the malloc and memset is 'ptr != 0'.
+1. This is probably what we really want to make everybody happy.
llvm/test/Transforms/DeadStoreElimination/noop-stores.ll | ||
---|---|---|
415 | I would rather see better fix, so this motivating case still works (allow 'ptr compared with NULL'). Othewise I see no value from this optimization at all and it should be just removed from DSE. I am somewhat scared that people talking about this pattern memset(malloc(size), 0, size) not suprised that why there are so many nasty bugs/exploits in C codebases. |
llvm/test/Transforms/DeadStoreElimination/noop-stores.ll | ||
---|---|---|
415 |
Sure, revert is a viable option while looking to add the 'ptr compared with NULL' check, as that's not so straightforward. |
llvm/test/Transforms/DeadStoreElimination/noop-stores.ll | ||
---|---|---|
415 | But probably we should just take your patch, to avoid regression as SLC's transformation was removed as DSE-based one was implemented. |
llvm/test/Transforms/DeadStoreElimination/noop-stores.ll | ||
---|---|---|
415 |
Yes, it requires some dance with matching like here (old patch doing transformation in SLC): https://reviews.llvm.org/D101176 |
I think, it's the right first step, and if there's a need to make the transformation support more use cases like checking the result of malloc for null, that can be added as a separate step.
I would rather see better fix, so this motivating case still works (allow 'ptr compared with NULL'). Othewise I see no value from this optimization at all and it should be just removed from DSE.
I am somewhat scared that people talking about this pattern
not suprised that why there are so many nasty bugs/exploits in C codebases.