Fix symbol names used for outputting schedules into valid C++ source variable names#5717
Fix symbol names used for outputting schedules into valid C++ source variable names#5717derek-inteon wants to merge 3 commits intohalide:mainfrom
Conversation
src/autoschedulers/adams2019/ASLog.h
Outdated
| }; | ||
|
|
||
| // Conform the given name into a valid C++ identifier (eg for dumping a Func/Var inside a schedule to a header) | ||
| std::string conform_name(const std::string &name, const std::string &prefix="_"); |
There was a problem hiding this comment.
This function doesn't have anything to do with logging, and thus doesn't belong in ASLog.h
There was a problem hiding this comment.
Yes, that's true. I placed it here since it was a common header, and deals with formatting text, but it's not actually doing any logging.
Would you propose a new header/source file or some other location?
There was a problem hiding this comment.
It looks like it's only used in the one source file LoopNest.cpp? I would just put it in there (in an anonymous namespace too).
|
Where does this PR stand? |
|
Monday Morning Review ping: Where does this PR stand? |
|
Is this PR still active? If not, it will be closed. |
|
Is this PR still active? |
There was a problem hiding this comment.
As this fix is rather ad-hoc, I think a more central place that legalizes all Func, Var and RVar names would be more reasonable, as that solves this issue for all auto-schedulers.
Also, there is already some sanitation happening here:
Halide/src/autoschedulers/adams2019/State.cpp
Lines 677 to 685 in 8bf7827
So this PR definitely needs changing.
Since Funcs and other classes can have user defined names, the resulting strings may be invalid C++ when used directly for variable names and identifiers during the source code generation for schedules.
This PR adds a 'conform_name' around all variable names being outputted to replace invalid characters with an underscore, to make sure only valid C++ identifiers are outputted for the schedule source.