[PATCH] D79943: [AMDGPU][MC] Corrected branch relocation handling to detect undefined labels
Dmitry Preobrazhensky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 18 04:15:30 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf997370d9c8f: [AMDGPU][MC] Corrected branch relocation handling to detect undefined labels (authored by dp).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79943/new/
https://reviews.llvm.org/D79943
Files:
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
llvm/test/MC/AMDGPU/labels-branch-err.s
Index: llvm/test/MC/AMDGPU/labels-branch-err.s
===================================================================
--- /dev/null
+++ llvm/test/MC/AMDGPU/labels-branch-err.s
@@ -0,0 +1,4 @@
+// RUN: not llvm-mc -arch=amdgcn -filetype=obj -o /dev/null %s 2>&1 | FileCheck -check-prefix=ERROR %s
+// ERROR: error: undefined label 'undef_label'
+
+s_branch undef_label
Index: llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
+++ llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
@@ -6,8 +6,10 @@
//
//===----------------------------------------------------------------------===//
+#include "AMDGPUFixupKinds.h"
#include "AMDGPUMCTargetDesc.h"
#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCELFObjectWriter.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
@@ -80,6 +82,15 @@
return ELF::R_AMDGPU_ABS64;
}
+ if (Fixup.getTargetKind() == AMDGPU::fixup_si_sopp_br) {
+ const auto *SymA = Target.getSymA();
+ assert(SymA);
+
+ Ctx.reportError(Fixup.getLoc(),
+ Twine("undefined label '") + SymA->getSymbol().getName() + "'");
+ return ELF::R_AMDGPU_NONE;
+ }
+
llvm_unreachable("unhandled relocation type");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79943.264580.patch
Type: text/x-patch
Size: 1371 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200518/3c332a04/attachment.bin>
More information about the llvm-commits
mailing list