Skip to content

[LoongArch][MC] Support to get the FixupKind for BL #72938

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

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

zhaoqi5
Copy link
Contributor

@zhaoqi5 zhaoqi5 commented Nov 21, 2023

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

Fixes #72826.

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

Fixes llvm#72826.
@llvmbot
Copy link
Member

llvmbot commented Nov 21, 2023

@llvm/pr-subscribers-backend-loongarch

Author: ZhaoQi (zhaoqi5)

Changes

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

Fixes #72826.


Full diff: https://github.com/llvm/llvm-project/pull/72938.diff

2 Files Affected:

  • (modified) llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp (+1)
  • (modified) llvm/test/CodeGen/LoongArch/test_bl_fixupkind.mir (+2-6)
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"

@SixWeining SixWeining merged commit 775d2f3 into llvm:main Nov 21, 2023
@zhaoqi5 zhaoqi5 deleted the get-fixupkind-for-bl branch November 23, 2023 06:17
leecheechen pushed a commit to leecheechen/llvm-project that referenced this pull request Jun 9, 2025
Previously, bolt could not get FixupKind for BL correctly, because bolt
cannot get target-flags for BL. Here just add support in MCCodeEmitter.

Fixes llvm#72826.

(cherry picked from commit 775d2f3)
Change-Id: Ia7e4174f6fcc4a64f7d1d3b10ed24e457fc08886
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants