Skip to content

Commit 5ca8bbd

Browse files
committed
[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.
1 parent 135483b commit 5ca8bbd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,8 +2366,12 @@ const MCExpr *AMDGPUDisassembler::createConstantSymbolExpr(StringRef Id,
23662366
int64_t Val) {
23672367
MCContext &Ctx = getContext();
23682368
MCSymbol *Sym = Ctx.getOrCreateSymbol(Id);
2369-
assert(!Sym->isVariable());
2370-
Sym->setVariableValue(MCConstantExpr::create(Val, Ctx));
2369+
int64_t Res = ~Val;
2370+
assert(!Sym->isVariable() ||
2371+
(Sym->getVariableValue()->evaluateAsAbsolute(Res) && Res == Val));
2372+
(void)Res;
2373+
if (!Sym->isVariable())
2374+
Sym->setVariableValue(MCConstantExpr::create(Val, Ctx));
23712375
return MCSymbolRefExpr::create(Sym, Ctx);
23722376
}
23732377

0 commit comments

Comments
 (0)