[llvm] [AMDGPU][MC] Allow UC_VERSION_* constant reuse (PR #96461)
Carl Ritson via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 24 01:34:55 PDT 2024
https://github.com/perlfu created https://github.com/llvm/llvm-project/pull/96461
If more than one disassembler is created for a context then allow reuse of existing constants.
Update assertion to validate constant contents.
>From 88595f24da33f71db1ea33c08b5e5fdb03a3ab0b Mon Sep 17 00:00:00 2001
From: Carl Ritson <carl.ritson at amd.com>
Date: Mon, 24 Jun 2024 17:32:41 +0900
Subject: [PATCH] [AMDGPU][MC] Allow UC_VERSION_* constant reuse
If more than one disassembler is created for a context then
allow reuse of existing constants.
Update assertion to validate constant contents.
---
.../lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
index 76a559c9443bd..d61e8ebb866df 100644
--- a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
+++ b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
@@ -2366,8 +2366,12 @@ const MCExpr *AMDGPUDisassembler::createConstantSymbolExpr(StringRef Id,
int64_t Val) {
MCContext &Ctx = getContext();
MCSymbol *Sym = Ctx.getOrCreateSymbol(Id);
- assert(!Sym->isVariable());
- Sym->setVariableValue(MCConstantExpr::create(Val, Ctx));
+ int64_t Res = ~Val;
+ assert(!Sym->isVariable() ||
+ (Sym->getVariableValue()->evaluateAsAbsolute(Res) && Res == Val));
+ (void)Res;
+ if (!Sym->isVariable())
+ Sym->setVariableValue(MCConstantExpr::create(Val, Ctx));
return MCSymbolRefExpr::create(Sym, Ctx);
}
More information about the llvm-commits
mailing list