[llvm] ed2b82f - MCValue: Change getAccessVariant to return uint16_t
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 5 12:12:16 PDT 2025
Author: Fangrui Song
Date: 2025-04-05T12:12:11-07:00
New Revision: ed2b82fb8b066f8c269be9e403ee20d86b5ead8a
URL: https://github.com/llvm/llvm-project/commit/ed2b82fb8b066f8c269be9e403ee20d86b5ead8a
DIFF: https://github.com/llvm/llvm-project/commit/ed2b82fb8b066f8c269be9e403ee20d86b5ead8a.diff
LOG: 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.
Added:
Modified:
llvm/include/llvm/MC/MCValue.h
llvm/lib/MC/MCValue.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCValue.h b/llvm/include/llvm/MC/MCValue.h
index 6e37fb56ab27f..cb89e245f2887 100644
--- a/llvm/include/llvm/MC/MCValue.h
+++ b/llvm/include/llvm/MC/MCValue.h
@@ -65,7 +65,9 @@ class MCValue {
/// Print the value to stderr.
void dump() const;
- MCSymbolRefExpr::VariantKind getAccessVariant() const;
+ // Get the relocation specifier from SymA. This is a workaround for targets
+ // that do not use MCValue::Specifier.
+ uint16_t getAccessVariant() const;
static MCValue get(const MCSymbolRefExpr *SymA,
const MCSymbolRefExpr *SymB = nullptr,
diff --git a/llvm/lib/MC/MCValue.cpp b/llvm/lib/MC/MCValue.cpp
index 8b2edc9ac57ec..b7ac3f247ecf9 100644
--- a/llvm/lib/MC/MCValue.cpp
+++ b/llvm/lib/MC/MCValue.cpp
@@ -44,10 +44,10 @@ LLVM_DUMP_METHOD void MCValue::dump() const {
}
#endif
-MCSymbolRefExpr::VariantKind MCValue::getAccessVariant() const {
+uint16_t MCValue::getAccessVariant() const {
const MCSymbolRefExpr *A = getSymA();
if (!A)
- return MCSymbolRefExpr::VK_None;
+ return 0;
- return A->getKind();
+ return A->getSpecifier();
}
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
index 7a5ebe342fccf..941422891832d 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
@@ -69,7 +69,7 @@ unsigned WebAssemblyWasmObjectWriter::getRelocType(
assert(RefA);
auto& SymA = cast<MCSymbolWasm>(RefA->getSymbol());
- MCSymbolRefExpr::VariantKind Modifier = Target.getAccessVariant();
+ auto Modifier = Target.getAccessVariant();
switch (Modifier) {
case MCSymbolRefExpr::VK_GOT:
More information about the llvm-commits
mailing list