OSDN Git Service

[WebAssembly] MC: Add compile-twice test and fix corresponding bug
authorSam Clegg <sbc@chromium.org>
Wed, 30 May 2018 02:57:20 +0000 (02:57 +0000)
committerSam Clegg <sbc@chromium.org>
Wed, 30 May 2018 02:57:20 +0000 (02:57 +0000)
Differential Revision: https://reviews.llvm.org/D47398

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333494 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCContext.cpp
lib/MC/WasmObjectWriter.cpp
test/MC/WebAssembly/compile-twice.ll [new file with mode: 0644]

index da2f0d4..5c4d67b 100644 (file)
@@ -105,6 +105,7 @@ void MCContext::reset() {
   MachOUniquingMap.clear();
   ELFUniquingMap.clear();
   COFFUniquingMap.clear();
+  WasmUniquingMap.clear();
 
   NextID.clear();
   AllowTemporaryLabels = true;
index a9ff7be..5a979d3 100644 (file)
@@ -270,9 +270,9 @@ private:
     Globals.clear();
     DataSegments.clear();
     SectionFunctions.clear();
-    MCObjectWriter::reset();
     NumFunctionImports = 0;
     NumGlobalImports = 0;
+    MCObjectWriter::reset();
   }
 
   void writeHeader(const MCAssembler &Asm);
diff --git a/test/MC/WebAssembly/compile-twice.ll b/test/MC/WebAssembly/compile-twice.ll
new file mode 100644 (file)
index 0000000..5fc3a04
--- /dev/null
@@ -0,0 +1,14 @@
+; Check that there is no persistent state in the WabAssembly emitter that cause
+; issues when reusing the pass manager.
+; RUN: llc -mtriple=wasm32-unknown-unknown -compile-twice -filetype=obj %s -o -
+
+; Force the creation of a DWARF section
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+@myglobal = global i32 0, align 4
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "LLVM", isOptimized: true, emissionKind: FullDebug)
+!1 = !DIFile(filename: "<stdin>", directory: "/")
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}