[PATCH] D17496: [ms-inline-asm] Fix bug in single asm statement support
Marina Yatsina via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 22 00:22:42 PST 2016
myatsina created this revision.
myatsina added reviewers: rnk, ehsan.
myatsina added a subscriber: llvm-commits.
myatsina set the repository for this revision to rL LLVM.
Fixing a crash caused by trying to merge a single-line asm statement with an asm block that follows it, e.g:
asm int 4
asm {
int 5
}
Now, only adjacent single-line asm statements that are not surrounded by braces will be merged into one asm call.
Repository:
rL LLVM
http://reviews.llvm.org/D17496
Files:
lib/Parse/ParseStmtAsm.cpp
test/CodeGen/ms-inline-asm.c
test/Parser/ms-inline-asm.c
Index: lib/Parse/ParseStmtAsm.cpp
===================================================================
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -423,6 +423,10 @@
// We're no longer in a comment.
InAsmComment = false;
if (isAsm) {
+ // If this is a new __asm {} block we want to process it seperately
+ // from the single-line __asm statements
+ if (PP.LookAhead(0).is(tok::l_brace))
+ break;
LineNo = SrcMgr.getLineNumber(ExpLoc.first, ExpLoc.second);
SkippedStartOfLine = Tok.isAtStartOfLine();
}
Index: test/CodeGen/ms-inline-asm.c
===================================================================
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -63,10 +63,19 @@
int t8() {
__asm int 4 ; } comments for single-line asm
__asm {}
- __asm int 4
+ __asm { int 5}
+ __asm int 6
+ __asm int 7
+ __asm {
+ int 8
+ }
return 10;
// CHECK: t8
-// CHECK: call i32 asm sideeffect inteldialect "int $$4\0A\09int $$4", "={eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call i32 asm sideeffect inteldialect "int $$4", "={eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call i32 asm sideeffect inteldialect "", "={eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call i32 asm sideeffect inteldialect "int $$5", "={eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call i32 asm sideeffect inteldialect "int $$6\0A\09int $$7", "={eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call i32 asm sideeffect inteldialect "int $$8", "={eax},~{dirflag},~{fpsr},~{flags}"()
// CHECK: ret i32 10
}
Index: test/Parser/ms-inline-asm.c
===================================================================
--- test/Parser/ms-inline-asm.c
+++ test/Parser/ms-inline-asm.c
@@ -55,4 +55,4 @@
}
int t_fail() { // expected-note {{to match this}}
__asm
- __asm { // expected-error 2 {{expected}} expected-note {{to match this}}
+ __asm { // expected-error 3 {{expected}} expected-note {{to match this}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17496.48651.patch
Type: text/x-patch
Size: 2033 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160222/f5697f0b/attachment.bin>
More information about the llvm-commits
mailing list