[llvm-dev] DSE: Remove useless stores between malloc & memset

Dávid Bolvanský via llvm-dev llvm-dev at lists.llvm.org
Thu May 17 08:58:20 PDT 2018


Hello,

I would like to find a way to do this removal properly. I found DSE and
"eliminateNoopStore" can be useful for this thing.

What I mean?
int *test = malloc(15 * sizeof(int));
test[10] = 12; < ----- remove this store
memset(test,0,sizeof(int) * 15);

I already checked the function "eliminateNoopStore".
Looks good, I think I would be to get the value ("A") we store to, is from
malloc. Then a pointer capture analysis would be performed. These steps
should not be hard.

The problem: how to do the detection that the value "A" is later zeroed
using memset? Traverse over all uses of "A"? Can you recommend me the
proper way how to check this?

Thank you

p.s: In the future it could be used for proper malloc + memset folding to
calloc, currently it is a bit suboptimal.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180517/bfc008ea/attachment.html>


More information about the llvm-dev mailing list