[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:16:26 PST 2015


eugenis updated this revision to Diff 41825.

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,12 @@
     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()->getPointerElementType()->isFunctionTy() &&
+        !isa<Function>(Alias.getAliasee()))
+      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.41825.patch
Type: text/x-patch
Size: 1315 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151204/6dbd36c5/attachment-0001.bin>


More information about the llvm-commits mailing list