[llvm] r254674 - Emit function alias to data as a function symbol.
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 3 16:45:44 PST 2015
Author: eugenis
Date: Thu Dec 3 18:45:43 2015
New Revision: 254674
URL: http://llvm.org/viewvc/llvm-project?rev=254674&view=rev
Log:
Emit function alias to data as a function symbol.
CFI emits jump slots for indirect functions as a byte array
constant, and declares function-typed aliases to these constants.
This change fixes AsmPrinter to emit these aliases as function
symbols and not data symbols.
Added:
llvm/trunk/test/CodeGen/Generic/function-alias.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=254674&r1=254673&r2=254674&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Dec 3 18:45:43 2015
@@ -1187,6 +1187,11 @@ bool AsmPrinter::doFinalization(Module &
else
assert(Alias.hasLocalLinkage() && "Invalid alias linkage");
+ // Set the symbol type to function if the alias has a function type.
+ // This affects codegen when the aliasee is not a function.
+ if (Alias.getType()->getPointerElementType()->isFunctionTy())
+ OutStreamer->EmitSymbolAttribute(Name, MCSA_ELF_TypeFunction);
+
EmitVisibility(Name, Alias.getVisibility());
// Emit the directives as assignments aka .set:
Added: llvm/trunk/test/CodeGen/Generic/function-alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/function-alias.ll?rev=254674&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Generic/function-alias.ll (added)
+++ llvm/trunk/test/CodeGen/Generic/function-alias.ll Thu Dec 3 18:45:43 2015
@@ -0,0 +1,12 @@
+; RUN: llc < %s | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; "data" constant
+ at 0 = private constant <{ i8, i8 }> <{i8 15, i8 11}>, section ".text"
+
+; function-typed alias
+ at ud2 = alias void (), bitcast (<{ i8, i8 }>* @0 to void ()*)
+
+; Check that "ud2" is emitted as a function symbol.
+; CHECK: .type{{.*}}ud2, at function
More information about the llvm-commits
mailing list