-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MC][AMDGPU] Support .reloc BFD_RELOC_{NONE,32,64} #114617
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
[MC][AMDGPU] Support .reloc BFD_RELOC_{NONE,32,64} #114617
Conversation
Emitting BFD_RELOC_* reloc directives can cause internal errors on AMDGPU
@llvm/pr-subscribers-mc @llvm/pr-subscribers-backend-amdgpu Author: Ethan Luis McDonough (EthanLuisMcDonough) ChangesEmitting BFD_RELOC_* reloc directives can cause internal errors on AMDGPU. Full diff: https://github.com/llvm/llvm-project/pull/114617.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
index c2d2ca0f90f930..3172a83e5a1fe0 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
@@ -163,12 +163,17 @@ void AMDGPUAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
std::optional<MCFixupKind>
AMDGPUAsmBackend::getFixupKind(StringRef Name) const {
- return StringSwitch<std::optional<MCFixupKind>>(Name)
-#define ELF_RELOC(Name, Value) \
- .Case(#Name, MCFixupKind(FirstLiteralRelocationKind + Value))
+ auto Type = StringSwitch<unsigned>(Name)
+#define ELF_RELOC(Name, Value) .Case(#Name, Value)
#include "llvm/BinaryFormat/ELFRelocs/AMDGPU.def"
#undef ELF_RELOC
- .Default(std::nullopt);
+ .Case("BFD_RELOC_NONE", ELF::R_AMDGPU_NONE)
+ .Case("BFD_RELOC_32", ELF::R_AMDGPU_ABS32)
+ .Case("BFD_RELOC_64", ELF::R_AMDGPU_ABS64)
+ .Default(-1u);
+ if (Type != -1u)
+ return static_cast<MCFixupKind>(FirstLiteralRelocationKind + Type);
+ return std::nullopt;
}
const MCFixupKindInfo &AMDGPUAsmBackend::getFixupKindInfo(
|
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.
Needs a test
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.
If we actually can handle these it would go in the AMDGPU relocations instead of being handled specially here. I don't know what these relocations are, do you know where they come from?
.Default(std::nullopt); | ||
.Case("BFD_RELOC_NONE", ELF::R_AMDGPU_NONE) | ||
.Case("BFD_RELOC_32", ELF::R_AMDGPU_ABS32) | ||
.Case("BFD_RELOC_64", ELF::R_AMDGPU_ABS64) |
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.
Why are they not added to "llvm/BinaryFormat/ELFRelocs/AMDGPU.def" ?
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.
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.
I have no idea why it's like this, why wouldn't these all be in the def? I guess it's fine to copy the pattern and clean them all later?
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.
We just need to decide which way we want to do it.
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.
Follow up could move all the targets to use the def files
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/30/builds/10188 Here is the relevant piece of the build log for the reference
|
Emitting BFD_RELOC_* reloc directives can cause internal errors on AMDGPU.