[llvm-bugs] [Bug 40722] New: callbr is not inlined

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 13 11:31:00 PST 2019


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

            Bug ID: 40722
           Summary: callbr is not inlined
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: ndesaulniers at google.com
                CC: llvm-bugs at lists.llvm.org
        Depends on: 9295
            Blocks: 4068

Created attachment 21475
  --> https://bugs.llvm.org/attachment.cgi?id=21475&action=edit
test.c

The recently added callbr IR instruction for supporting asm goto currently is
not inlined.  The x86 Linux kernel currently makes use of code that requires
asm goto to be inline-able to be semantically valid.

Attached is a simple test case.  To observe the inlining occuring when
compiling with GCC and not with Clang:

$ clang -O2 -no-integrated-as test.c
$ gdb -batch -ex 'file a.out' -ex 'disassemble t32' -ex 'disassemble main'
$ gcc -O2 test.c
$ gdb -batch -ex 'file a.out' -ex 'disassemble t32' -ex 'disassemble main'

Will show that GCC is able in inline this construct.

Instrumenting
llvm/lib/Transforms/Utils/InlineFunction.cpp#llvm::InlineFunction() it seems
that the functions I expect to be evaluated for inlining are not even
considered.  It seems that checks for basic blocks having their address taken
are preventing code in llvm/lib/Analysis/InlineCost.cpp
(CallAnalyzer::analyzeCall() and llvm::isInlineViable()) from considering these
functions for inlining.

Simply removing these "early bailouts" allows my simple attached test case to
be inlined, compilation of my kernel translation units to proceed, but
eventually we crash in a later translation unit while performing loop rotation
(not sure if that's an unrelated bug, or my "patch" is not conservative
enough).  This crash is also observed when running the llvm-lit test
llvm/test/Transforms/Inline/blockaddress.ll.  Attached is my basic "early
bailouts" patch.


Referenced Bugs:

https://bugs.llvm.org/show_bug.cgi?id=4068
[Bug 4068] [Meta] Compiling the Linux kernel with clang
https://bugs.llvm.org/show_bug.cgi?id=9295
[Bug 9295] Support for "asm goto"
-- 
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/20190213/2ee3b428/attachment-0001.html>


More information about the llvm-bugs mailing list