[llvm-bugs] [Bug 39413] New: GlobalMerge optimization drops visibility attributes
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 23 13:18:43 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39413
Bug ID: 39413
Summary: GlobalMerge optimization drops visibility attributes
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: rprichard at google.com
CC: llvm-bugs at lists.llvm.org
The GlobalMerge optimization enabled with -Oz or -O3 appears to discard
visibility attributes from variables. The merged variables have default
visibility when they were declared as hidden or protected.
int somevar1 __attribute__((visibility("hidden"))) = 1;
int somevar2 __attribute__((visibility("hidden"))) = 2;
int somevar3 __attribute__((visibility("protected"))) = 1;
int somevar4 __attribute__((visibility("protected"))) = 2;
int get12() {
return somevar1 + somevar2;
}
int get34() {
return somevar3 + somevar4;
}
$ clang -target arm -Oz test.c -c && readelf -s test.o | grep somevar
11: 00000000 4 OBJECT GLOBAL DEFAULT 6 somevar1
12: 00000004 4 OBJECT GLOBAL DEFAULT 6 somevar2
13: 00000008 4 OBJECT GLOBAL DEFAULT 6 somevar3
14: 0000000c 4 OBJECT GLOBAL DEFAULT 6 somevar4
$ clang -target arm -Oz test.c -c -mno-global-merge && readelf -s test.o | grep
somevar
9: 00000000 4 OBJECT GLOBAL HIDDEN 6 somevar1
10: 00000004 4 OBJECT GLOBAL HIDDEN 6 somevar2
11: 00000008 4 OBJECT GLOBAL PROTECTED 6 somevar3
12: 0000000c 4 OBJECT GLOBAL PROTECTED 6 somevar4
This was originally reported against the Android NDK
(https://github.com/android-ndk/ndk/issues/829).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181023/c4f5daae/attachment-0001.html>
More information about the llvm-bugs
mailing list