[llvm] abcd19e - MIPS: Register .set created symbols
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon May 26 18:45:10 PDT 2025
Author: Fangrui Song
Date: 2025-05-26T18:45:05-07:00
New Revision: abcd19e7d9acd54c10027ed4a68909ea5cf0e96c
URL: https://github.com/llvm/llvm-project/commit/abcd19e7d9acd54c10027ed4a68909ea5cf0e96c
DIFF: https://github.com/llvm/llvm-project/commit/abcd19e7d9acd54c10027ed4a68909ea5cf0e96c.diff
LOG: MIPS: Register .set created symbols
When the `.set` directive is used to equate a symbol (`.set symbol,
expression`), ensure the created symbol is registered in the symbol
table.
Added:
Modified:
llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/test/MC/Mips/set-defined-symbol.s
llvm/test/MC/Mips/set-sym-recursive.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 9e839d589323f..d1b94410c601a 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -7507,7 +7507,7 @@ bool MipsAsmParser::parseSetAssignment() {
if (MCParserUtils::parseAssignmentExpression(Name, /* allow_redef */ true,
Parser, Sym, Value))
return true;
- Sym->setVariableValue(Value);
+ getStreamer().emitAssignment(Sym, Value);
return false;
}
diff --git a/llvm/test/MC/Mips/set-defined-symbol.s b/llvm/test/MC/Mips/set-defined-symbol.s
index dd7924427c19e..1521e99a75f06 100644
--- a/llvm/test/MC/Mips/set-defined-symbol.s
+++ b/llvm/test/MC/Mips/set-defined-symbol.s
@@ -16,3 +16,7 @@ b:
# CHECK-NOT: b:
# CHECK-NOT: foo:
# CHECK: <bar>:
+
+# CHECK: <dot>:
+.set dot, .
+ nop
diff --git a/llvm/test/MC/Mips/set-sym-recursive.s b/llvm/test/MC/Mips/set-sym-recursive.s
index 85e468db1a294..0db3c05c32f55 100644
--- a/llvm/test/MC/Mips/set-sym-recursive.s
+++ b/llvm/test/MC/Mips/set-sym-recursive.s
@@ -1,9 +1,11 @@
# RUN: not llvm-mc -filetype=obj -triple=mips64 %s -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
-.set B, B + 1
-
# CHECK: :[[@LINE+1]]:11: error: cyclic dependency detected for symbol 'A'
.set A, A + 1
# CHECK: :[[@LINE+1]]:7: error: expected relocatable expression
.word A
.word A
+
+# CHECK: :[[@LINE+2]]:11: error: cyclic dependency detected for symbol 'B'
+# CHECK: :[[@LINE+1]]:11: error: expression could not be evaluated
+.set B, B + 1
More information about the llvm-commits
mailing list