This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Correct strtol folding with nonnull endptr
ClosedPublic

Authored by msebor on Aug 1 2022, 9:00 AM.

Details

Summary

The part of the change submitted in D129224 that enables the folding of strtol calls with a nonnull endptr fails to reflect in the pointer's offset the length of the leading part of the consumed string preceding the first converted digit. The tests for this part of the change were inadvertently disabled so the bug has gone unnoticed both during testing and in review. This change fixes the problem and adjusts the existing tests to let them exercise it.

Since this bug is apparently causing problems downstream I'll plan on committing the fix today and address any subsequent review comments afterwards.

Diff Detail

Event Timeline

msebor created this revision.Aug 1 2022, 9:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2022, 9:00 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
msebor requested review of this revision.Aug 1 2022, 9:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2022, 9:00 AM
efriedma accepted this revision.Aug 1 2022, 12:18 PM

LGTM

llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
93

Please use size_t here. (Not that it's really likely to matter here, but for the sake of clarity.)

This revision is now accepted and ready to land.Aug 1 2022, 12:18 PM
msebor marked an inline comment as done.Aug 1 2022, 3:47 PM
This revision was landed with ongoing or failed builds.Aug 1 2022, 3:47 PM
This revision was automatically updated to reflect the committed changes.

@tstellar This commit needs to be cherrypicked to the 15.x branch, since it fixes a problem introduced before the llvm 16 cut (https://reviews.llvm.org/D129224).

@alexfh Can you file an issue for this one too?