[llvm] 7cb66ff - [PowerPC] Use reportError

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 6 00:03:53 PDT 2025


Author: Fangrui Song
Date: 2025-04-06T00:03:48-07:00
New Revision: 7cb66ff4648a15741a1908658dfef5cb3d4a9199

URL: https://github.com/llvm/llvm-project/commit/7cb66ff4648a15741a1908658dfef5cb3d4a9199
DIFF: https://github.com/llvm/llvm-project/commit/7cb66ff4648a15741a1908658dfef5cb3d4a9199.diff

LOG: [PowerPC] Use reportError

Report a proper error and fix de1dc9c98f9ce74d38aceb44e00d258370d1bb34

Added: 
    

Modified: 
    llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
    llvm/test/MC/PowerPC/relocation-specifier-err.s

Removed: 
    llvm/test/MC/PowerPC/pr24686.s


################################################################################
diff  --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
index d7ff92f64bf4f..50b59b336bb5b 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
@@ -145,9 +145,8 @@ unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
       break;
     case PPC::fixup_ppc_half16ds:
     case PPC::fixup_ppc_half16dq:
-      Target.print(errs());
-      errs() << '\n';
-      report_fatal_error("Invalid PC-relative half16ds relocation");
+      Ctx.reportError(Loc, "unsupported relocation type");
+      break;
     case PPC::fixup_ppc_pcrel34:
       switch (Spec) {
       default:

diff  --git a/llvm/test/MC/PowerPC/pr24686.s b/llvm/test/MC/PowerPC/pr24686.s
deleted file mode 100644
index 35a379c697eaf..0000000000000
--- a/llvm/test/MC/PowerPC/pr24686.s
+++ /dev/null
@@ -1,7 +0,0 @@
-# RUN: not --crash llvm-mc -triple=powerpc64le-unknown-linux-gnu -filetype=obj %s \
-# RUN: 2>&1 | FileCheck %s
-        
-_stext:
-ld %r5, p_end - _stext(%r5)
-
-# CHECK: LLVM ERROR: Invalid PC-relative half16ds relocation

diff  --git a/llvm/test/MC/PowerPC/relocation-specifier-err.s b/llvm/test/MC/PowerPC/relocation-specifier-err.s
index 835fde7519ace..e7210794cdd58 100644
--- a/llvm/test/MC/PowerPC/relocation-specifier-err.s
+++ b/llvm/test/MC/PowerPC/relocation-specifier-err.s
@@ -10,5 +10,8 @@ addi 3, 3, foo at plt
 # CHECK: [[#@LINE+1]]:14: error: unsupported relocation type
 paddi 3, 13, foo at toc, 0
 
+# CHECK: [[#@LINE+1]]:15: error: unsupported relocation type
+ld %r5, p_end - .(%r5)
+
 # CHECK: [[#@LINE+1]]:7: error: unsupported relocation type
 .quad foo at toc


        


More information about the llvm-commits mailing list