[llvm] [AMDGPU][MC] Allow UC_VERSION_* constant reuse (PR #96461)
    Jay Foad via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Jun 24 05:01:05 PDT 2024
    
    
  
================
@@ -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;
----------------
jayfoad wrote:
This makes me question whether implementing `UC_VERSION_*` as symbols _that the user can redefine_ was the best choice in the first place. But I don't have any alternative suggestion.
https://github.com/llvm/llvm-project/pull/96461
    
    
More information about the llvm-commits
mailing list