[WebAssembly] Don't emit .import_global for the wasm target.
authorDan Gohman <dan433584@gmail.com>
Tue, 5 Dec 2017 17:21:57 +0000 (17:21 +0000)
committerDan Gohman <dan433584@gmail.com>
Tue, 5 Dec 2017 17:21:57 +0000 (17:21 +0000)
.import_global is used by the ELF-based target and not needed by the wasm
target.

llvm-svn: 319796

llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
llvm/test/CodeGen/WebAssembly/globl.ll

index ee60c8f..5f7f3d6 100644 (file)
@@ -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));
     }
index ba9f665..c3126d5 100644 (file)
@@ -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