[cfe-commits] r163345 - in /cfe/trunk: lib/Sema/SemaStmtAsm.cpp test/CodeGen/ms-inline-asm.c

Chad Rosier mcrosier at apple.com
Thu Sep 6 12:56:25 PDT 2012


Author: mcrosier
Date: Thu Sep  6 14:56:25 2012
New Revision: 163345

URL: http://llvm.org/viewvc/llvm-project?rev=163345&view=rev
Log:
[ms-inline asm] Output empty asm statements for the directives we don't
handle.  Otherwise, the AsmParser will explode if we try to generate an
object files.

Modified:
    cfe/trunk/lib/Sema/SemaStmtAsm.cpp
    cfe/trunk/test/CodeGen/ms-inline-asm.c

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=163345&r1=163344&r2=163345&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Thu Sep  6 14:56:25 2012
@@ -454,11 +454,11 @@
   return Res.str();
 }
 
-#define DEF_SIMPLE_MSASM                                                     \
+#define DEF_SIMPLE_MSASM(STR)                                                \
   MSAsmStmt *NS =                                                            \
     new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, /*IsSimple*/ true,   \
                             /*IsVolatile*/ true, AsmToks, Inputs, Outputs,   \
-                            InputExprs, OutputExprs, AsmString, Constraints, \
+                            InputExprs, OutputExprs, STR, Constraints,       \
                             Clobbers, EndLoc);
 
 StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc,
@@ -478,11 +478,8 @@
   SmallVector<std::string, 4> OutputExprNames;
 
   // Empty asm statements don't need to instantiate the AsmParser, etc.
-  if (AsmToks.empty()) {
-    StringRef AsmString;
-    DEF_SIMPLE_MSASM;
-    return Owned(NS);
-  }
+  StringRef EmptyAsmStr;
+  if (AsmToks.empty()) { DEF_SIMPLE_MSASM(EmptyAsmStr); return Owned(NS); }
 
   std::vector<std::string> AsmStrings;
   std::vector<std::pair<unsigned,unsigned> > AsmTokRanges;
@@ -495,7 +492,7 @@
   bool IsSimple = isSimpleMSAsm(Pieces, Context.getTargetInfo());
 
   // AsmParser doesn't fully support these asm statements.
-  if (bailOnMSAsm(Pieces)) { DEF_SIMPLE_MSASM; return Owned(NS); }
+  if (bailOnMSAsm(Pieces)) { DEF_SIMPLE_MSASM(EmptyAsmStr); return Owned(NS); }
 
   // Initialize targets and assembly printers/parsers.
   llvm::InitializeAllTargetInfos();
@@ -549,7 +546,7 @@
     bool HadError = TargetParser->ParseInstruction(OpcodeStr.str(), IDLoc,
                                                    Operands);
     // If we had an error parsing the operands, fail gracefully.
-    if (HadError) { DEF_SIMPLE_MSASM; return Owned(NS); }
+    if (HadError) { DEF_SIMPLE_MSASM(EmptyAsmStr); return Owned(NS); }
 
     // Match the MCInstr.
     unsigned Kind;
@@ -559,7 +556,7 @@
                                               ErrorInfo,
                                               /*matchingInlineAsm*/ true);
     // If we had an error parsing the operands, fail gracefully.
-    if (HadError) { DEF_SIMPLE_MSASM; return Owned(NS); }
+    if (HadError) { DEF_SIMPLE_MSASM(EmptyAsmStr); return Owned(NS); }
 
     // Get the instruction descriptor.
     llvm::MCInst Inst = Instrs[0];

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=163345&r1=163344&r2=163345&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Thu Sep  6 14:56:25 2012
@@ -96,6 +96,9 @@
 void t11(void) {
   __asm EVEN
   __asm ALIGN
+// CHECK: t11
+// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
+// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
 }
 
 void t12(void) {
@@ -104,6 +107,8 @@
     _emit 0x43
     _emit 0x4B
   }
+// CHECK: t12
+// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
 }
 
 void t13(void) {
@@ -111,4 +116,8 @@
   __asm LENGTH arr ; sizeof(arr)/sizeof(arr[0])
   __asm SIZE arr   ; sizeof(arr)
   __asm TYPE arr   ; sizeof(arr[0])
+// CHECK: t13
+// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
+// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
+// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
 }





More information about the cfe-commits mailing list