From 76e32dfbc0acecb33e2141a0c2faf5b23e1342fc Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Wed, 18 May 2016 16:10:24 +0000 Subject: [PATCH] AMDGPU: Error if branch distance exceeds limit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269951 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp b/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp index c7c4cf0969d..933c167f013 100644 --- a/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp +++ b/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp @@ -96,8 +96,12 @@ void AMDGPUAsmBackend::applyFixup(const MCFixup &Fixup, char *Data, switch ((unsigned)Fixup.getKind()) { case AMDGPU::fixup_si_sopp_br: { + int64_t BrImm = (Value - 4) / 4; + if (!isInt<16>(BrImm)) + report_fatal_error("branch size exceeds simm16"); + uint16_t *Dst = (uint16_t*)(Data + Fixup.getOffset()); - *Dst = (Value - 4) / 4; + *Dst = BrImm; break; }