https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78306

            Bug ID: 78306
           Summary: [CilkPlus] "inlining failed in call to always_inline
                    ‘memset’: function not inlinable" with -fcilkplus
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iblue at gmx dot net
  Target Milestone: ---

Created attachment 40020
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40020&action=edit
Preprocessed file

Hello everyone,

I encountered a problem with compiling my code and wrote up a small snippet to
reproduce the issue (see below). I get the error message "inlining failed in
call to always_inline ‘memset’: function not inlinable" when setting
-fcilkplus.

Since I carefully read the bug reporting instructions, here are the necessary
informations:

GCC Version: 6.2.0 20161018 (Ubuntu 6.2.0-7ubuntu11).
Sytem type: x86_64-linux-gnu
GCC has been built with: ../src/configure -v --with-pkgversion='Ubuntu
6.2.0-7ubuntu11' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared
--enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu

Complete commandline that triggers the bug: gcc-6 -O2 -fcilkplus -o test3
test3.c (it won't happen with -O0, but you can also use -O1, -O3 and -Os)

Compiler output:

In file included from /usr/include/features.h:364:0,
                 from /usr/include/string.h:25,
                 from test3.c:2:
test3.c: In function ‘sum’:
/usr/include/x86_64-linux-gnu/bits/string3.h:78:1: error: inlining failed in
call to always_inline ‘memset’: function not inlinable
 __NTH (memset (void *__dest, int __ch, size_t __len))
 ^
test3.c:16:3: note: called from here
   memset(foo, 0, 64*sizeof(int)); // <--- Fails
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Source code:
---------------------------------------
#include <cilk/cilk.h>
#include <string.h>
#include <malloc.h>

int sum(int low, int high) {
  if(low == high) {
    return low;
  }

  int mid = low + (high-low)/2;
  int a = cilk_spawn sum(low, mid);
  int b = sum(mid+1, high);

  // Some very expensive computation here
  int foo[64];
  memset(foo, 0, 64*sizeof(int)); // <--- Fails

  cilk_sync;

  return a+b;
}

int main(void) {
  return sum(0, 100);
}
---------------------------------------

I have attached the preprocessed file (because it's quite lengthy).

I think there was a similar bug in GCC 5 when using intrinsics, but that has
been fixed in GCC 6 (see http://stackoverflow.com/q/31846389/773690 - Code
compiles just fine), so that might me a regression or other edge case.

If there is a workaround I can do that would be greatly appreciated if you
could give a short hint. clang compiles the code just fine (but generates slow
code) and icc is expensive.

Thank you very much!

Reply via email to