[PATCH] D75135: Revert "[WebAssembly] MC: Mark more function aliases as functions"

Michael Liao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 25 12:49:42 PST 2020


hliao created this revision.
hliao added reviewers: sbc100, dschuff, kripken.
Herald added subscribers: llvm-commits, sunfish, aheejin, hiraditya, jgravelle-google.
Herald added a project: LLVM.

This reverts commit 313f9f54f5a85790ae09cc48c1df54a4c635a3e3.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75135

Files:
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/test/MC/WebAssembly/function-alias.ll


Index: llvm/test/MC/WebAssembly/function-alias.ll
===================================================================
--- llvm/test/MC/WebAssembly/function-alias.ll
+++ /dev/null
@@ -1,44 +0,0 @@
-; RUN: llc -filetype=obj %s -o - | llvm-readobj --symbols | FileCheck %s
-
-target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
-target triple = "wasm32-unknown-unknown-wasm"
-
- at foo = alias i8, bitcast (i8* ()* @func to i8*)
- at bar = alias i8* (), i8* ()* @func
- at bar2 = alias i8* (), i8* ()* @bar
-
-define i8* @func() {
-  call i8* @bar2();
-  ret i8* @foo;
-}
-
-; CHECK:      Symbols [
-; CHECK-NEXT:   Symbol {
-; CHECK-NEXT:     Name: func
-; CHECK-NEXT:     Type: FUNCTION (0x0)
-; CHECK-NEXT:     Flags [ (0x0)
-; CHECK-NEXT:     ]
-; CHECK-NEXT:     ElementIndex: 0x0
-; CHECK-NEXT:   }
-; CHECK-NEXT:   Symbol {
-; CHECK-NEXT:     Name: bar2
-; CHECK-NEXT:     Type: FUNCTION (0x0)
-; CHECK-NEXT:     Flags [ (0x0)
-; CHECK-NEXT:     ]
-; CHECK-NEXT:     ElementIndex: 0x0
-; CHECK-NEXT:   }
-; CHECK-NEXT:   Symbol {
-; CHECK-NEXT:     Name: foo
-; CHECK-NEXT:     Type: FUNCTION (0x0)
-; CHECK-NEXT:     Flags [ (0x0)
-; CHECK-NEXT:     ]
-; CHECK-NEXT:     ElementIndex: 0x0
-; CHECK-NEXT:   }
-; CHECK-NEXT:   Symbol {
-; CHECK-NEXT:     Name: bar
-; CHECK-NEXT:     Type: FUNCTION (0x0)
-; CHECK-NEXT:     Flags [ (0x0)
-; CHECK-NEXT:     ]
-; CHECK-NEXT:     ElementIndex: 0x0
-; CHECK-NEXT:   }
-; CHECK-NEXT: ]
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1357,19 +1357,9 @@
   else
     assert(GIS.hasLocalLinkage() && "Invalid alias or ifunc linkage");
 
-  bool IsFunction = GIS.getValueType()->isFunctionTy();
-
-  // Treat bitcasts of functions as functions also. This is important at least
-  // on WebAssembly where object and function addresses can't alias each other.
-  if (!IsFunction)
-    if (auto *CE = dyn_cast<ConstantExpr>(GIS.getIndirectSymbol()))
-      if (CE->getOpcode() == Instruction::BitCast)
-        IsFunction =
-          CE->getOperand(0)->getType()->getPointerElementType()->isFunctionTy();
-
   // Set the symbol type to function if the alias has a function type.
   // This affects codegen when the aliasee is not a function.
-  if (IsFunction)
+  if (GIS.getType()->getPointerElementType()->isFunctionTy())
     OutStreamer->emitSymbolAttribute(Name, isa<GlobalIFunc>(GIS)
                                                ? MCSA_ELF_TypeIndFunction
                                                : MCSA_ELF_TypeFunction);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75135.246545.patch
Type: text/x-patch
Size: 2645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200225/626caf0f/attachment.bin>


More information about the llvm-commits mailing list