[llvm] r255043 - Add Available Externally linkage type to isWeakForLinker()
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 8 11:01:30 PST 2015
Author: mehdi_amini
Date: Tue Dec 8 13:01:29 2015
New Revision: 255043
URL: http://llvm.org/viewvc/llvm-project?rev=255043&view=rev
Log:
Add Available Externally linkage type to isWeakForLinker()
Per LangRef: "Globals with available_externally linkage are
allowed to be discarded at will, and are otherwise the same
as linkonce_odr", since linkonce_odr is in this list it makes
sense to have available_externally there as well.
Reviewers: rafael
Differential Revision: http://reviews.llvm.org/D15323
From: Mehdi Amini <mehdi.amini at apple.com>
Added:
llvm/trunk/test/Transforms/GlobalOpt/available_externally_global_ctors.ll
Modified:
llvm/trunk/include/llvm/IR/GlobalValue.h
Modified: llvm/trunk/include/llvm/IR/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalValue.h?rev=255043&r1=255042&r2=255043&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/IR/GlobalValue.h Tue Dec 8 13:01:29 2015
@@ -256,7 +256,8 @@ public:
static bool isWeakForLinker(LinkageTypes Linkage) {
return Linkage == WeakAnyLinkage || Linkage == WeakODRLinkage ||
Linkage == LinkOnceAnyLinkage || Linkage == LinkOnceODRLinkage ||
- Linkage == CommonLinkage || Linkage == ExternalWeakLinkage;
+ Linkage == CommonLinkage || Linkage == ExternalWeakLinkage ||
+ Linkage == AvailableExternallyLinkage;
}
bool hasExternalLinkage() const { return isExternalLinkage(Linkage); }
Added: llvm/trunk/test/Transforms/GlobalOpt/available_externally_global_ctors.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/available_externally_global_ctors.ll?rev=255043&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/GlobalOpt/available_externally_global_ctors.ll (added)
+++ llvm/trunk/test/Transforms/GlobalOpt/available_externally_global_ctors.ll Tue Dec 8 13:01:29 2015
@@ -0,0 +1,22 @@
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.11.0"
+
+; RUN: opt -S -globalopt < %s | FileCheck %s
+
+; Verify that the initialization of the available_externally global is not eliminated
+; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo_static_init, i8* null }]
+
+ at llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo_static_init, i8* null }]
+ at foo_external = available_externally global void ()* null, align 8
+
+define internal void @foo_static_init() {
+entry:
+ store void ()* @foo_impl, void ()** @foo_external, align 8
+ ret void
+}
+
+define internal void @foo_impl() {
+entry:
+ ret void
+}
+
More information about the llvm-commits
mailing list