From: Sam Clegg Date: Wed, 30 May 2018 02:57:20 +0000 (+0000) Subject: [WebAssembly] MC: Add compile-twice test and fix corresponding bug X-Git-Tag: android-x86-7.1-r4~485 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1838ee9182958461fb02820d68a345ffe31232b6;p=android-x86%2Fexternal-llvm.git [WebAssembly] MC: Add compile-twice test and fix corresponding bug Differential Revision: https://reviews.llvm.org/D47398 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333494 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index da2f0d4e60b..5c4d67b10dd 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -105,6 +105,7 @@ void MCContext::reset() { MachOUniquingMap.clear(); ELFUniquingMap.clear(); COFFUniquingMap.clear(); + WasmUniquingMap.clear(); NextID.clear(); AllowTemporaryLabels = true; diff --git a/lib/MC/WasmObjectWriter.cpp b/lib/MC/WasmObjectWriter.cpp index a9ff7be2bab..5a979d36e81 100644 --- a/lib/MC/WasmObjectWriter.cpp +++ b/lib/MC/WasmObjectWriter.cpp @@ -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 index 00000000000..5fc3a04eacc --- /dev/null +++ b/test/MC/WebAssembly/compile-twice.ll @@ -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: "", directory: "/") +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3}