[llvm] a2fb2c0 - [GlobalMerge] Preserve symbol visibility when merging globals

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 16:43:08 PST 2020


This was fixed in 6be9acd.  It looks like there’s something wrong with the bot’s configuration; it’s lagging over half a day behind master.

-Eli

From: Galina Kistanova <gkistanova at gmail.com>
Sent: Thursday, January 30, 2020 4:33 PM
To: Eli Friedman <efriedma at quicinc.com>; Eli Friedman <llvmlistbot at llvm.org>
Cc: llvm-commits <llvm-commits at lists.llvm.org>
Subject: [EXT] Re: [llvm] a2fb2c0 - [GlobalMerge] Preserve symbol visibility when merging globals

Hello Michael,

This  commit broke test for the builder:
http://lab.llvm.org:8011/builders/llvm-clang-win-x-aarch64/builds/3704
. . .
Failing Tests (1):
    LLVM :: CodeGen/AArch64/global-merge-hidden-minsize.ll

Please have a look ASAP?

Thanks

Galina


On Tue, Jan 28, 2020 at 1:26 PM Eli Friedman via llvm-commits <llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>> wrote:

Author: Michael Spang
Date: 2020-01-28T13:26:18-08:00
New Revision: a2fb2c0ddca14c133f24d08af4a78b6a3d612ec6

URL: https://github.com/llvm/llvm-project/commit/a2fb2c0ddca14c133f24d08af4a78b6a3d612ec6
DIFF: https://github.com/llvm/llvm-project/commit/a2fb2c0ddca14c133f24d08af4a78b6a3d612ec6.diff

LOG: [GlobalMerge] Preserve symbol visibility when merging globals

Symbols created for merged external global variables have default
visibility. This can break programs when compiling with -Oz
-fvisibility=hidden as symbols that should be hidden will be exported at
link time.

Differential Revision: https://reviews.llvm.org/D73235

Added:
    llvm/test/CodeGen/AArch64/global-merge-hidden-minsize.ll

Modified:
    llvm/lib/CodeGen/GlobalMerge.cpp

Removed:



################################################################################
diff  --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index 5870e20d4227..6e5593abb43e 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -524,6 +524,7 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
     for (ssize_t k = i, idx = 0; k != j; k = GlobalSet.find_next(k), ++idx) {
       GlobalValue::LinkageTypes Linkage = Globals[k]->getLinkage();
       std::string Name = Globals[k]->getName();
+      GlobalValue::VisibilityTypes Visibility = Globals[k]->getVisibility();
       GlobalValue::DLLStorageClassTypes DLLStorage =
           Globals[k]->getDLLStorageClass();

@@ -549,6 +550,7 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
       if (Linkage != GlobalValue::InternalLinkage || !IsMachO) {
         GlobalAlias *GA = GlobalAlias::create(Tys[StructIdxs[idx]], AddrSpace,
                                               Linkage, Name, GEP, &M);
+        GA->setVisibility(Visibility);
         GA->setDLLStorageClass(DLLStorage);
       }


diff  --git a/llvm/test/CodeGen/AArch64/global-merge-hidden-minsize.ll b/llvm/test/CodeGen/AArch64/global-merge-hidden-minsize.ll
new file mode 100644
index 000000000000..25241ad2af8a
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/global-merge-hidden-minsize.ll
@@ -0,0 +1,26 @@
+; RUN: llc %s -mtriple=arm-none-linux-gnu -o - | FileCheck %s
+; RUN: llc %s -mtriple=aarch64-none-linux-gnu -o - | FileCheck %s
+
+ at x = hidden global i32 0, align 4
+ at y = hidden global i32 0, align 4
+
+define hidden void @f() #0 {
+  store i32 0, i32* @x, align 4
+  store i32 0, i32* @y, align 4
+  ret void
+}
+
+attributes #0 = { minsize optsize }
+
+; CHECK: .local .L_MergedGlobals
+; CHECK: .comm .L_MergedGlobals,8,4
+
+; CHECK: .globl x
+; CHECK: .hidden x
+; CHECK: .set x, .L_MergedGlobals
+; CHECK: .size x, 4
+
+; CHECK: .globl y
+; CHECK: .hidden y
+; CHECK: .set y, .L_MergedGlobals+4
+; CHECK: .size y, 4



_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200131/88cb7675/attachment.html>


More information about the llvm-commits mailing list