[PATCH] Allow AsmLabel with -fno-gnu-inline-asm

Steven Wu stevenwu at apple.com
Mon May 11 13:54:45 PDT 2015


Hi rnk, bob.wilson,

AsmLabel is heavily used in system level and firmware to redirect
function and access platform specific labels. They are also extensively
used in system headers which makes this option unusable for many
users. Since AsmLabel doesn't introduce any assembly code into the
output binary, it shouldn't be considered as inline-asm.

http://reviews.llvm.org/D9679

Files:
  lib/Parse/Parser.cpp
  test/Parser/no-gnu-inline-asm.c

Index: lib/Parse/Parser.cpp
===================================================================
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -669,6 +669,11 @@
 
     SourceLocation StartLoc = Tok.getLocation();
     SourceLocation EndLoc;
+
+    // Check if GNU-style InlineAsm is disabled.
+    if (!getLangOpts().GNUAsm)
+      Diag(StartLoc, diag::err_gnu_inline_asm_disabled);
+
     ExprResult Result(ParseSimpleAsm(&EndLoc));
 
     ExpectAndConsume(tok::semi, diag::err_expected_after,
@@ -1253,10 +1258,6 @@
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
   SourceLocation Loc = ConsumeToken();
 
-  // Check if GNU-style InlineAsm is disabled.
-  if (!getLangOpts().GNUAsm)
-    Diag(Loc, diag::err_gnu_inline_asm_disabled);
-
   if (Tok.is(tok::kw_volatile)) {
     // Remove from the end of 'asm' to the end of 'volatile'.
     SourceRange RemovalRange(PP.getLocForEndOfToken(Loc),
Index: test/Parser/no-gnu-inline-asm.c
===================================================================
--- test/Parser/no-gnu-inline-asm.c
+++ test/Parser/no-gnu-inline-asm.c
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 %s -triple i686-apple-darwin -verify -fsyntax-only -fno-gnu-inline-asm
 
 asm ("INST r1, 0"); // expected-error {{GNU-style inline assembly is disabled}}
+
+void foo() __asm("__foo_func"); // AsmLabel is OK
+int foo1 asm("bar1") = 0; // OK
+
 void f (void) {
   long long foo = 0, bar;
   asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar)); // expected-error {{GNU-style inline assembly is disabled}}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9679.25506.patch
Type: text/x-patch
Size: 1520 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150511/7128d1d8/attachment.bin>


More information about the cfe-commits mailing list