[llvm] r319956 - [WebAssembly] Remove WASM_STACK_POINTER.
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 6 12:56:40 PST 2017
Author: djg
Date: Wed Dec 6 12:56:40 2017
New Revision: 319956
URL: http://llvm.org/viewvc/llvm-project?rev=319956&view=rev
Log:
[WebAssembly] Remove WASM_STACK_POINTER.
WASM_STACK_POINTER and the .stack_pointer directive are no longer needed
now that the stack pointer global is an import.
Modified:
llvm/trunk/include/llvm/BinaryFormat/Wasm.h
llvm/trunk/lib/MC/WasmObjectWriter.cpp
llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
llvm/trunk/test/CodeGen/WebAssembly/stack-alignment.ll
Modified: llvm/trunk/include/llvm/BinaryFormat/Wasm.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Wasm.h?rev=319956&r1=319955&r2=319956&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Wasm.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Wasm.h Wed Dec 6 12:56:40 2017
@@ -182,7 +182,6 @@ enum class ValType {
// Linking metadata kinds.
enum : unsigned {
- WASM_STACK_POINTER = 0x1,
WASM_SYMBOL_INFO = 0x2,
WASM_DATA_SIZE = 0x3,
WASM_DATA_ALIGNMENT = 0x4,
Modified: llvm/trunk/lib/MC/WasmObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WasmObjectWriter.cpp?rev=319956&r1=319955&r2=319956&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WasmObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WasmObjectWriter.cpp Wed Dec 6 12:56:40 2017
@@ -287,8 +287,7 @@ private:
void writeDataRelocSection();
void writeLinkingMetaDataSection(
ArrayRef<WasmDataSegment> Segments, uint32_t DataSize,
- SmallVector<std::pair<StringRef, uint32_t>, 4> SymbolFlags,
- Optional<uint32_t> StackPointerGlobal);
+ SmallVector<std::pair<StringRef, uint32_t>, 4> SymbolFlags);
uint32_t getProvisionalValue(const WasmRelocationEntry &RelEntry);
void applyRelocations(ArrayRef<WasmRelocationEntry> Relocations,
@@ -929,18 +928,11 @@ void WasmObjectWriter::writeDataRelocSec
void WasmObjectWriter::writeLinkingMetaDataSection(
ArrayRef<WasmDataSegment> Segments, uint32_t DataSize,
- SmallVector<std::pair<StringRef, uint32_t>, 4> SymbolFlags,
- Optional<uint32_t> StackPointerGlobal) {
+ SmallVector<std::pair<StringRef, uint32_t>, 4> SymbolFlags) {
SectionBookkeeping Section;
startSection(Section, wasm::WASM_SEC_CUSTOM, "linking");
SectionBookkeeping SubSection;
- if (StackPointerGlobal.hasValue()) {
- startSection(SubSection, wasm::WASM_STACK_POINTER);
- encodeULEB128(StackPointerGlobal.getValue(), getStream()); // id
- endSection(SubSection);
- }
-
if (SymbolFlags.size() != 0) {
startSection(SubSection, wasm::WASM_SYMBOL_INFO);
encodeULEB128(SymbolFlags.size(), getStream());
@@ -1011,8 +1003,6 @@ void WasmObjectWriter::writeObject(MCAss
SmallPtrSet<const MCSymbolWasm *, 4> IsAddressTaken;
unsigned NumFuncImports = 0;
SmallVector<WasmDataSegment, 4> DataSegments;
- Optional<StringRef> StackPointerGlobalName;
- Optional<uint32_t> StackPointerGlobal;
uint32_t DataSize = 0;
// Populate the IsAddressTaken set.
@@ -1095,23 +1085,6 @@ void WasmObjectWriter::writeObject(MCAss
}
}
- // In the special .stack_pointer section, we've encoded the stack pointer
- // index.
- MCSectionWasm *StackPtr =
- Ctx.getWasmSection(".stack_pointer", SectionKind::getMetadata());
- if (!StackPtr->getFragmentList().empty()) {
- if (StackPtr->getFragmentList().size() != 1)
- report_fatal_error("only one .stack_pointer fragment supported");
- const MCFragment &Frag = *StackPtr->begin();
- if (Frag.hasInstructions() || Frag.getKind() != MCFragment::FT_Data)
- report_fatal_error("only data supported in .stack_pointer");
- const auto &DataFrag = cast<MCDataFragment>(Frag);
- if (!DataFrag.getFixups().empty())
- report_fatal_error("fixups not supported in .stack_pointer");
- const SmallVectorImpl<char> &Contents = DataFrag.getContents();
- StackPointerGlobalName = StringRef(Contents.data(), Contents.size());
- }
-
// Populate FunctionTypeIndices and Imports.
for (const MCSymbol &S : Asm.symbols()) {
const auto &WS = static_cast<const MCSymbolWasm &>(S);
@@ -1144,11 +1117,8 @@ void WasmObjectWriter::writeObject(MCAss
// If this global is the stack pointer, make it mutable and remember it
// so that we can emit metadata for it.
- if (StackPointerGlobalName.hasValue() &&
- WS.getName() == StackPointerGlobalName.getValue()) {
+ if (WS.getName() == "__stack_pointer")
Import.IsMutable = true;
- StackPointerGlobal = NumGlobalImports;
- }
++NumGlobalImports;
}
@@ -1338,8 +1308,7 @@ void WasmObjectWriter::writeObject(MCAss
writeNameSection(Functions, Imports, NumFuncImports);
writeCodeRelocSection();
writeDataRelocSection();
- writeLinkingMetaDataSection(DataSegments, DataSize, SymbolFlags,
- StackPointerGlobal);
+ writeLinkingMetaDataSection(DataSegments, DataSize, SymbolFlags);
// TODO: Translate the .comment section to the output.
// TODO: Translate debug sections to the output.
Modified: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp?rev=319956&r1=319955&r2=319956&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp Wed Dec 6 12:56:40 2017
@@ -108,10 +108,6 @@ void WebAssemblyTargetAsmStreamer::emitG
}
}
-void WebAssemblyTargetAsmStreamer::emitStackPointer(MCSymbol *Symbol) {
- OS << "\t.stack_pointer\t" << Symbol->getName() << '\n';
-}
-
void WebAssemblyTargetAsmStreamer::emitEndFunc() { OS << "\t.endfunc\n"; }
void WebAssemblyTargetAsmStreamer::emitIndirectFunctionType(
@@ -157,11 +153,6 @@ void WebAssemblyTargetELFStreamer::emitG
llvm_unreachable(".globalvar encoding not yet implemented");
}
-void WebAssemblyTargetELFStreamer::emitStackPointer(
- MCSymbol *Symbol) {
- llvm_unreachable(".stack_pointer encoding not yet implemented");
-}
-
void WebAssemblyTargetELFStreamer::emitEndFunc() {
Streamer.EmitIntValue(WebAssembly::End, 1);
}
@@ -238,14 +229,6 @@ void WebAssemblyTargetWasmStreamer::emit
Streamer.PopSection();
}
-void WebAssemblyTargetWasmStreamer::emitStackPointer(MCSymbol *Symbol) {
- Streamer.PushSection();
- Streamer.SwitchSection(Streamer.getContext().getWasmSection(
- ".stack_pointer", SectionKind::getMetadata()));
- Streamer.EmitBytes(Symbol->getName());
- Streamer.PopSection();
-}
-
void WebAssemblyTargetWasmStreamer::emitEndFunc() {
llvm_unreachable(".end_func is not needed for direct wasm output");
}
Modified: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h?rev=319956&r1=319955&r2=319956&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h (original)
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h Wed Dec 6 12:56:40 2017
@@ -39,8 +39,6 @@ public:
virtual void emitLocal(ArrayRef<MVT> Types) = 0;
/// .globalvar
virtual void emitGlobal(ArrayRef<wasm::Global> Globals) = 0;
- /// .stack_pointer
- virtual void emitStackPointer(MCSymbol *Symbol) = 0;
/// .endfunc
virtual void emitEndFunc() = 0;
/// .functype
@@ -67,7 +65,6 @@ public:
void emitResult(MCSymbol *Symbol, ArrayRef<MVT> Types) override;
void emitLocal(ArrayRef<MVT> Types) override;
void emitGlobal(ArrayRef<wasm::Global> Globals) override;
- void emitStackPointer(MCSymbol *Symbol) override;
void emitEndFunc() override;
void emitIndirectFunctionType(MCSymbol *Symbol,
SmallVectorImpl<MVT> &Params,
@@ -85,7 +82,6 @@ public:
void emitResult(MCSymbol *Symbol, ArrayRef<MVT> Types) override;
void emitLocal(ArrayRef<MVT> Types) override;
void emitGlobal(ArrayRef<wasm::Global> Globals) override;
- void emitStackPointer(MCSymbol *Symbol) override;
void emitEndFunc() override;
void emitIndirectFunctionType(MCSymbol *Symbol,
SmallVectorImpl<MVT> &Params,
@@ -103,7 +99,6 @@ public:
void emitResult(MCSymbol *Symbol, ArrayRef<MVT> Types) override;
void emitLocal(ArrayRef<MVT> Types) override;
void emitGlobal(ArrayRef<wasm::Global> Globals) override;
- void emitStackPointer(MCSymbol *Symbol) override;
void emitEndFunc() override;
void emitIndirectFunctionType(MCSymbol *Symbol,
SmallVectorImpl<MVT> &Params,
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp?rev=319956&r1=319955&r2=319956&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp Wed Dec 6 12:56:40 2017
@@ -78,12 +78,6 @@ WebAssemblyTargetStreamer *WebAssemblyAs
//===----------------------------------------------------------------------===//
void WebAssemblyAsmPrinter::EmitEndOfAsmFile(Module &M) {
- // Declare the stack pointer.
- if (TM.getTargetTriple().isOSBinFormatWasm()) {
- getTargetStreamer()->emitStackPointer(
- GetExternalSymbolSymbol("__stack_pointer"));
- }
-
for (const auto &F : M) {
// Emit function type info for all undefined functions
if (F.isDeclarationForLinker() && !F.isIntrinsic()) {
Modified: llvm/trunk/test/CodeGen/WebAssembly/stack-alignment.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/stack-alignment.ll?rev=319956&r1=319955&r2=319956&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/stack-alignment.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/stack-alignment.ll Wed Dec 6 12:56:40 2017
@@ -147,5 +147,3 @@ entry:
call void @somefunc(i32* %static)
ret void
}
-
-; CHECK: .stack_pointer __stack_pointer
More information about the llvm-commits
mailing list