[PATCH] D138362: [AsmPrinter] .addrsig_sym: remove isTransitiveUsedByMetadataOnly
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 19 13:56:53 PST 2022
MaskRay created this revision.
MaskRay added reviewers: rnk, zequanwu.
Herald added subscribers: StephenFan, pengfei, hiraditya.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
With D135642 <https://reviews.llvm.org/D135642> ignoring unregistered symbols, isTransitiveUsedByMetadataOnly added
by D101512 <https://reviews.llvm.org/D101512> is no longer needed (the operation is potentially slow). There is a
`.addrsig_sym` directive for an only-used-by-metadata symbol but it does not
emit an entry.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138362
Files:
llvm/include/llvm/IR/Value.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/IR/Value.cpp
llvm/test/CodeGen/X86/addrsig.ll
Index: llvm/test/CodeGen/X86/addrsig.ll
===================================================================
--- llvm/test/CodeGen/X86/addrsig.ll
+++ llvm/test/CodeGen/X86/addrsig.ll
@@ -1,8 +1,18 @@
; RUN: llc < %s -mtriple=x86_64-unknown-linux | FileCheck --check-prefix=NO-ADDRSIG %s
; RUN: llc < %s -mtriple=x86_64-unknown-linux -addrsig | FileCheck %s
+; RUN: llc %s -filetype=obj -mtriple=x86_64-unknown-linux -addrsig -o %t
+; RUN: llvm-readobj --addrsig %t | FileCheck %s --check-prefix=SYM
; NO-ADDRSIG-NOT: .addrsig
+; SYM: Addrsig [
+; SYM-NEXT: Sym: f1
+; SYM-NEXT: Sym: metadata_f2
+; SYM-NEXT: Sym: g1
+; SYM-NEXT: Sym: a1
+; SYM-NEXT: Sym: i1
+; SYM-NEXT: ]
+
; CHECK: .addrsig
; CHECK: .addrsig_sym f1
@@ -27,7 +37,8 @@
declare void @f4(i8*) unnamed_addr
-; CHECK-NOT: .addrsig_sym metadata_f1
+;; f1 is unreferenced, so this directive does not emit an entry.
+; CHECK: .addrsig_sym metadata_f1
declare void @metadata_f1()
; CHECK: .addrsig_sym metadata_f2
Index: llvm/lib/IR/Value.cpp
===================================================================
--- llvm/lib/IR/Value.cpp
+++ llvm/lib/IR/Value.cpp
@@ -1022,22 +1022,6 @@
return Alloca->isSwiftError();
}
-bool Value::isTransitiveUsedByMetadataOnly() const {
- SmallVector<const User *, 32> WorkList(user_begin(), user_end());
- SmallPtrSet<const User *, 32> Visited(user_begin(), user_end());
- while (!WorkList.empty()) {
- const User *U = WorkList.pop_back_val();
- // If it is transitively used by a global value or a non-constant value,
- // it's obviously not only used by metadata.
- if (!isa<Constant>(U) || isa<GlobalValue>(U))
- return false;
- for (const User *UU : U->users())
- if (Visited.insert(UU).second)
- WorkList.push_back(UU);
- }
- return true;
-}
-
//===----------------------------------------------------------------------===//
// ValueHandleBase Class
//===----------------------------------------------------------------------===//
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2261,9 +2261,9 @@
// Emit address-significance attributes for all globals.
OutStreamer->emitAddrsig();
for (const GlobalValue &GV : M.global_values()) {
- if (!GV.use_empty() && !GV.isTransitiveUsedByMetadataOnly() &&
- !GV.isThreadLocal() && !GV.hasDLLImportStorageClass() &&
- !GV.getName().startswith("llvm.") && !GV.hasAtLeastLocalUnnamedAddr())
+ if (!GV.use_empty() && !GV.isThreadLocal() &&
+ !GV.hasDLLImportStorageClass() && !GV.getName().startswith("llvm.") &&
+ !GV.hasAtLeastLocalUnnamedAddr())
OutStreamer->emitAddrsigSym(getSymbol(&GV));
}
}
Index: llvm/include/llvm/IR/Value.h
===================================================================
--- llvm/include/llvm/IR/Value.h
+++ llvm/include/llvm/IR/Value.h
@@ -556,9 +556,6 @@
/// Return true if there is metadata referencing this value.
bool isUsedByMetadata() const { return IsUsedByMD; }
- // Return true if this value is only transitively referenced by metadata.
- bool isTransitiveUsedByMetadataOnly() const;
-
protected:
/// Get the current metadata attachments for the given kind, if any.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138362.476702.patch
Type: text/x-patch
Size: 3420 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221119/407027dc/attachment-0001.bin>
More information about the llvm-commits
mailing list