summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp3
-rw-r--r--llvm/test/CodeGen/WebAssembly/globl.ll13
2 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index ee60c8f3a7a..5f7f3d694cd 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -91,7 +91,8 @@ void WebAssemblyAsmPrinter::EmitEndOfAsmFile(Module &M) {
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));
}
diff --git a/llvm/test/CodeGen/WebAssembly/globl.ll b/llvm/test/CodeGen/WebAssembly/globl.ll
index ba9f6659d7d..c3126d55863 100644
--- a/llvm/test/CodeGen/WebAssembly/globl.ll
+++ b/llvm/test/CodeGen/WebAssembly/globl.ll
@@ -4,11 +4,14 @@ target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown-wasm"
; CHECK: .globl foo
+; CHECK: .type foo,@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{{$}}
-@bar = external global i32
+; CHECK: .type bar,@object
+; CHECK: .globl bar
+; CHECK: .size bar, 4
+@bar = global i32 2
OpenPOWER on IntegriCloud