[llvm] r319796 - [WebAssembly] Don't emit .import_global for the wasm target.
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 5 09:21:57 PST 2017
Author: djg
Date: Tue Dec 5 09:21:57 2017
New Revision: 319796
URL: http://llvm.org/viewvc/llvm-project?rev=319796&view=rev
Log:
[WebAssembly] Don't emit .import_global for the wasm target.
.import_global is used by the ELF-based target and not needed by the wasm
target.
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
llvm/trunk/test/CodeGen/WebAssembly/globl.ll
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp?rev=319796&r1=319795&r2=319796&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp Tue Dec 5 09:21:57 2017
@@ -91,7 +91,8 @@ void WebAssemblyAsmPrinter::EmitEndOfAsm
for (const auto &G : M.globals()) {
if (!G.hasInitializer() && G.hasExternalLinkage()) {
uint16_t Size = M.getDataLayout().getTypeAllocSize(G.getValueType());
- getTargetStreamer()->emitGlobalImport(G.getGlobalIdentifier());
+ if (TM.getTargetTriple().isOSBinFormatELF())
+ getTargetStreamer()->emitGlobalImport(G.getGlobalIdentifier());
OutStreamer->emitELFSize(getSymbol(&G),
MCConstantExpr::create(Size, OutContext));
}
Modified: llvm/trunk/test/CodeGen/WebAssembly/globl.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/globl.ll?rev=319796&r1=319795&r2=319796&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/globl.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/globl.ll Tue Dec 5 09:21:57 2017
@@ -4,11 +4,14 @@ target datalayout = "e-m:e-p:32:32-i64:6
target triple = "wasm32-unknown-unknown-wasm"
; CHECK: .globl foo
+; CHECK: .type foo, at function
; CHECK-LABEL: foo:
-define void @foo() {
- ret void
+; CHECK: .size foo,
+define i32* @foo() {
+ ret i32* @bar
}
-; Check import directives - must be at the end of the file
-; CHECK: .import_global bar{{$}}
- at bar = external global i32
+; CHECK: .type bar, at object
+; CHECK: .globl bar
+; CHECK: .size bar, 4
+ at bar = global i32 2
More information about the llvm-commits
mailing list