[llvm-dev] Disabling inline compilation (Clang with VS2019)

Hans Wennborg via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 23 10:42:45 PDT 2021


On Thu, Sep 23, 2021 at 4:18 PM <paul.robinson at sony.com> wrote:
> On the other hand, the experience described upthread is that Clang's
> handling of /Ob0 still permits inlining.  The MSDN quote suggests that
> /Ob0 should suppress inlining, and that's not what people see.
> --paulr

I haven't been able to reproduce that though. When I try it,
clang-cl's /Ob0 correctly suppresses the inlining:

---
C:\src\tmp>type a.cc
#if defined (BUILDING_DLL)
   #define DLL_API __declspec(dllexport)
#else
   #define DLL_API __declspec(dllimport)
#endif

namespace Gtkmm2ext {

   class DLL_API Keyboard
   {
     public:
       Keyboard ();
       ~Keyboard ();

       static Keyboard& get_keyboard() { return *_the_keyboard; }

     protected:
       static Keyboard* _the_keyboard;
   };

} /* namespace */


void *f() {
    return (void*)&Gtkmm2ext::Keyboard::get_keyboard();
}

C:\src\tmp>\src\llvm.monorepo\build.release\bin\clang-cl -c a.cc /Ox
/Ob0 && dumpbin /nologo /disasm a.obj

Dump of file a.obj

File Type: COFF OBJECT

?f@@YAPEAXXZ (void * __cdecl f(void)):
  0000000000000000: 48 FF 25 00 00 00  jmp         qword ptr
[__imp_?get_keyboard at Keyboard@Gtkmm2ext@@SAAEAV12 at XZ]
                    00

  Summary

           0 .bss
           0 .data
          30 .drectve
           0 .llvm_addrsig
           7 .text
---

Perhaps what's happening is that the /Ob0 flag never makes it to
clang-cl in John's build, or maybe it gets passed before another
optimization flag which turns inlining back on again.


More information about the llvm-dev mailing list