[PATCH] D15215: Emit function alias to data as a function symbol

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 3 16:41:14 PST 2015


eugenis updated this revision to Diff 41830.

Repository:
  rL LLVM

http://reviews.llvm.org/D15215

Files:
  lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  test/CodeGen/Generic/function-alias.ll

Index: test/CodeGen/Generic/function-alias.ll
===================================================================
--- /dev/null
+++ test/CodeGen/Generic/function-alias.ll
@@ -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
Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1187,6 +1187,11 @@
     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:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15215.41830.patch
Type: text/x-patch
Size: 1276 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151204/9c71613c/attachment.bin>


More information about the llvm-commits mailing list