Skip to content

Commit ca5b3a0

Browse files
committed
[MC] Remove SetUsed on isUndefined and getFragment
Due to the known limitations of .set reassignment (see https://sourceware.org/PR288), we use diagnostics to reject patterns that could lead to errors (ae7ac01 2009-06)). This code gets refined multiple times, see: * 9b4a824 (2010-05) `IsUsedInExpr` * 46c79ef (2010-11) renamed `IsUsedInExpr` to `IsUsed` The related `SetUsed` bit seems unnecessary nowadays.
1 parent 1c5ce2d commit ca5b3a0

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

llvm/include/llvm/MC/MCSymbol.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,7 @@ class MCSymbol {
257257
}
258258

259259
/// isUndefined - Check if this symbol undefined (i.e., implicitly defined).
260-
bool isUndefined(bool SetUsed = true) const {
261-
return getFragment(SetUsed) == nullptr;
262-
}
260+
bool isUndefined() const { return getFragment() == nullptr; }
263261

264262
/// isAbsolute - Check if this is an absolute symbol.
265263
bool isAbsolute() const {
@@ -395,7 +393,7 @@ class MCSymbol {
395393
return SymbolContents == SymContentsTargetCommon;
396394
}
397395

398-
MCFragment *getFragment(bool SetUsed = true) const {
396+
MCFragment *getFragment(bool SetUsed = false) const {
399397
if (Fragment || !isVariable() || isWeakExternal())
400398
return Fragment;
401399
// If the symbol is a non-weak alias, get information about

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5284,9 +5284,9 @@ bool AsmParser::parseDirectiveIfdef(SMLoc DirectiveLoc, bool expect_defined) {
52845284
MCSymbol *Sym = getContext().lookupSymbol(Name);
52855285

52865286
if (expect_defined)
5287-
TheCondState.CondMet = (Sym && !Sym->isUndefined(false));
5287+
TheCondState.CondMet = (Sym && !Sym->isUndefined());
52885288
else
5289-
TheCondState.CondMet = (!Sym || Sym->isUndefined(false));
5289+
TheCondState.CondMet = (!Sym || Sym->isUndefined());
52905290
TheCondState.Ignore = !TheCondState.CondMet;
52915291
}
52925292

@@ -6362,8 +6362,7 @@ bool parseAssignmentExpression(StringRef Name, bool allow_redef,
63626362
// FIXME: Diagnose assignment to protected identifier (e.g., register name).
63636363
if (Value->isSymbolUsedInExpression(Sym))
63646364
return Parser.Error(EqualLoc, "Recursive use of '" + Name + "'");
6365-
else if (Sym->isUndefined(/*SetUsed*/ false) && !Sym->isUsed() &&
6366-
!Sym->isVariable())
6365+
else if (Sym->isUndefined() && !Sym->isUsed() && !Sym->isVariable())
63676366
; // Allow redefinitions of undefined symbols only used in directives.
63686367
else if (Sym->isVariable() && !Sym->isUsed() && allow_redef)
63696368
; // Allow redefinitions of variables that haven't yet been used.

llvm/lib/MC/MCParser/MasmParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4761,7 +4761,7 @@ bool MasmParser::parseDirectiveIfdef(SMLoc DirectiveLoc, bool expect_defined) {
47614761
is_defined = true;
47624762
} else {
47634763
MCSymbol *Sym = getContext().lookupSymbol(Name.lower());
4764-
is_defined = (Sym && !Sym->isUndefined(false));
4764+
is_defined = (Sym && !Sym->isUndefined());
47654765
}
47664766
}
47674767

@@ -4882,7 +4882,7 @@ bool MasmParser::parseDirectiveElseIfdef(SMLoc DirectiveLoc,
48824882
is_defined = true;
48834883
} else {
48844884
MCSymbol *Sym = getContext().lookupSymbol(Name);
4885-
is_defined = (Sym && !Sym->isUndefined(false));
4885+
is_defined = (Sym && !Sym->isUndefined());
48864886
}
48874887
}
48884888

@@ -5052,7 +5052,7 @@ bool MasmParser::parseDirectiveErrorIfdef(SMLoc DirectiveLoc,
50525052
IsDefined = true;
50535053
} else {
50545054
MCSymbol *Sym = getContext().lookupSymbol(Name);
5055-
IsDefined = (Sym && !Sym->isUndefined(false));
5055+
IsDefined = (Sym && !Sym->isUndefined());
50565056
}
50575057
}
50585058

0 commit comments

Comments
 (0)