Skip to content

Commit

Permalink
fix PR10415, tidying up IR representation of module level inline asm
Browse files Browse the repository at this point in the history
to avoid extraneous \n's.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135862 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Jul 23, 2011
1 parent ab4e83b commit 9f5bff0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions test/CodeGen/asm.c
Original file line number Diff line number Diff line change
@@ -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));
}
Expand Down

0 comments on commit 9f5bff0

Please sign in to comment.