Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions clang/lib/Driver/ToolChains/HIPUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,8 @@ class HIPUndefinedFatBinSymbols {
// Handling for defined symbols
if (!isUndefined) {
if (isFatBinSymbol) {
DefinedFatBinSymbols.insert(Name.str());
FatBinSymbols.erase(Name.str());
} else if (isGPUBinHandleSymbol) {
DefinedGPUBinHandleSymbols.insert(Name.str());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this mean that DefinedFatBinSymbols and DefinedGPUBinHandleSymbols are always empty? Therefore, the DefinedFatBinSymbols.find(Name) == DefinedFatBinSymbols.end() check below is always true, so that the code becomes:

// Handling for defined symbols
if (!isUndefined) {
  if (isFatBinSymbol) {
    FatBinSymbols.erase(Name.str());
  } else if (isGPUBinHandleSymbol) {
    GPUBinHandleSymbols.erase(Name.str());
  }
  continue;
}

// Add undefined symbols if they are not in the defined sets
if (isFatBinSymbol)
  FatBinSymbols.insert(Name.str());
else if (isGPUBinHandleSymbol)
  GPUBinHandleSymbols.insert(Name.str());

I think then there's an issue where the order in which files are processed impacts whether a symbol is stored in FatBinSymbols and GPUBinHandleSymbols: hipcc -o output defined_use.o undefined_use.o will probably result in multiple-definition errors.

GPUBinHandleSymbols.erase(Name.str());
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-      if (!isUndefined) {
+      if (!isUndefined && !isHidden) {
         if (isFatBinSymbol) {
           DefinedFatBinSymbols.insert(Name.str());
           FatBinSymbols.erase(Name.str());
-        } else if (isGPUBinHandleSymbol && (!isHidden) ) {
+        } else if (isGPUBinHandleSymbol) {
           DefinedGPUBinHandleSymbols.insert(Name.str());
           GPUBinHandleSymbols.erase(Name.str());
         }

I don't recall if I've specifically seen that __hip_fatbin symbols have the same issue, but it's probably best to avoid that issue as well if it crops up.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @omor1. You're right. Sam suggested we just remove the code to add these symbols if they are already defined. I've added a new commit. And the change is for both of the _hip symbols.

continue;
Expand Down