Skip to content

[Hexagon] shouldForceRelocation: check MCValue::Specifier #139948

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCValue.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/EndianStream.h"
Expand Down Expand Up @@ -322,7 +323,7 @@ class HexagonAsmBackend : public MCAsmBackend {
// Leave these relocations alone as they are used for EH.
return false;
}
return false;
return Target.getSpecifier();
}

/// getFixupKindNumBytes - The number of bytes the fixup may change.
Expand Down
56 changes: 56 additions & 0 deletions llvm/test/MC/Hexagon/reloc-addends.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# RUN: llvm-mc -triple=hexagon -mv73 -filetype=obj %s | llvm-readobj -r - | FileCheck %s

# This checks various combinations of relocation addends. Several cases below
# had been incorrect.

{
call a
}
#CHECK: R_HEX_B22_PCREL a 0x0

## Expect .Lb+4
{
if (p0) jump ##.Lb
}
{
p0 = !cmp.gt(r2, #-1)
p0 = sfclass(r2, #0xe)
if (!p0.new) jump:t c
}
#CHECK: R_HEX_B32_PCREL_X c 0x8
#CHECK: R_HEX_B15_PCREL_X c 0xC

{
if (!p0) jump d
if (p0) jump d
}
#CHECK: R_HEX_B32_PCREL_X d 0x0
#CHECK: R_HEX_B15_PCREL_X d 0x4
#CHECK: R_HEX_B32_PCREL_X d 0x8
#CHECK: R_HEX_B15_PCREL_X d 0xC
{
if (!p0) jump e
jump .Lb
}
#CHECK: R_HEX_B32_PCREL_X e 0x0
#CHECK: R_HEX_B15_PCREL_X e 0x4
.Lb:

{
r0 = add(pc, ##foo@PCREL)
if (!p0) jump f
}
#CHECK: R_HEX_B32_PCREL_X foo 0x0
#CHECK: R_HEX_6_PCREL_X foo 0x4
#CHECK: R_HEX_B32_PCREL_X f 0x8
#CHECK: R_HEX_B15_PCREL_X f 0xC

{
r0 = add(pc, ##.Lx@PCREL)
if (!p0) jump __hexagon_sqrtf
}
.Lx:
#CHECK: R_HEX_B32_PCREL_X .text
#CHECK: R_HEX_6_PCREL_X .text
#CHECK: R_HEX_B32_PCREL_X __hexagon_sqrtf 0x8
#CHECK: R_HEX_B15_PCREL_X __hexagon_sqrtf 0xC