Skip to content

Commit 723863f

Browse files
committed
Address Review Feedback
1 parent 98dfeed commit 723863f

File tree

4 files changed

+31
-52
lines changed

4 files changed

+31
-52
lines changed

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,7 @@ void RISCVAsmBackend::addVendorReloc(const MCFragment &F, const MCFixup &Fixup,
641641
MCSymbol *VendorSymbol = It->getValue();
642642
const MCExpr *VendorExpr = MCSymbolRefExpr::create(VendorSymbol, Ctx);
643643
MCFixup VendorFixup =
644-
MCFixup::create(Fixup.getOffset(), VendorExpr,
645-
FirstLiteralRelocationKind + ELF::R_RISCV_VENDOR);
644+
MCFixup::create(Fixup.getOffset(), VendorExpr, ELF::R_RISCV_VENDOR);
646645
// Explicitly create MCValue so that the absolute symbol is not evaluated to
647646
// a constant.
648647
MCValue VendorTarget = MCValue::get(VendorSymbol);
@@ -700,14 +699,18 @@ bool RISCVAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
700699
(getFixupKindInfo(Fixup.getKind()).Flags & MCFixupKindInfo::FKF_IsPCRel))
701700
IsResolved = isPCRelFixupResolved(Target.getAddSym(), F);
702701

703-
// Some Fixups require a vendor relocation, record it (directly) before we add
704-
// the relocation.
705-
if (!IsResolved || shouldForceRelocation(Fixup, Target)) {
702+
if (IsResolved && shouldForceRelocation(Fixup, Target))
703+
IsResolved = false;
704+
705+
if (!IsResolved) {
706+
// Some Fixups require a vendor relocation, record it (directly) before we
707+
// add the relocation.
706708
if (std::optional<StringRef> VendorIdentifier =
707709
getVendorIdentifierForFixup(Fixup.getTargetKind()))
708710
addVendorReloc(F, Fixup, *VendorIdentifier);
711+
712+
Asm->getWriter().recordRelocation(F, Fixup, Target, FixedValue);
709713
}
710-
IsResolved = MCAsmBackend::addReloc(F, Fixup, Target, FixedValue, IsResolved);
711714

712715
if (Fixup.isLinkerRelaxable()) {
713716
auto FA = MCFixup::create(Fixup.getOffset(), nullptr, ELF::R_RISCV_RELAX);

llvm/test/MC/RISCV/xqcibi-relocations.s

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,53 +21,45 @@ this_section:
2121
# ASM: qc.bnei t1, 10, undef
2222
# OBJ: qc.bnei t1, 0xa, 0x0 <this_section>
2323
# OBJ-NEXT: R_RISCV_BRANCH undef{{$}}
24-
# OBJ-NOT: R_RISCV
2524
qc.bnei t1, 10, undef
2625

2726
# ASM: qc.e.bgeui s0, 20, undef
28-
# OBJ: qc.e.bgeui s0, 0x14, 0x4 <this_section+0x4>
27+
# OBJ-NEXT: qc.e.bgeui s0, 0x14, 0x4 <this_section+0x4>
2928
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
3029
# OBJ-NEXT: R_RISCV_CUSTOM193 undef{{$}}
31-
# OBJ-NOT: R_RISCV
3230
qc.e.bgeui s0, 20, undef
3331

3432

3533
# ASM: qc.bnei t2, 11, same_section
36-
# OBJ: qc.bnei t2, 0xb, 0x28 <same_section>
37-
# OBJ-NOT: R_RISCV
34+
# OBJ-NEXT: qc.bnei t2, 0xb, 0x28 <same_section>
3835
qc.bnei t2, 11, same_section
3936

4037
# ASM: qc.e.bgeui s1, 21, same_section
41-
# OBJ: qc.e.bgeui s1, 0x15, 0x28 <same_section>
42-
# OBJ-NOT: R_RISCV
38+
# OBJ-NEXT: qc.e.bgeui s1, 0x15, 0x28 <same_section>
4339
qc.e.bgeui s1, 21, same_section
4440

4541

4642
# ASM: qc.bnei t2, 12, same_section_extern
47-
# OBJ: qc.bnei t2, 0xc, 0x14 <this_section+0x14>
43+
# OBJ-NEXT: qc.bnei t2, 0xc, 0x14 <this_section+0x14>
4844
# OBJ-NEXT: R_RISCV_BRANCH same_section_extern{{$}}
49-
# OBJ-NOT: R_RISCV
5045
qc.bnei t2, 12, same_section_extern
5146

5247
# ASM: qc.e.bgeui s1, 22, same_section_extern
53-
# OBJ: qc.e.bgeui s1, 0x16, 0x18 <this_section+0x18>
48+
# OBJ-NEXT: qc.e.bgeui s1, 0x16, 0x18 <this_section+0x18>
5449
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
5550
# OBJ-NEXT: R_RISCV_CUSTOM193 same_section_extern{{$}}
56-
# OBJ-NOT: R_RISCV
5751
qc.e.bgeui s1, 22, same_section_extern
5852

5953

6054
# ASM: qc.bnei t3, 13, other_section
61-
# OBJ: qc.bnei t3, 0xd, 0x1e <this_section+0x1e>
55+
# OBJ-NEXT: qc.bnei t3, 0xd, 0x1e <this_section+0x1e>
6256
# OBJ-NEXT: R_RISCV_BRANCH other_section{{$}}
63-
# OBJ-NOT: R_RISCV
6457
qc.bnei t3, 13, other_section
6558

6659
# ASM: qc.e.bgeui s2, 23, other_section
67-
# OBJ: qc.e.bgeui s2, 0x17, 0x22 <this_section+0x22>
60+
# OBJ-NEXT: qc.e.bgeui s2, 0x17, 0x22 <this_section+0x22>
6861
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
6962
# OBJ-NEXT: R_RISCV_CUSTOM193 other_section{{$}}
70-
# OBJ-NOT: R_RISCV
7163
qc.e.bgeui s2, 23, other_section
7264

7365

llvm/test/MC/RISCV/xqcilb-relocations.s

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,57 +19,49 @@
1919
this_section:
2020

2121
# ASM: qc.e.j undef
22-
# OBJ: qc.e.j 0x0
22+
# OBJ: qc.e.j 0x0 <this_section>
2323
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
2424
# OBJ-NEXT: R_RISCV_CUSTOM195 undef{{$}}
25-
# OBJ-NOT: R_RISCV
2625
qc.e.j undef
2726

2827
# ASM: qc.e.jal undef
29-
# OBJ: qc.e.jal 0x6
28+
# OBJ-NEXT: qc.e.jal 0x6 <this_section+0x6>
3029
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
3130
# OBJ-NEXT: R_RISCV_CUSTOM195 undef{{$}}
32-
# OBJ-NOT: R_RISCV
3331
qc.e.jal undef
3432

3533

3634
# ASM: qc.e.j same_section
37-
# OBJ: qc.e.j 0x30
38-
# OBJ-NOT: R_RISCV
35+
# OBJ-NEXT: qc.e.j 0x30 <same_section>
3936
qc.e.j same_section
4037

4138
# ASM: qc.e.jal same_section
42-
# OBJ: qc.e.jal 0x30
43-
# OBJ-NOT: R_RISCV
39+
# OBJ-NEXT: qc.e.jal 0x30 <same_section>
4440
qc.e.jal same_section
4541

4642
# ASM: qc.e.j same_section_extern
47-
# OBJ: qc.e.j 0x18
43+
# OBJ-NEXT: qc.e.j 0x18 <this_section+0x18>
4844
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
4945
# OBJ-NEXT: R_RISCV_CUSTOM195 same_section_extern{{$}}
50-
# OBJ-NOT: R_RISCV
5146
qc.e.j same_section_extern
5247

5348
# ASM: qc.e.jal same_section_extern
54-
# OBJ: qc.e.jal 0x1e
49+
# OBJ-NEXT: qc.e.jal 0x1e <this_section+0x1e>
5550
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
5651
# OBJ-NEXT: R_RISCV_CUSTOM195 same_section_extern{{$}}
57-
# OBJ-NOT: R_RISCV
5852
qc.e.jal same_section_extern
5953

6054

6155
# ASM: qc.e.j other_section
62-
# OBJ: qc.e.j 0x24
56+
# OBJ-NEXT: qc.e.j 0x24 <this_section+0x24>
6357
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
6458
# OBJ-NEXT: R_RISCV_CUSTOM195 other_section{{$}}
65-
# OBJ-NOT: R_RISCV
6659
qc.e.j other_section
6760

6861
# ASM: qc.e.jal other_section
69-
# OBJ: qc.e.jal 0x2a
62+
# OBJ-NEXT: qc.e.jal 0x2a <this_section+0x2a>
7063
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
7164
# OBJ-NEXT: R_RISCV_CUSTOM195 other_section{{$}}
72-
# OBJ-NOT: R_RISCV
7365
qc.e.jal other_section
7466

7567

llvm/test/MC/RISCV/xqcili-relocations.s

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,54 +23,46 @@ this_section:
2323
# OBJ: qc.li a0, 0x0
2424
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
2525
# OBJ-NEXT: R_RISCV_CUSTOM192 undef{{$}}
26-
# OBJ-NOT: R_RISCV
2726
qc.li a0, %qc.abs20(undef)
2827

2928
# ASM: qc.e.li s0, undef
30-
# OBJ: qc.e.li s0, 0x0
29+
# OBJ-NEXT: qc.e.li s0, 0x0
3130
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
3231
# OBJ-NEXT: R_RISCV_CUSTOM194 undef{{$}}
33-
# OBJ-NOT: R_RISCV
3432
qc.e.li s0, undef
3533

3634

3735
# ASM: qc.li a1, %qc.abs20(0)
38-
# OBJ: qc.li a1, 0x0
39-
# OBJ-NOT: R_RISCV
36+
# OBJ-NEXT: qc.li a1, 0x0
4037
qc.li a1, %qc.abs20(abs_symbol)
4138

4239
# ASM: qc.e.li s1, 0
43-
# OBJ: qc.e.li s1, 0x0
44-
# OBJ-NOT: R_RISCV
40+
# OBJ-NEXT: qc.e.li s1, 0x0
4541
qc.e.li s1, abs_symbol
4642

4743

4844
# ASM: qc.li a2, %qc.abs20(same_section)
49-
# OBJ: qc.li a2, 0x0
45+
# OBJ-NEXT: qc.li a2, 0x0
5046
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
5147
# OBJ-NEXT: R_RISCV_CUSTOM192 same_section{{$}}
52-
# OBJ-NOT: R_RISCV
5348
qc.li a2, %qc.abs20(same_section)
5449

5550
# ASM: qc.e.li s2, same_section
56-
# OBJ: qc.e.li s2, 0x0
51+
# OBJ-NEXT: qc.e.li s2, 0x0
5752
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
5853
# OBJ-NEXT: R_RISCV_CUSTOM194 same_section{{$}}
59-
# OBJ-NOT: R_RISCV
6054
qc.e.li s2, same_section
6155

6256
# ASM: qc.li a3, %qc.abs20(other_section)
63-
# OBJ: qc.li a3, 0x0
57+
# OBJ-NEXT: qc.li a3, 0x0
6458
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
6559
# OBJ-NEXT: R_RISCV_CUSTOM192 other_section{{$}}
66-
# OBJ-NOT: R_RISCV
6760
qc.li a3, %qc.abs20(other_section)
6861

6962
# ASM: qc.e.li s3, other_section
70-
# OBJ: qc.e.li s3, 0x0
63+
# OBJ-NEXT: qc.e.li s3, 0x0
7164
# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
7265
# OBJ-NEXT: R_RISCV_CUSTOM194 other_section{{$}}
73-
# OBJ-NOT: R_RISCV
7466
qc.e.li s3, other_section
7567

7668
# ASM-LABEL: same_section:

0 commit comments

Comments
 (0)