Skip to content

Commit 3f47eeb

Browse files
committed
[Hexagon] shouldForceRelocation: check MCValue::Specifier
Hexagon follow-up to 38c3ad3.
1 parent 8c43588 commit 3f47eeb

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "llvm/MC/MCInstrInfo.h"
2222
#include "llvm/MC/MCObjectWriter.h"
2323
#include "llvm/MC/MCSubtargetInfo.h"
24+
#include "llvm/MC/MCValue.h"
2425
#include "llvm/MC/TargetRegistry.h"
2526
#include "llvm/Support/Debug.h"
2627
#include "llvm/Support/EndianStream.h"
@@ -322,7 +323,7 @@ class HexagonAsmBackend : public MCAsmBackend {
322323
// Leave these relocations alone as they are used for EH.
323324
return false;
324325
}
325-
return false;
326+
return Target.getSpecifier();
326327
}
327328

328329
/// getFixupKindNumBytes - The number of bytes the fixup may change.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# RUN: llvm-mc -triple=hexagon -mv73 -filetype=obj %s | llvm-readobj -r - | FileCheck %s
2+
3+
# This checks various combinations of relocation addends. Several cases below
4+
# had been incorrect.
5+
6+
{
7+
call a
8+
}
9+
#CHECK: R_HEX_B22_PCREL a 0x0
10+
11+
## Expect .Lb+4
12+
{
13+
if (p0) jump ##.Lb
14+
}
15+
{
16+
p0 = !cmp.gt(r2, #-1)
17+
p0 = sfclass(r2, #0xe)
18+
if (!p0.new) jump:t c
19+
}
20+
#CHECK: R_HEX_B32_PCREL_X c 0x8
21+
#CHECK: R_HEX_B15_PCREL_X c 0xC
22+
23+
{
24+
if (!p0) jump d
25+
if (p0) jump d
26+
}
27+
#CHECK: R_HEX_B32_PCREL_X d 0x0
28+
#CHECK: R_HEX_B15_PCREL_X d 0x4
29+
#CHECK: R_HEX_B32_PCREL_X d 0x8
30+
#CHECK: R_HEX_B15_PCREL_X d 0xC
31+
{
32+
if (!p0) jump e
33+
jump .Lb
34+
}
35+
#CHECK: R_HEX_B32_PCREL_X e 0x0
36+
#CHECK: R_HEX_B15_PCREL_X e 0x4
37+
.Lb:
38+
39+
{
40+
r0 = add(pc, ##foo@PCREL)
41+
if (!p0) jump f
42+
}
43+
#CHECK: R_HEX_B32_PCREL_X foo 0x0
44+
#CHECK: R_HEX_6_PCREL_X foo 0x4
45+
#CHECK: R_HEX_B32_PCREL_X f 0x8
46+
#CHECK: R_HEX_B15_PCREL_X f 0xC
47+
48+
{
49+
r0 = add(pc, ##.Lx@PCREL)
50+
if (!p0) jump __hexagon_sqrtf
51+
}
52+
.Lx:
53+
#CHECK: R_HEX_B32_PCREL_X .text
54+
#CHECK: R_HEX_6_PCREL_X .text
55+
#CHECK: R_HEX_B32_PCREL_X __hexagon_sqrtf 0x8
56+
#CHECK: R_HEX_B15_PCREL_X __hexagon_sqrtf 0xC

0 commit comments

Comments
 (0)