[PATCH] CodeGen: terminate compilation on failure in Inline ASM

Saleem Abdulrasool compnerd at compnerd.org
Sun Jan 4 17:42:24 PST 2015


In the case that we come across an error related to inline assembly, simply
terminate at that point.  There is no recovery path at this point.  In the best
case scenario, we will fail later on in assertions, and in the worst case, we
would lose the instruction in selection entirely.

Formulating a test for this is difficult as it relies on generating instructions
which may assert during lowering in SelDAG and other paths which don't which
seems rather fragile.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D6838

Files:
  lib/CodeGen/CodeGenAction.cpp

Index: lib/CodeGen/CodeGenAction.cpp
===================================================================
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -519,8 +519,15 @@
   // Get the diagnostic ID based.
   switch (DI.getKind()) {
   case llvm::DK_InlineAsm:
-    if (InlineAsmDiagHandler(cast<DiagnosticInfoInlineAsm>(DI)))
-      return;
+    if (InlineAsmDiagHandler(cast<DiagnosticInfoInlineAsm>(DI))) {
+      if (Severity != llvm::DS_Error)
+        return;
+      // If there was an error with inline asm, the BB may actually be
+      // incomplete and may fail later in the best scenario, or simply miss the
+      // entire block of inline assembly in the worst case.  Terminate the
+      // process at this point, we can no longer recover.
+      exit(1);
+    }
     ComputeDiagID(Severity, inline_asm, DiagID);
     break;
   case llvm::DK_StackSize:

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6838.17780.patch
Type: text/x-patch
Size: 890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150105/410f9027/attachment.bin>


More information about the cfe-commits mailing list