Skip to content

Commit ed2b82f

Browse files
committed
MCValue: Change getAccessVariant to return uint16_t
Some targets encode the relocation specifier within SymA using MCSymbolRefExpr::SubclassData. They will cast the specifier to *MCExpr::Specifier. Migrate away from the confusing MCSymbolRefExpr::VariantKind. Note: getAccessVariant is a deprecated method to get the relocation specifier.
1 parent 5e8f438 commit ed2b82f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

llvm/include/llvm/MC/MCValue.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ class MCValue {
6565
/// Print the value to stderr.
6666
void dump() const;
6767

68-
MCSymbolRefExpr::VariantKind getAccessVariant() const;
68+
// Get the relocation specifier from SymA. This is a workaround for targets
69+
// that do not use MCValue::Specifier.
70+
uint16_t getAccessVariant() const;
6971

7072
static MCValue get(const MCSymbolRefExpr *SymA,
7173
const MCSymbolRefExpr *SymB = nullptr,

llvm/lib/MC/MCValue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ LLVM_DUMP_METHOD void MCValue::dump() const {
4444
}
4545
#endif
4646

47-
MCSymbolRefExpr::VariantKind MCValue::getAccessVariant() const {
47+
uint16_t MCValue::getAccessVariant() const {
4848
const MCSymbolRefExpr *A = getSymA();
4949
if (!A)
50-
return MCSymbolRefExpr::VK_None;
50+
return 0;
5151

52-
return A->getKind();
52+
return A->getSpecifier();
5353
}

llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ unsigned WebAssemblyWasmObjectWriter::getRelocType(
6969
assert(RefA);
7070
auto& SymA = cast<MCSymbolWasm>(RefA->getSymbol());
7171

72-
MCSymbolRefExpr::VariantKind Modifier = Target.getAccessVariant();
72+
auto Modifier = Target.getAccessVariant();
7373

7474
switch (Modifier) {
7575
case MCSymbolRefExpr::VK_GOT:

0 commit comments

Comments
 (0)