This is an archive of the discontinued LLVM Phabricator instance.

[Support] Fix for two issues with clearing of the internal storage for cl::bits
ClosedPublic

Authored by RVP on Feb 5 2022, 4:11 PM.

Details

Summary

This patch fixes two issues with clearing of the internal storage for cl::bits

  1. The internal bits storage for cl::bits is uninitialized. This is a problem if a cl::bits option is not defined with static lifetime.
  2. ResetAllOptionOccurrences does not reset cl::bits options.

The latter is also discussed in:

https://lists.llvm.org/pipermail/llvm-dev/2021-February/148299.html

Diff Detail

Event Timeline

RVP created this revision.Feb 5 2022, 4:11 PM
RVP requested review of this revision.Feb 5 2022, 4:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 5 2022, 4:11 PM
RVP added a reviewer: kazu.Feb 5 2022, 4:15 PM
RVP added a comment.Feb 5 2022, 4:19 PM
NOTE: I have no commit access. If this is good to land, I will need someone to commit this. Thanks!
RVP retitled this revision from Fix for two issues related to clearing of the internal storage for cl::bits to [Support] Fix for two issues with clearing of the internal storage for cl::bits.Feb 5 2022, 4:49 PM
RVP edited the summary of this revision. (Show Details)
RVP edited the summary of this revision. (Show Details)Feb 5 2022, 4:55 PM
RVP updated this revision to Diff 406233.Feb 5 2022, 11:35 PM

Changed the declaration of Args in unit test to use const char* Args[] which is how it was originally. std::array seems to break Windows build.

The pre-merge build shows a failure due to some unit tests timing out. I am not able to see any relation. Please let me know otherwise. Thanks.

llvm/include/llvm/Support/CommandLine.h
1731

Previously, uninitialized if cl::bits has non-static lifetime

llvm/unittests/Support/CommandLineTest.cpp
1954

Without the initialization, this EXPECT will fail.

1963

Without the fix in setDefault, this EXPECT will fail.

serge-sans-paille accepted this revision.Feb 6 2022, 1:07 PM

Thanks for this patch, it looks correct to me.

This revision is now accepted and ready to land.Feb 6 2022, 1:07 PM
RVP added a comment.Feb 6 2022, 8:17 PM

@serge-sans-paille Thanks for reviewing. Please note that I have no commit access and I will need someone to do it for me.

(running extra checks and landing the patch)

This revision was landed with ongoing or failed builds.Feb 9 2022, 12:47 AM
This revision was automatically updated to reflect the committed changes.