llvm.org GIT mirror llvm / e54eacc
MC: Label definitions are permitted after .set directives .set directives may be overridden by other .set directives as well as label definitions. This fixes PR22019. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224811 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 5 years ago
5 changed file(s) with 49 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
5252 /// "Lfoo" or ".foo".
5353 unsigned IsTemporary : 1;
5454
55 /// \brief True if this symbol can be redefined.
56 unsigned IsRedefinable : 1;
57
5558 /// IsUsed - True if this symbol has been used.
5659 mutable unsigned IsUsed : 1;
5760
6063 friend class MCContext;
6164 MCSymbol(StringRef name, bool isTemporary)
6265 : Name(name), Section(nullptr), Value(nullptr),
63 IsTemporary(isTemporary), IsUsed(false) {}
66 IsTemporary(isTemporary), IsRedefinable(false), IsUsed(false) {}
6467
6568 MCSymbol(const MCSymbol&) LLVM_DELETED_FUNCTION;
6669 void operator=(const MCSymbol&) LLVM_DELETED_FUNCTION;
7780 /// isUsed - Check if this is used.
7881 bool isUsed() const { return IsUsed; }
7982 void setUsed(bool Value) const { IsUsed = Value; }
83
84 /// \brief Check if this symbol is redefinable.
85 bool isRedefinable() const { return IsRedefinable; }
86 /// \brief Mark this symbol as redefinable.
87 void setRedefinable(bool Value) { IsRedefinable = Value; }
88 /// \brief Prepare this symbol to be redefined.
89 void redefineIfPossible() {
90 if (IsRedefinable) {
91 Value = nullptr;
92 Section = nullptr;
93 IsRedefinable = false;
94 }
95 }
8096
8197 /// @}
8298 /// @name Associated Sections
540540 /// EmitFunctionEntryLabel - Emit the label that is the entrypoint for the
541541 /// function. This can be overridden by targets as required to do custom stuff.
542542 void AsmPrinter::EmitFunctionEntryLabel() {
543 CurrentFnSym->redefineIfPossible();
544
543545 // The function label could have already been emitted if two symbols end up
544546 // conflicting due to asm renaming. Detect this and emit an error.
545547 if (CurrentFnSym->isUndefined())
12971297 Sym = getContext().GetOrCreateSymbol(IDVal);
12981298 } else
12991299 Sym = Ctx.CreateDirectionalLocalSymbol(LocalLabelVal);
1300
1301 Sym->redefineIfPossible();
1302
13001303 if (!Sym->isUndefined() || Sym->isVariable())
13011304 return Error(IDLoc, "invalid symbol redefinition");
13021305
22162219 } else
22172220 Sym = getContext().GetOrCreateSymbol(Name);
22182221
2222 Sym->setRedefinable(allow_redef);
2223
22192224 // Do the assignment.
22202225 Out.EmitAssignment(Sym, Value);
22212226 if (NoDeadStrip)
0 ; RUN: llc < %s | FileCheck %s
1 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
2 target triple = "x86_64-unknown-linux-gnu"
3
4 module asm "pselect = __pselect"
5 ; CHECK: pselect = __pselect
6
7 ; CHECK: pselect:
8 ; CHECK: retq
9 define void @pselect() {
10 ret void
11 }
1818 bar5 = bar4
1919
2020 .long foo2
21
22 // Test that bar6 is a function that doesn't have the same value as foo4.
23 bar6 = bar5
24 bar6:
2125
2226 // CHECK: Symbols [
2327 // CHECK-NEXT: Symbol {
5357 // CHECK-NEXT: Size: 0
5458 // CHECK-NEXT: Binding: Local
5559 // CHECK-NEXT: Type: Function
60 // CHECK-NEXT: Other: 0
61 // CHECK-NEXT: Section: .text
62 // CHECK-NEXT: }
63 // CHECK-NEXT: Symbol {
64 // CHECK-NEXT: Name: bar6
65 // CHECK-NEXT: Value: 0x5
66 // CHECK-NEXT: Size: 0
67 // CHECK-NEXT: Binding: Local
68 // CHECK-NEXT: Type: None
5669 // CHECK-NEXT: Other: 0
5770 // CHECK-NEXT: Section: .text
5871 // CHECK-NEXT: }