[PATCH] D12347: [MC/AsmParser] Avoid setting MCSymbol.IsUsed
Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 31 10:46:05 PDT 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246457: [MC/AsmParser] Avoid setting MCSymbol.IsUsed in some cases (authored by vedantk).
Changed prior to commit:
http://reviews.llvm.org/D12347?vs=33241&id=33597#toc
Repository:
rL LLVM
http://reviews.llvm.org/D12347
Files:
llvm/trunk/include/llvm/MC/MCSymbol.h
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/test/MC/AsmParser/reassign.s
Index: llvm/trunk/include/llvm/MC/MCSymbol.h
===================================================================
--- llvm/trunk/include/llvm/MC/MCSymbol.h
+++ llvm/trunk/include/llvm/MC/MCSymbol.h
@@ -223,7 +223,7 @@
/// isUsed - Check if this is used.
bool isUsed() const { return IsUsed; }
- void setUsed(bool Value) const { IsUsed = Value; }
+ void setUsed(bool Value) const { IsUsed |= Value; }
/// \brief Check if this symbol is redefinable.
bool isRedefinable() const { return IsRedefinable; }
Index: llvm/trunk/test/MC/AsmParser/reassign.s
===================================================================
--- llvm/trunk/test/MC/AsmParser/reassign.s
+++ llvm/trunk/test/MC/AsmParser/reassign.s
@@ -0,0 +1,12 @@
+// RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+
+ .text
+bar:
+
+ .data
+.globl foo
+.set foo, bar
+.globl foo
+.set foo, bar
+
+// CHECK-NOT: invalid reassignment of non-absolute variable
Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp
@@ -693,9 +693,9 @@
// FIXME: We would really like to refer back to where the symbol was
// first referenced for a source location. We need to add something
// to track that. Currently, we just point to the end of the file.
- printMessage(
- getLexer().getLoc(), SourceMgr::DK_Error,
- "assembler local symbol '" + Sym->getName() + "' not defined");
+ printMessage(getLexer().getLoc(), SourceMgr::DK_Error,
+ "assembler local symbol '" + Sym->getName() +
+ "' not defined");
}
}
@@ -867,11 +867,12 @@
// If this is an absolute variable reference, substitute it now to preserve
// semantics in the face of reassignment.
- if (Sym->isVariable() && isa<MCConstantExpr>(Sym->getVariableValue())) {
+ if (Sym->isVariable() &&
+ isa<MCConstantExpr>(Sym->getVariableValue(/*SetUsed*/ false))) {
if (Variant)
return Error(EndLoc, "unexpected modifier on variable reference");
- Res = Sym->getVariableValue();
+ Res = Sym->getVariableValue(/*SetUsed*/ false);
return false;
}
@@ -4805,7 +4806,8 @@
// FIXME: Diagnose assignment to protected identifier (e.g., register name).
if (isSymbolUsedInExpression(Sym, Value))
return Parser.Error(EqualLoc, "Recursive use of '" + Name + "'");
- else if (Sym->isUndefined() && !Sym->isUsed() && !Sym->isVariable())
+ else if (Sym->isUndefined(/*SetUsed*/ false) && !Sym->isUsed() &&
+ !Sym->isVariable())
; // Allow redefinitions of undefined symbols only used in directives.
else if (Sym->isVariable() && !Sym->isUsed() && allow_redef)
; // Allow redefinitions of variables that haven't yet been used.
@@ -4817,9 +4819,6 @@
return Parser.Error(EqualLoc,
"invalid reassignment of non-absolute variable '" +
Name + "'");
-
- // Don't count these checks as uses.
- Sym->setUsed(false);
} else if (Name == ".") {
if (Parser.getStreamer().EmitValueToOffset(Value, 0)) {
Parser.Error(EqualLoc, "expected absolute expression");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12347.33597.patch
Type: text/x-patch
Size: 3331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150831/f85ffdac/attachment.bin>
More information about the llvm-commits
mailing list