-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Only emit one copy-to-host or copy-to-accelerator compiler warning per source location, even if it has multiple host uses. #18402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please test tensorflow |
// DenseMap/DenseSet key type instead of SourceRange. That would require that | ||
// the call-site translate a SILLocation / SourceRange to line and column | ||
// numbers first. | ||
template<> struct DenseMapInfo<SourceRange> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go in the header that defines SourceRange, and upstreamed :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
// Emit the warning on this value, if that has not been done before. | ||
if (!copyToAccelWarningLocs.insert(loc.getSourceRange()).second) | ||
return; | ||
|
||
diagnose(ctx, loc.getSourceLoc(), diagID, description) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to unique based on the entire source range? Would it be fine to just unique based on loc.getSourceLoc() ? That would eliminate the need for template specialization entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DenseMapInfo
is not defined for SourceLoc
either, so I might as make SourceRange
work as the key type.
Compiler error for using llvm::DenseSet<SourceLoc> copyToHostWarningLocs
:
/usr/local/google/home/hongm/ssd_part/git/swift-base/llvm/include/llvm/ADT/DenseMap.h:421:22: error: no member named 'getEmptyKey' in 'llvm::DenseMapInfo<swift::SourceLoc>'
return KeyInfoT::getEmptyKey();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix! LGTM.
// the call-site translate a SILLocation / SourceRange to line and column | ||
// numbers first. | ||
template<> struct DenseMapInfo<SourceRange> { | ||
static SourceRange getEmptyKey() { return SourceRange(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider making the empty key and the tombstone key different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…r source location, even if it has multiple host uses.
One use case is using DenseSet to manage a set of source locations, so that we emit at most one compiler diagnostic per location (see swiftlang#18402).
Resolves SR-8412.