Skip to content

[ELF] Correctly set the nvptx triple from makeTriple() #76970

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

Merged
merged 1 commit into from
Jan 4, 2024
Merged
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
7 changes: 7 additions & 0 deletions llvm/include/llvm/Object/ELFObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,13 @@ template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
return Triple::UnknownArch;
}

case ELF::EM_CUDA: {
if (EF.getHeader().e_ident[ELF::EI_CLASS] == ELF::ELFCLASS32)
return Triple::nvptx;
else
return Triple::nvptx64;
Comment on lines +1353 to +1356
Copy link
Collaborator

Choose a reason for hiding this comment

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

avoid else-after-return, per the LLVM style guide.
Instead use:

if (...)
  return ...;
return ...;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a test for this now in #76992. I can do the style NFC if needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Generally the test should go with the patch that introduces the change in behavior. If the change in behavior is unreachable/untestable without some other changes, then they should go together so test coverage is clear (otherwise it's hard to track that the patch did eventually get tested).

Sure - an NFC change would be good - no need to send it for review, you can commit that directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There weren't any existing tests for any of this code, so I just punted it until the second patch. Thanks, I'll do the NFC.

}

case ELF::EM_BPF:
return IsLittleEndian ? Triple::bpfel : Triple::bpfeb;

Expand Down