Index: llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp =================================================================== --- llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp +++ llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp @@ -7,8 +7,10 @@ //===----------------------------------------------------------------------===// #include "AMDGPUMCTargetDesc.h" +#include "MCTargetDesc/AMDGPUFixupKinds.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/MC/MCELFObjectWriter.h" +#include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCFixup.h" #include "llvm/MC/MCObjectWriter.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"); } 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