[llvm-bugs] [Bug 41343] New: __attribute__((optnone)) not respected for included lambda

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 2 02:36:42 PDT 2019


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

            Bug ID: 41343
           Summary: __attribute__((optnone)) not respected for included
                    lambda
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: christian.weber at nokia.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Test program test.cpp:

template <typename T>
class Test
{
    public:
    Test(){init();}

    template <typename U> 
    int doThis(){return 10;};

    template <typename U> 
    int doThat(){return 10;};

    private:
    void init() __attribute__((optnone));
};

template <typename T>
void Test<T>::init()
{
   [&](){this->template doThis<int>();}();
   this->template doThat<int>();
};


int main()
{
Test<bool> test;
}

clang -O3 test.cpp -c -o test.o
nm -C test.o
0000000000000000 T main
0000000000000000 W Test<bool>::init()
0000000000000000 W int Test<bool>::doThat<int>()
0000000000000000 W Test<bool>::init()::{lambda()#1}::operator()() const

I expect to see int Test<bool>::doThis<int>() in object file also.

Note: g++ 6.3.1a is not optimizing away the lambda function if
__attribute__((optnone))__ is replaced by __attribute__((optimize(0))) :

g++ -O3 test.cpp -c -o test_g++.o
nm -C test_g++.o
0000000000000000 T main
0000000000000000 W Test<bool>::init()
0000000000000000 t int Test<bool>::doThat<int>() [clone .isra.1]
0000000000000000 t int Test<bool>::doThis<int>() [clone .isra.0]
0000000000000000 W Test<bool>::init()::{lambda()#1}::operator()() const

-- 
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/20190402/a1742a6d/attachment-0001.html>


More information about the llvm-bugs mailing list