[llvm] r298932 - Revert "Dont emit Mapping symbols for sections that contain only data."
Weiming Zhao via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 28 10:15:12 PDT 2017
Author: weimingz
Date: Tue Mar 28 12:15:11 2017
New Revision: 298932
URL: http://llvm.org/viewvc/llvm-project?rev=298932&view=rev
Log:
Revert "Dont emit Mapping symbols for sections that contain only data."
It breaks some lld tests.
This reverts commit 3a50eea6d9732ab40e9a7aebe6be777b53a8b35c.
Removed:
llvm/trunk/test/MC/ARM/Inputs/1.s
llvm/trunk/test/MC/ARM/Inputs/2.s
llvm/trunk/test/MC/ARM/Inputs/3.s
llvm/trunk/test/MC/ARM/Inputs/4.s
llvm/trunk/test/MC/ARM/Inputs/5.s
llvm/trunk/test/MC/ARM/Inputs/6.s
llvm/trunk/test/MC/ARM/Inputs/7.s
llvm/trunk/test/MC/ARM/Inputs/attr.s
llvm/trunk/test/MC/ARM/Inputs/ident.s
llvm/trunk/test/MC/ARM/mappingsymbols.s
Modified:
llvm/trunk/include/llvm/MC/MCELFStreamer.h
llvm/trunk/include/llvm/MC/MCObjectStreamer.h
llvm/trunk/lib/MC/MCELFStreamer.cpp
llvm/trunk/lib/MC/MCObjectStreamer.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
llvm/trunk/test/MC/ARM/data-in-code.ll
llvm/trunk/test/MC/ARM/multi-section-mapping.s
llvm/trunk/test/Object/ARM/nm-mapping-symbol.s
Modified: llvm/trunk/include/llvm/MC/MCELFStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCELFStreamer.h?rev=298932&r1=298931&r2=298932&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCELFStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCELFStreamer.h Tue Mar 28 12:15:11 2017
@@ -42,7 +42,6 @@ public:
void InitSections(bool NoExecStack) override;
void ChangeSection(MCSection *Section, const MCExpr *Subsection) override;
void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
- void EmitLabel(MCSymbol *Symbol, SMLoc Loc, MCFragment *F) override;
void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
void EmitThumbFunc(MCSymbol *Func) override;
void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
Modified: llvm/trunk/include/llvm/MC/MCObjectStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectStreamer.h?rev=298932&r1=298931&r2=298932&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectStreamer.h Tue Mar 28 12:15:11 2017
@@ -90,7 +90,6 @@ public:
/// @{
void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
- virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc, MCFragment *F);
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
void EmitValueImpl(const MCExpr *Value, unsigned Size,
SMLoc Loc = SMLoc()) override;
Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=298932&r1=298931&r2=298932&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Tue Mar 28 12:15:11 2017
@@ -103,16 +103,6 @@ void MCELFStreamer::EmitLabel(MCSymbol *
Symbol->setType(ELF::STT_TLS);
}
-void MCELFStreamer::EmitLabel(MCSymbol *S, SMLoc Loc, MCFragment *F) {
- auto *Symbol = cast<MCSymbolELF>(S);
- MCObjectStreamer::EmitLabel(Symbol, Loc, F);
-
- const MCSectionELF &Section =
- static_cast<const MCSectionELF &>(*getCurrentSectionOnly());
- if (Section.getFlags() & ELF::SHF_TLS)
- Symbol->setType(ELF::STT_TLS);
-}
-
void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
// Let the target do whatever target specific stuff it needs to do.
getAssembler().getBackend().handleAssemblerFlag(Flag);
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=298932&r1=298931&r2=298932&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Tue Mar 28 12:15:11 2017
@@ -171,16 +171,6 @@ void MCObjectStreamer::EmitLabel(MCSymbo
}
}
-void MCObjectStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc, MCFragment *F) {
- MCStreamer::EmitLabel(Symbol, Loc);
- getAssembler().registerSymbol(*Symbol);
- auto *DF = dyn_cast_or_null<MCDataFragment>(F);
- if (DF)
- Symbol->setFragment(F);
- else
- PendingLabels.push_back(Symbol);
-}
-
void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value) {
int64_t IntValue;
if (Value->evaluateAsAbsolute(IntValue, getAssembler())) {
@@ -501,8 +491,8 @@ void MCObjectStreamer::EmitGPRel32Value(
MCDataFragment *DF = getOrCreateDataFragment();
flushPendingLabels(DF, DF->getContents().size());
- DF->getFixups().push_back(
- MCFixup::create(DF->getContents().size(), Value, FK_GPRel_4));
+ DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
+ Value, FK_GPRel_4));
DF->getContents().resize(DF->getContents().size() + 4, 0);
}
@@ -511,8 +501,8 @@ void MCObjectStreamer::EmitGPRel64Value(
MCDataFragment *DF = getOrCreateDataFragment();
flushPendingLabels(DF, DF->getContents().size());
- DF->getFixups().push_back(
- MCFixup::create(DF->getContents().size(), Value, FK_GPRel_4));
+ DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
+ Value, FK_GPRel_4));
DF->getContents().resize(DF->getContents().size() + 8, 0);
}
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp?rev=298932&r1=298931&r2=298932&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp Tue Mar 28 12:15:11 2017
@@ -464,14 +464,13 @@ public:
void emitUnwindRaw(int64_t Offset, const SmallVectorImpl<uint8_t> &Opcodes);
void ChangeSection(MCSection *Section, const MCExpr *Subsection) override {
- LastMappingSymbols[getPreviousSection().first] = std::move(LastEMSInfo);
+ // We have to keep track of the mapping symbol state of any sections we
+ // use. Each one should start off as EMS_None, which is provided as the
+ // default constructor by DenseMap::lookup.
+ LastMappingSymbols[getPreviousSection().first] = LastEMS;
+ LastEMS = LastMappingSymbols.lookup(Section);
+
MCELFStreamer::ChangeSection(Section, Subsection);
- auto LastMappingSymbol = LastMappingSymbols.find(Section);
- if (LastMappingSymbol != LastMappingSymbols.end()) {
- LastEMSInfo = std::move(LastMappingSymbol->second);
- return;
- }
- LastEMSInfo.reset(new ElfMappingSymbolInfo(SMLoc(), nullptr, 0));
}
/// This function is the one used to emit instruction data into the ELF
@@ -533,14 +532,6 @@ public:
MCELFStreamer::EmitBytes(Data);
}
- void FlushPendingMappingSymbol() {
- if (!LastEMSInfo->hasInfo())
- return;
- ElfMappingSymbolInfo *EMS = LastEMSInfo.get();
- EmitMappingSymbol("$d", EMS->Loc, EMS->F, EMS->Offset);
- EMS->resetInfo();
- }
-
/// This is one of the functions used to emit data into an ELF section, so the
/// ARM streamer overrides it to add the appropriate mapping symbol ($d) if
/// necessary.
@@ -582,54 +573,22 @@ private:
EMS_Data
};
- struct ElfMappingSymbolInfo {
- explicit ElfMappingSymbolInfo(SMLoc Loc, MCFragment *F, uint64_t O)
- : Loc(Loc), F(F), Offset(O), State(EMS_None) {}
- void resetInfo() {
- F = nullptr;
- Offset = 0;
- }
- bool hasInfo() { return F != nullptr; }
- SMLoc Loc;
- MCFragment *F;
- uint64_t Offset;
- ElfMappingSymbol State;
- };
-
void EmitDataMappingSymbol() {
- if (LastEMSInfo->State == EMS_Data)
- return;
- else if (LastEMSInfo->State == EMS_None) {
- // This is a tentative symbol, it won't really be emitted until it's
- // actually needed.
- ElfMappingSymbolInfo *EMS = LastEMSInfo.get();
- auto *DF = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
- if (!DF)
- return;
- EMS->Loc = SMLoc();
- EMS->F = getCurrentFragment();
- EMS->Offset = DF->getContents().size();
- LastEMSInfo->State = EMS_Data;
- return;
- }
+ if (LastEMS == EMS_Data) return;
EmitMappingSymbol("$d");
- LastEMSInfo->State = EMS_Data;
+ LastEMS = EMS_Data;
}
void EmitThumbMappingSymbol() {
- if (LastEMSInfo->State == EMS_Thumb)
- return;
- FlushPendingMappingSymbol();
+ if (LastEMS == EMS_Thumb) return;
EmitMappingSymbol("$t");
- LastEMSInfo->State = EMS_Thumb;
+ LastEMS = EMS_Thumb;
}
void EmitARMMappingSymbol() {
- if (LastEMSInfo->State == EMS_ARM)
- return;
- FlushPendingMappingSymbol();
+ if (LastEMS == EMS_ARM) return;
EmitMappingSymbol("$a");
- LastEMSInfo->State = EMS_ARM;
+ LastEMS = EMS_ARM;
}
void EmitMappingSymbol(StringRef Name) {
@@ -642,17 +601,6 @@ private:
Symbol->setExternal(false);
}
- void EmitMappingSymbol(StringRef Name, SMLoc Loc, MCFragment *F,
- uint64_t Offset) {
- auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
- Name + "." + Twine(MappingSymbolCounter++)));
- EmitLabel(Symbol, Loc, F);
- Symbol->setType(ELF::STT_NOTYPE);
- Symbol->setBinding(ELF::STB_LOCAL);
- Symbol->setExternal(false);
- Symbol->setOffset(Offset);
- }
-
void EmitThumbFunc(MCSymbol *Func) override {
getAssembler().setIsThumbFunc(Func);
EmitSymbolAttribute(Func, MCSA_ELF_TypeFunction);
@@ -678,10 +626,8 @@ private:
bool IsThumb;
int64_t MappingSymbolCounter = 0;
- DenseMap<const MCSection *, std::unique_ptr<ElfMappingSymbolInfo>>
- LastMappingSymbols;
-
- std::unique_ptr<ElfMappingSymbolInfo> LastEMSInfo;
+ DenseMap<const MCSection *, ElfMappingSymbol> LastMappingSymbols;
+ ElfMappingSymbol LastEMS = EMS_None;
// ARM Exception Handling Frame Information
MCSymbol *ExTab;
Removed: llvm/trunk/test/MC/ARM/Inputs/1.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/Inputs/1.s?rev=298931&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/Inputs/1.s (original)
+++ llvm/trunk/test/MC/ARM/Inputs/1.s (removed)
@@ -1,3 +0,0 @@
- .section .foobar,"ax",%progbits
- nop
- .word 32
Removed: llvm/trunk/test/MC/ARM/Inputs/2.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/Inputs/2.s?rev=298931&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/Inputs/2.s (original)
+++ llvm/trunk/test/MC/ARM/Inputs/2.s (removed)
@@ -1,3 +0,0 @@
- .section .foobar,"",%progbits
- nop
- .word 32
Removed: llvm/trunk/test/MC/ARM/Inputs/3.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/Inputs/3.s?rev=298931&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/Inputs/3.s (original)
+++ llvm/trunk/test/MC/ARM/Inputs/3.s (removed)
@@ -1,3 +0,0 @@
- .section .foobar,"aw",%progbits
- nop
- .word 32
Removed: llvm/trunk/test/MC/ARM/Inputs/4.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/Inputs/4.s?rev=298931&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/Inputs/4.s (original)
+++ llvm/trunk/test/MC/ARM/Inputs/4.s (removed)
@@ -1,2 +0,0 @@
- .section .foobar,"",%progbits
- .word 32
Removed: llvm/trunk/test/MC/ARM/Inputs/5.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/Inputs/5.s?rev=298931&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/Inputs/5.s (original)
+++ llvm/trunk/test/MC/ARM/Inputs/5.s (removed)
@@ -1,2 +0,0 @@
- .section .foobar,"aw",%progbits
- .word 32
Removed: llvm/trunk/test/MC/ARM/Inputs/6.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/Inputs/6.s?rev=298931&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/Inputs/6.s (original)
+++ llvm/trunk/test/MC/ARM/Inputs/6.s (removed)
@@ -1,12 +0,0 @@
- .section .foo
- .word 30
- .word 31
- .word 32
- .word 33
- nop
- .word 34
- .word 35
- .word 36
- .word 37
- .word 38
- nop
Removed: llvm/trunk/test/MC/ARM/Inputs/7.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/Inputs/7.s?rev=298931&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/Inputs/7.s (original)
+++ llvm/trunk/test/MC/ARM/Inputs/7.s (removed)
@@ -1,3 +0,0 @@
- .section .foobar,"aw",%progbits
- .word 32
- nop
Removed: llvm/trunk/test/MC/ARM/Inputs/attr.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/Inputs/attr.s?rev=298931&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/Inputs/attr.s (original)
+++ llvm/trunk/test/MC/ARM/Inputs/attr.s (removed)
@@ -1,5 +0,0 @@
- .text
- .syntax unified
- .eabi_attribute 67, "2.09" @ Tag_conformance
- .cpu arm7tdmi
- .eabi_attribute 6, 2 @ Tag_CPU_arch
Removed: llvm/trunk/test/MC/ARM/Inputs/ident.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/Inputs/ident.s?rev=298931&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/Inputs/ident.s (original)
+++ llvm/trunk/test/MC/ARM/Inputs/ident.s (removed)
@@ -1 +0,0 @@
- .ident "LLVM ARM Compiler"
Modified: llvm/trunk/test/MC/ARM/data-in-code.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/data-in-code.ll?rev=298932&r1=298931&r2=298932&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/data-in-code.ll (original)
+++ llvm/trunk/test/MC/ARM/data-in-code.ll Tue Mar 28 12:15:11 2017
@@ -60,6 +60,23 @@ exit:
;; ARM-NEXT: Other:
;; ARM-NEXT: Section: [[MIXED_SECT]]
+;; ARM: Symbol {
+;; ARM: Name: $d
+;; ARM-NEXT: Value: 0x0
+;; ARM-NEXT: Size: 0
+;; ARM-NEXT: Binding: Local (0x0)
+;; ARM-NEXT: Type: None (0x0)
+;; ARM-NEXT: Other: 0
+;; ARM-NEXT: Section: .ARM.exidx
+;; ARM-NEXT: }
+
+;; ARM: Symbol {
+;; ARM: Name: $d
+;; ARM-NEXT: Value: 0
+;; ARM-NEXT: Size: 0
+;; ARM-NEXT: Binding: Local
+;; ARM-NEXT: Type: None
+
;; ARM-NOT: ${{[atd]}}
;; TMB: Symbol {
Removed: llvm/trunk/test/MC/ARM/mappingsymbols.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/mappingsymbols.s?rev=298931&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/mappingsymbols.s (original)
+++ llvm/trunk/test/MC/ARM/mappingsymbols.s (removed)
@@ -1,48 +0,0 @@
-# Check section containing code and data with permission executable for the section.
-@ RUN: llvm-mc -triple armv7-none-linux -filetype=obj -o %t.o %p/Inputs/1.s
-@ RUN: llvm-readobj -elf-output-style=GNU -symbols %t.o | FileCheck %s
-
-# Check section containing code and data with no permissions for the section.
-@ RUN: llvm-mc -triple armv7-none-linux -filetype=obj -o %t.o %p/Inputs/2.s
-@ RUN: llvm-readobj -elf-output-style=GNU -symbols %t.o | FileCheck %s
-
-# Check section containing code and data with read/write permissions for the section.
-@ RUN: llvm-mc -triple armv7-none-linux -filetype=obj -o %t.o %p/Inputs/3.s
-@ RUN: llvm-readobj -elf-output-style=GNU -symbols %t.o | FileCheck %s
-
-# Check section containing data with no permissions for the section.
-@ RUN: llvm-mc -triple armv7-none-linux -filetype=obj -o %t.o %p/Inputs/4.s
-@ RUN: llvm-readobj -elf-output-style=GNU -symbols %t.o | FileCheck %s -check-prefix=MAPPINGSYMBOLS
-
-# Check section containing only data with read/write permissions for the section.
-@ RUN: llvm-mc -triple armv7-none-linux -filetype=obj -o %t.o %p/Inputs/5.s
-@ RUN: llvm-readobj -elf-output-style=GNU -symbols %t.o | FileCheck %s -check-prefix=MAPPINGSYMBOLS
-
-# Check section containing the ident string with no permissions for the section.
-@ RUN: llvm-mc -triple armv7-none-linux -filetype=obj -o %t.o %p/Inputs/ident.s
-@ RUN: llvm-readobj -elf-output-style=GNU -symbols %t.o | FileCheck %s -check-prefix=MAPPINGSYMBOLS
-
-# Check section containing the attributes with no permissions for the section.
-@ RUN: llvm-mc -triple armv7-none-linux -filetype=obj -o %t.o %p/Inputs/attr.s
-@ RUN: llvm-readobj -elf-output-style=GNU -symbols %t.o | FileCheck %s -check-prefix=MAPPINGSYMBOLS
-
-# Check section containing code and data with no permissions for the section.
-# data comes before code.
-@ RUN: llvm-mc -triple armv7-none-linux -filetype=obj -o %t.o %p/Inputs/6.s
-@ RUN: llvm-readobj -elf-output-style=GNU -symbols %t.o | FileCheck %s -check-prefix=MIX
-
-# Check section containing code and data with no permissions for the section.
-# data comes before code.
-@ RUN: llvm-mc -triple armv7-none-linux -filetype=obj -o %t.o %p/Inputs/7.s
-@ RUN: llvm-readobj -elf-output-style=GNU -symbols %t.o | FileCheck %s
-
-#CHECK: $a
-#CHECK: $d
-
-#MIX: $a
-#MIX: $a
-#MIX: $d
-#MIX: $d
-
-#MAPPINGSYMBOLS-NOT: $a
-#MAPPINGSYMBOLS-NOT: $d
Modified: llvm/trunk/test/MC/ARM/multi-section-mapping.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/multi-section-mapping.s?rev=298932&r1=298931&r2=298932&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/multi-section-mapping.s (original)
+++ llvm/trunk/test/MC/ARM/multi-section-mapping.s Tue Mar 28 12:15:11 2017
@@ -29,6 +29,7 @@
@ CHECK: 00000000 .text 00000000 $a
@ CHECK-NEXT: 00000000 .wibble 00000000 $a
+@ CHECK-NEXT: 00000000 .starts_data 00000000 $d
@ CHECK-NEXT: 00000000 .starts_thumb 00000000 $t
@ CHECK-NOT: ${{[adt]}}
Modified: llvm/trunk/test/Object/ARM/nm-mapping-symbol.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/ARM/nm-mapping-symbol.s?rev=298932&r1=298931&r2=298932&view=diff
==============================================================================
--- llvm/trunk/test/Object/ARM/nm-mapping-symbol.s (original)
+++ llvm/trunk/test/Object/ARM/nm-mapping-symbol.s Tue Mar 28 12:15:11 2017
@@ -9,4 +9,3 @@
.section .foobar,"",%progbits
.asciz "foo"
- nop
More information about the llvm-commits
mailing list