<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - segfault in llvm::FPPassManager::runOnFunction, running X86 FP Stackifier pass"
   href="https://bugs.llvm.org/show_bug.cgi?id=32832">32832</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>segfault in llvm::FPPassManager::runOnFunction, running  X86 FP Stackifier  pass
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>4.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>peter@cordes.ca
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>While compiling some code with rotates and bswaps (that's what I changed most
recently), I hit a compiler error.

I'm using x86-64 Arch Linux's clang-4.0.0-1 package.
  (<a href="https://www.archlinux.org/packages/extra/x86_64/clang/">https://www.archlinux.org/packages/extra/x86_64/clang/</a>).

#0 0x00007f56bf845d88 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/bin/
../lib/libLLVM-4.0.so+0x76fd88)
#1 0x00007f56bf843cae llvm::sys::RunSignalHandlers()
(/usr/bin/../lib/libLLVM-4.0.so+0x76dcae)
#2 0x00007f56bf843dea (/usr/bin/../lib/libLLVM-4.0.so+0x76ddea)
#3 0x00007f56be7c6a90 __restore_rt (/usr/bin/../lib/libc.so.6+0x33a90)
#4 0x00007f56c0fd7f98 (/usr/bin/../lib/libLLVM-4.0.so+0x1f01f98)
#5 0x00007f56c0fda55d (/usr/bin/../lib/libLLVM-4.0.so+0x1f0455d)
#6 0x00007f56c0fdbf4a (/usr/bin/../lib/libLLVM-4.0.so+0x1f05f4a)
#7 0x00007f56bfa9a841 llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/usr/bin/../lib/libLLVM-4.0.so+0x9c4841)
#8 0x00007f56bf91ab32 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/bin/../lib/libLLVM-4.0.so+0x844b32)
#9 0x00007f56bf91abd3 llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/bin/../lib/libLLVM-4.0.so+0x844bd3)
#10 0x00007f56bf91b584 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/bin/../lib/libLLVM-4.0.so+0x845584)
#11 0x000000000078f9eb clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) (/usr/bin/clang-4.0+0x78f9eb)
#12 0x0000000000b5f4b0 (/usr/bin/clang-4.0+0xb5f4b0)
#13 0x0000000000cadaa8 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/bin/clang-4.0+0xcadaa8)
#14 0x0000000000acf56e clang::FrontendAction::Execute()
(/usr/bin/clang-4.0+0xacf56e)
#15 0x0000000000a9ff66
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/bin/clang-4.0+0xa9ff66)
#16 0x0000000000b58022
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/bin/clang-4.0+0xb58022)
#17 0x0000000000746298 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/bin/clang-4.0+0x746298)
#18 0x0000000000742002 main (/usr/bin/clang-4.0+0x742002)
#19 0x00007f56be7b3511 __libc_start_main (/usr/bin/../lib/libc.so.6+0x20511)
#20 0x000000000074417a _start (/usr/bin/clang-4.0+0x74417a)
Stack dump:
0.      Program arguments: /usr/bin/clang-4.0 -cc1 -triple
x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name CanvasRenderingContext2d.cc
-mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu sandybridge -target-feature -sse2 -mllvm
-x86-asm-syntax=intel -momit-leaf-frame-pointer -dwarf-column-info
-debugger-tuning=gdb -coverage-notes-file
/home/peter/src/primity/node-canvas/build/-.gcno -resource-dir
/usr/bin/../lib/clang/4.0.0 -dependency-file
./Release/.deps/Release/obj.target/canvas/src/CanvasRenderingContext2d.o.d.raw
-MT - -D NODE_GYP_MODULE_NAME=canvas -D USING_UV_SHARED=1 -D USING_V8_SHARED=1
-D V8_DEPRECATION_WARNINGS=1 -D _LARGEFILE_SOURCE -D _FILE_OFFSET_BITS=64 -D
HAVE_FREETYPE -D HAVE_PANGO -D HAVE_JPEG -D HAVE_GIF -D BUILDING_NODE_EXTENSION
-I /home/peter/.node-gyp/7.7.3/include/node -I /home/peter/.node-gyp/7.7.3/src
-I /home/peter/.node-gyp/7.7.3/deps/uv/include -I
/home/peter/.node-gyp/7.7.3/deps/v8/include -I ../../nan -I /usr/include/cairo
-I /usr/include/pixman-1 -I /usr/include/freetype2 -I /usr/include/libpng16 -I
/usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include -I
/usr/include/libdrm -I /usr/include/pango-1.0 -internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../include/c++/6.3.1
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../include/c++/6.3.1/x86_64-pc-linux-gnu
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../include/c++/6.3.1/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/bin/../lib/clang/4.0.0/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -O3 -Wall -Wextra -Wno-unused-parameter
-std=gnu++0x -fdeprecated-macro -fdebug-compilation-dir
/home/peter/src/primity/node-canvas/build -ferror-limit 19 -fmessage-length 0
-pthread -fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option
-vectorize-loops -vectorize-slp -o - -x c++ ../src/CanvasRenderingContext2d.cc 
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module
'../src/CanvasRenderingContext2d.cc'.
4.      Running pass 'X86 FP Stackifier' on function
'@_ZN9Context2d6RotateERKN3Nan20FunctionCallbackInfoIN2v85ValueEEE'
clang-4.0: error: unable to execute command: Segmentation fault (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

The most recent changes from when it didn't segfault, IIRC, were in
copy1PixRGBAtoNative (called from PutImageData), and adding
 Canvas *canvas = context->canvas();
early in PutImageData instead of re-chasing the pointer every time it's used.

(I'm working on speeding up PutImageData and GetImageData in node-canvas,
<a href="https://github.com/Automattic/node-canvas/issues/909">https://github.com/Automattic/node-canvas/issues/909</a>)

In case it's relevant, in a version that did compile, I noticed that clang
decided *not* to use a ROR instruction to rotate by 8 bits, but instead do two
shifts + and OR, because it wanted to keep one of the shifted values around for
use in an unlikely() branch.  i.e. it seriously slowed down the fast path
because of CSE with the slow path, for the scalar version.  /facepalm.  Extra
MOV instructions for this reason seem to be common for gcc, but clang had
mostly been doing better.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>