]> granicus.if.org Git - clang/commitdiff
fix PR10415, tidying up IR representation of module level inline asm
authorChris Lattner <sabre@nondot.org>
Sat, 23 Jul 2011 20:04:25 +0000 (20:04 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 23 Jul 2011 20:04:25 +0000 (20:04 +0000)
to avoid extraneous \n's.

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

lib/CodeGen/CodeGenModule.cpp
test/CodeGen/asm.c

index a4fce926ec259df7924194e0457746d55f16db7b..d7b6c7ec3df35e3000112e8fe7e5882542dd20ab 100644 (file)
@@ -2186,6 +2186,8 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
     const std::string &S = getModule().getModuleInlineAsm();
     if (S.empty())
       getModule().setModuleInlineAsm(AsmString);
+    else if (*--S.end() == '\n')
+      getModule().setModuleInlineAsm(S + AsmString.str());
     else
       getModule().setModuleInlineAsm(S + '\n' + AsmString.str());
     break;
index 7199f09e1a3cb3d7d6e79c39fc306e4f2a33ad78..a2d56c84f4648d2eac4cf27fba6671ea5bafe1c3 100644 (file)
@@ -1,4 +1,13 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+// PR10415
+__asm__ ("foo1");
+__asm__ ("foo2");
+__asm__ ("foo3");
+// CHECK: module asm "foo1"
+// CHECK-NEXT: module asm "foo2"
+// CHECK-NEXT: module asm "foo3"
+
 void t1(int len) {
   __asm__ volatile("" : "=&r"(len), "+&r"(len));
 }