Added a write method for TimeTrace that takes two strings representing
file names. The first is any file name that may have been provided by the
user via time-trace-file flag, and the second is a fallback that should
be configured by the caller. This method makes it cleaner to write the
trace output because there is no longer a need to check file names at the
caller and simplifies future TimeTrace usages.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Once the error handling is fixed up, I'm not sure this is that much better than what came before, but I could be wrong.
llvm/lib/Support/TimeProfiler.cpp | ||
---|---|---|
296 | Maybe passing the error back to the caller (as the Error type, perhaps?) would be better. LLD would hook it into its diagnostic machinery and clang to its own. Otherwise, the user can supply an unwritable path which will cause clang/lld to print a banner asking them to file a bug report, which is incorrect, it's a usage bug, not a compiler bug. |
I'm not sure this is that much better than what came before, but I could be wrong.
The benefit of this change is that in the next diff in this stack I add additional usage of the TimeTraceScope to LLVM passes/pass managers. In doing so there is another need to essentially flush the trace info to a file and also validate the file name provided. It made sense to move handling whether or not a user provided a file name to a consistent place.
llvm/lib/Support/TimeProfiler.cpp | ||
---|---|---|
296 | Will do! Sounds like a good improvement. |
Maybe passing the error back to the caller (as the Error type, perhaps?) would be better. LLD would hook it into its diagnostic machinery and clang to its own. Otherwise, the user can supply an unwritable path which will cause clang/lld to print a banner asking them to file a bug report, which is incorrect, it's a usage bug, not a compiler bug.