[llvm] r314783 - [WebAssembly] MC: Support for init_array and fini_array
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 3 04:20:28 PDT 2017
Author: sbc
Date: Tue Oct 3 04:20:28 2017
New Revision: 314783
URL: http://llvm.org/viewvc/llvm-project?rev=314783&view=rev
Log:
[WebAssembly] MC: Support for init_array and fini_array
Differential Revision: https://reviews.llvm.org/D37757
Added:
llvm/trunk/test/MC/WebAssembly/init-fini-array.ll
Modified:
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=314783&r1=314782&r2=314783&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Tue Oct 3 04:20:28 2017
@@ -1328,7 +1328,9 @@ const MCExpr *TargetLoweringObjectFileWa
MCSymbolRefExpr::create(TM.getSymbol(RHS), getContext()), getContext());
}
-void
-TargetLoweringObjectFileWasm::InitializeWasm() {
- // TODO: Initialize StaticCtorSection and StaticDtorSection.
+void TargetLoweringObjectFileWasm::InitializeWasm() {
+ StaticCtorSection =
+ getContext().getWasmSection(".init_array", wasm::WASM_SEC_DATA);
+ StaticDtorSection =
+ getContext().getWasmSection(".fini_array", wasm::WASM_SEC_DATA);
}
Added: llvm/trunk/test/MC/WebAssembly/init-fini-array.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/init-fini-array.ll?rev=314783&view=auto
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/init-fini-array.ll (added)
+++ llvm/trunk/test/MC/WebAssembly/init-fini-array.ll Tue Oct 3 04:20:28 2017
@@ -0,0 +1,96 @@
+; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o - | obj2yaml | FileCheck %s
+
+ at global1 = global i32 1025, align 8
+
+declare void @func1()
+
+declare void @func2()
+
+ at llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @func1, i8* null }]
+
+ at llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @func2, i8* null }]
+
+
+; CHECK: - Type: IMPORT
+; CHECK-NEXT: Imports:
+; CHECK-NEXT: - Module: env
+; CHECK-NEXT: Field: func1
+; CHECK-NEXT: Kind: FUNCTION
+; CHECK-NEXT: SigIndex: 0
+; CHECK-NEXT: - Module: env
+; CHECK-NEXT: Field: func2
+; CHECK-NEXT: Kind: FUNCTION
+; CHECK-NEXT: SigIndex: 0
+; CHECK-NEXT: - Type: TABLE
+; CHECK-NEXT: Tables:
+; CHECK-NEXT: - ElemType: ANYFUNC
+; CHECK-NEXT: Limits:
+; CHECK-NEXT: Initial: 0x00000002
+; CHECK-NEXT: - Type: MEMORY
+; CHECK-NEXT: Memories:
+; CHECK-NEXT: - Initial: 0x00000001
+; CHECK-NEXT: - Type: GLOBAL
+; CHECK-NEXT: Globals:
+; CHECK-NEXT: - Type: I32
+; CHECK-NEXT: Mutable: false
+; CHECK-NEXT: InitExpr:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 0
+; CHECK-NEXT: - Type: EXPORT
+; CHECK-NEXT: Exports:
+; CHECK-NEXT: - Name: global1
+; CHECK-NEXT: Kind: GLOBAL
+; CHECK-NEXT: Index: 0
+; CHECK-NEXT: - Type: ELEM
+; CHECK-NEXT: Segments:
+; CHECK-NEXT: - Offset:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 0
+; CHECK-NEXT: Functions: [ 0, 1 ]
+; CHECK-NEXT: - Type: DATA
+; CHECK-NEXT: Relocations:
+; CHECK-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_I32
+; CHECK-NEXT: Index: 0
+; CHECK-NEXT: Offset: 0x0000000F
+; CHECK-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_I32
+; CHECK-NEXT: Index: 1
+; CHECK-NEXT: Offset: 0x00000018
+; CHECK-NEXT: Segments:
+; CHECK-NEXT: - SectionOffset: 6
+; CHECK-NEXT: MemoryIndex: 0
+; CHECK-NEXT: Offset:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 0
+; CHECK-NEXT: Content: '01040000'
+; CHECK-NEXT: - SectionOffset: 15
+; CHECK-NEXT: MemoryIndex: 0
+; CHECK-NEXT: Offset:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 4
+; CHECK-NEXT: Content: '00000000'
+; CHECK-NEXT: - SectionOffset: 24
+; CHECK-NEXT: MemoryIndex: 0
+; CHECK-NEXT: Offset:
+; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 8
+; CHECK-NEXT: Content: '01000000'
+; CHECK-NEXT: - Type: CUSTOM
+; CHECK-NEXT: Name: name
+; CHECK-NEXT: FunctionNames:
+; CHECK-NEXT: - Index: 0
+; CHECK-NEXT: Name: func1
+; CHECK-NEXT: - Index: 1
+; CHECK-NEXT: Name: func2
+; CHECK-NEXT: - Type: CUSTOM
+; CHECK-NEXT: Name: linking
+; CHECK-NEXT: DataSize: 12
+; CHECK-NEXT: DataAlignment: 8
+; CHECK-NEXT: SegmentNames:
+; CHECK-NEXT: - Index: 0
+; CHECK-NEXT: Name: .data.global1
+; CHECK-NEXT: - Index: 1
+; CHECK-NEXT: Name: .init_array
+; CHECK-NEXT: - Index: 2
+; CHECK-NEXT: Name: .fini_array
+; CHECK-NEXT: ...
+
More information about the llvm-commits
mailing list