From 7695f70bbd3e4d42adaa1ef2ff5e1b9ab3d9c345 Mon Sep 17 00:00:00 2001 From: Lauro Ramos Venancio Date: Tue, 26 Feb 2008 19:19:58 +0000 Subject: [PATCH] Fix a bug in ConvertAsmString function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47618 91177308-0d34-0410-b5e6-96231b3b80d8 --- CodeGen/CGStmt.cpp | 4 ++-- test/CodeGen/2008-02-26-inline-asm-bug.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 test/CodeGen/2008-02-26-inline-asm-bug.c diff --git a/CodeGen/CGStmt.cpp b/CodeGen/CGStmt.cpp index 0da91dabe6..5fdc61b46f 100644 --- a/CodeGen/CGStmt.cpp +++ b/CodeGen/CGStmt.cpp @@ -569,7 +569,7 @@ static inline std::string ConvertAsmString(const char *Start, } Result += '$' + llvm::utostr(n); - Start = End; + Start = End - 1; } else if (isalpha(EscapedChar)) { char *End; @@ -583,7 +583,7 @@ static inline std::string ConvertAsmString(const char *Start, } Result += "${" + llvm::utostr(n) + ':' + EscapedChar + '}'; - Start = End; + Start = End - 1; } else { assert(0 && "Unhandled asm escaped character!"); } diff --git a/test/CodeGen/2008-02-26-inline-asm-bug.c b/test/CodeGen/2008-02-26-inline-asm-bug.c new file mode 100644 index 0000000000..668b06c0d1 --- /dev/null +++ b/test/CodeGen/2008-02-26-inline-asm-bug.c @@ -0,0 +1,6 @@ +// RUN: clang -emit-llvm < %s | grep "\$0,\$1" + +void f() { + int d1, d2; + asm("%0,%1": "=r" (d1) : "r" (d2)); +} -- 2.50.1