ThinLTOBitcodeWriter: Do not include module-level inline asm in the merged module.
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 6 Feb 2018 03:29:18 +0000 (03:29 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 6 Feb 2018 03:29:18 +0000 (03:29 +0000)
If the inline asm provides the definition of a symbol, this can result
in duplicate symbol errors.

Differential Revision: https://reviews.llvm.org/D42944

llvm-svn: 324313

llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
llvm/test/Transforms/ThinLTOBitcodeWriter/module-asm.ll [new file with mode: 0644]

index f5a3d44..d2ce97a 100644 (file)
@@ -298,6 +298,7 @@ void splitAndWriteThinLTOBitcode(
         return false;
       }));
   StripDebugInfo(*MergedM);
+  MergedM->setModuleInlineAsm("");
 
   for (Function &F : *MergedM)
     if (!F.isDeclaration()) {
diff --git a/llvm/test/Transforms/ThinLTOBitcodeWriter/module-asm.ll b/llvm/test/Transforms/ThinLTOBitcodeWriter/module-asm.ll
new file mode 100644 (file)
index 0000000..15e4778
--- /dev/null
@@ -0,0 +1,12 @@
+; RUN: opt -thinlto-bc -o %t %s
+; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=M0 %s
+; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=M1 %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+@g = constant i32 0, !type !0
+!0 = !{i32 0, !"typeid"}
+
+; M0: module asm "ret"
+; M1-NOT: module asm
+module asm "ret"