[llvm] [LoongArch][MC] Support to get the FixupKind for BL (PR #72938)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 20 17:57:16 PST 2023


https://github.com/zhaoqi5 created https://github.com/llvm/llvm-project/pull/72938

Previously, bolt could not get FixupKind for BL correctly, because bolt cannot get target-flags for BL. Here just add support in MCCodeEmitter.

Fixes https://github.com/llvm/llvm-project/pull/72826.

>From 134e174fb07503bf8ddfa6db88c1a961563a9f66 Mon Sep 17 00:00:00 2001
From: zhaoqi <zhaoqi01 at loongson.cn>
Date: Wed, 25 Oct 2023 15:12:00 +0800
Subject: [PATCH] [LoongArch][MC] Support to get the FixupKind for BL

Previously, bolt could not get FixupKind for BL correctly, because
bolt cannot get target-flags for BL. Here just add support in
MCCodeEmitter.

Fixes https://github.com/llvm/llvm-project/pull/72826.
---
 .../LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp     | 1 +
 llvm/test/CodeGen/LoongArch/test_bl_fixupkind.mir         | 8 ++------
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
index fbe817a2b5475a2..45169becca37b75 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
@@ -259,6 +259,7 @@ LoongArchMCCodeEmitter::getExprOpValue(const MCInst &MI, const MCOperand &MO,
       FixupKind = LoongArch::fixup_loongarch_b21;
       break;
     case LoongArch::B:
+    case LoongArch::BL:
       FixupKind = LoongArch::fixup_loongarch_b26;
       break;
     }
diff --git a/llvm/test/CodeGen/LoongArch/test_bl_fixupkind.mir b/llvm/test/CodeGen/LoongArch/test_bl_fixupkind.mir
index 2c1d41be77112f0..70cd5fb8d7eb690 100644
--- a/llvm/test/CodeGen/LoongArch/test_bl_fixupkind.mir
+++ b/llvm/test/CodeGen/LoongArch/test_bl_fixupkind.mir
@@ -1,14 +1,10 @@
-## Tagged as "Expectedly Failed" until the following patch fix it
-# XFAIL: *
 # RUN: llc --mtriple=loongarch64 --filetype=obj %s -o - | \
 # RUN: llvm-objdump -d - | FileCheck %s
 
 # REQUIRES: asserts
 
-## Check that bl can get fixupkind correctly.
-## When BL has target-flags(loongarch-call), there is no error. But without
-## this flag, an assertion error will appear:
-## Assertion `FixupKind != LoongArch::fixup_loongarch_invalid && "Unhandled expression!"' failed.
+## Check that bl can get fixupkind correctly, whether BL contains
+## target-flags(loongarch-call) or not.
 
 --- |
   target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"



More information about the llvm-commits mailing list