Hi all,
the attached patch makes builtins that have been explicitly declared
with an assembler label honour it. The most basic example is longjmp on
NetBSD:

typedef long jmp_buf[14];
void longjmp(jmp_buf, int) __asm("__longjmp14");

void test(void)
{
        longjmp((void *)0, 0);
}

While longjmp matches the LIBBUILTIN, the output should be using
__longjmp14, not longjmp itself.

Also attached is a small diagnostic improvement for dumpXML().

Note that validation of non-confliction assembler labels is still
missing in clang.

Joerg
Index: CodeGenModule.cpp
===================================================================
--- CodeGenModule.cpp	(revision 130694)
+++ CodeGenModule.cpp	(working copy)
@@ -1561,10 +1561,15 @@
          "isn't a lib fn");
 
   // Get the name, skip over the __builtin_ prefix (if necessary).
-  const char *Name = Context.BuiltinInfo.GetName(BuiltinID);
-  if (Context.BuiltinInfo.isLibFunction(BuiltinID))
-    Name += 10;
+  llvm::StringRef Name;
 
+  if (const AsmLabelAttr *ALA = FD->getAttr<AsmLabelAttr>())
+    Name = ALA->getLabel();
+  else if (Context.BuiltinInfo.isLibFunction(BuiltinID))
+    Name = Context.BuiltinInfo.GetName(BuiltinID) + 10;
+  else
+    Name = Context.BuiltinInfo.GetName(BuiltinID);
+
   const llvm::FunctionType *Ty =
     cast<llvm::FunctionType>(getTypes().ConvertType(FD->getType()));
 
Index: DumpXML.cpp
===================================================================
--- DumpXML.cpp	(revision 130694)
+++ DumpXML.cpp	(working copy)
@@ -487,6 +487,8 @@
       set("storage",
           VarDecl::getStorageClassSpecifierString(D->getStorageClass()));
     setFlag("inline", D->isInlineSpecified());
+    if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>())
+      set("asmlabel", ALA->getLabel());
     // TODO: instantiation, etc.
   }
   void visitFunctionDeclChildren(FunctionDecl *D) {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to