[llvm] [AMDGPU][MC] Allow UC_VERSION_* constant reuse (PR #96461)

Ivan Kosarev via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 2 03:57:36 PDT 2024


================
@@ -2362,12 +2369,17 @@ Expected<bool> AMDGPUDisassembler::onSymbolStart(SymbolInfoTy &Symbol,
   return false;
 }
 
-const MCExpr *AMDGPUDisassembler::createConstantSymbolExpr(StringRef Id,
-                                                           int64_t Val) {
+const MCSymbolRefExpr *
+AMDGPUDisassembler::createConstantSymbolExpr(StringRef Id, int64_t Val) {
   MCContext &Ctx = getContext();
   MCSymbol *Sym = Ctx.getOrCreateSymbol(Id);
-  assert(!Sym->isVariable());
-  Sym->setVariableValue(MCConstantExpr::create(Val, Ctx));
+  // Note: only set value to Val on a new symbol.
+  // Existing symbol may potentially have a different value to the one
+  // requested, which allows for user redefinition of symbols.
+  if (!Sym->isVariable()) {
+    Sym->setRedefinable(true);
----------------
kosarev wrote:

Why is this call necessary?

https://github.com/llvm/llvm-project/pull/96461


More information about the llvm-commits mailing list