Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1187,6 +1187,13 @@ else assert(Alias.hasLocalLinkage() && "Invalid alias linkage"); + // If the alias has a function type and the aliasee is not a function, + // explicitly switch the symbol type to function. + if (Alias.getType()->isPointerTy() && + Alias.getType()->getPointerElementType()->isFunctionTy() && + !isa(Alias.getAliasee())) + OutStreamer->EmitSymbolAttribute(Name, MCSA_ELF_TypeFunction); + EmitVisibility(Name, Alias.getVisibility()); // Emit the directives as assignments aka .set: Index: test/CodeGen/Generic/function-alias.ll =================================================================== --- /dev/null +++ test/CodeGen/Generic/function-alias.ll @@ -0,0 +1,12 @@ +; RUN: llc < %s | FileCheck +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; "data" constant +@0 = private constant <{ i8, i8 }> <{i8 15, i8 11}>, section ".text" + +; function-typed alias +@ud2 = alias void (), bitcast (<{ i8, i8 }>* @0 to void ()*) + +; Check that "ud2" is emitted as a function symbol. +; CHECK: .type{{.*}}ud2,@function