This is an archive of the discontinued LLVM Phabricator instance.

[clang][codegen] Remember string used to create llvm::Regex for optimization remarks
ClosedPublic

Authored by jansvoboda11 on Feb 4 2021, 7:13 AM.

Details

Summary

Regular expression patterns passed through the command line are being used to create an instances of llvm::Regex and thrown away.

There is no API to serialize Regex back to the original pattern. This means we have no way to reconstruct the original pattern from command line. This is necessary for serializing CompilerInvocation.

This patch stores the original pattern string in CodeGenOptions alongside the llvm::Regex instance.

Diff Detail

Event Timeline

jansvoboda11 requested review of this revision.Feb 4 2021, 7:13 AM
jansvoboda11 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2021, 7:13 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
thegameg accepted this revision.Feb 4 2021, 7:29 AM
This revision is now accepted and ready to land.Feb 4 2021, 7:29 AM
dexonsmith accepted this revision.Feb 4 2021, 8:49 AM

LGTM! I also have a couple of optional suggestions to consider.

clang/include/clang/Basic/CodeGenOptions.h
286

This could also be:

explicit operator bool() const { return Regex != nullptr }
288–291

Another option would be:

llvm::Regex *operator->() const { return Regex.get(); }

treating RemarkPattern as a pointer wrapper (that also knows the std::string). WDYT?

Apply suggested change

I originally wanted to improve the API (make the null checks unnecessary), but keeping the API and minimizing the patch with your changes is nice too. I'm going with your suggestion, thanks!

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