[PATCH] D30831: [ASTImporter] Import fix of GCCAsmStmts w/ missing symbolic operands

Zoltán Gera via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 10 08:24:46 PST 2017


gerazo created this revision.

Do not drop the import of the whole function just because an asm statement in it has some missing symbolic names.


https://reviews.llvm.org/D30831

Files:
  lib/AST/ASTImporter.cpp
  test/ASTMerge/asm/Inputs/asm-function.cpp
  test/ASTMerge/asm/test.cpp


Index: test/ASTMerge/asm/test.cpp
===================================================================
--- test/ASTMerge/asm/test.cpp
+++ test/ASTMerge/asm/test.cpp
@@ -4,4 +4,5 @@
 
 void testAsmImport() {
   asmFunc(12, 42);
+  asmFunc2(42);
 }
Index: test/ASTMerge/asm/Inputs/asm-function.cpp
===================================================================
--- test/ASTMerge/asm/Inputs/asm-function.cpp
+++ test/ASTMerge/asm/Inputs/asm-function.cpp
@@ -9,3 +9,13 @@
   res = bigres;
   return res;
 }
+
+int asmFunc2(int i) {
+  int res;
+  asm ("mov %1, %0 \t\n"
+       "inc %0 "
+      : "=r" (res)
+      : "r" (i)
+      : "cc");
+  return res;
+}
Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -5218,14 +5218,14 @@
   SmallVector<IdentifierInfo *, 4> Names;
   for (unsigned I = 0, E = S->getNumOutputs(); I != E; I++) {
     IdentifierInfo *ToII = Importer.Import(S->getOutputIdentifier(I));
-    if (!ToII)
-      return nullptr;
+    // ToII is nullptr when no symbolic name is given for output operand
+    // see ParseStmtAsm::ParseAsmOperandsOpt
     Names.push_back(ToII);
   }
   for (unsigned I = 0, E = S->getNumInputs(); I != E; I++) {
     IdentifierInfo *ToII = Importer.Import(S->getInputIdentifier(I));
-    if (!ToII)
-      return nullptr;
+    // ToII is nullptr when no symbolic name is given for input operand
+    // see ParseStmtAsm::ParseAsmOperandsOpt
     Names.push_back(ToII);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30831.91351.patch
Type: text/x-patch
Size: 1534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170310/504cb7eb/attachment.bin>


More information about the cfe-commits mailing list