[llvm-bugs] [Bug 29085] New: -O2: __always_inline__ does not have effect with visibility attribute hidden.

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 21 19:47:03 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=29085

            Bug ID: 29085
           Summary: -O2: __always_inline__ does not have effect with
                    visibility attribute hidden.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bluechristlove at 163.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Consider the following test case:
[code]
class __attribute__ ((__visibility__("default"))) facet1
{
protected:
__attribute__ ((__visibility__("hidden"), __always_inline__))
explicit facet1(int __refs = 0){}

virtual ~facet1();
};

template <class _CharT >
class __attribute__ ((__visibility__("default"))) money_put
: public facet1
{
public:
__attribute__ ((__visibility__("hidden"), __always_inline__))
explicit money_put(int __refs = 0){}


protected:
__attribute__ ((__visibility__("hidden"), __always_inline__))
~money_put() {}

};

extern template class __attribute__ ((__visibility__("default")))
money_put<char>;

struct Mymon_ : public money_put<char> {
Mymon_(int refs)
: money_put<char>(refs) {}
};
struct Myimon_ : public money_put<char> {
Myimon_(int refs)
: money_put<char>(refs) {}
};
int main(int argc, char *argv[])
{
Mymon_ fac(1);
Myimon_ faci(1);
}
[/code]

when we use clang with O2, clang++ t.cpp -O2 -c

then we grep money_put destructor on the t.o

nm t.o | grep _ZN9money_putIcED2Ev

we will find it:
                 U _ZN9money_putIcED2Ev
However, because we have __always_inline__, it should be inlined.

If we compile it with O0, it will fine. And if we g++ with O0 / O2, it is fine
too.

One more thing, it we use Clang 3.6 with O2, everything is ok, but Clang 3.8 /
Clang 3.9 / Main trunk fails.

This case can be reproduces on Linux on Power / x86

-- 
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/20160822/b3e74f16/attachment.html>


More information about the llvm-bugs mailing list