This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Make getStringLenth aware of strdup
ClosedPublic

Authored by serge-sans-paille on Apr 11 2022, 4:49 AM.

Details

Summary

During strlen compile-time evaluation, make it possible to track size of
strduped strings.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 4:49 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
serge-sans-paille requested review of this revision.Apr 11 2022, 4:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 4:49 AM

clang-formatted version

nikic accepted this revision.Apr 11 2022, 5:33 AM

LGTM

This revision is now accepted and ready to land.Apr 11 2022, 5:33 AM
This revision was landed with ongoing or failed builds.Apr 12 2022, 5:48 AM
This revision was automatically updated to reflect the committed changes.
efriedma added inline comments.
llvm/lib/Analysis/ValueTracking.cpp
4254

Do you need to check somewhere that the string returned by strdup hasn't been modified? The existing code gets away without any checks for modification because getConstantDataArrayInfo only works on constant globals, but strdup returns a modifiable buffer.

nikic added inline comments.Apr 12 2022, 9:13 AM
llvm/lib/Analysis/ValueTracking.cpp
4254

Great point, sorry for missing that.

llvm/lib/Analysis/ValueTracking.cpp
4254

Indeed!

serge-sans-paille added a comment.EditedApr 13 2022, 1:52 AM

Patch reverted by da2d6ebf0ab0badccb89ba20940fdd208636fa59 262eba01b33fd5cda5e4b65a744bac9d87cd7453

Patch reverted by da2d6ebf0ab0badccb89ba20940fdd208636fa59

That patch doesn't appear to exist