Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Optimized and unoptimized version of the clang-built program behave differently #42007

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR43038
Status NEW
Importance P enhancement
Reported by Yuri (yuri@tsoft.com)
Reported on 2019-08-18 16:46:27 -0700
Last modified on 2019-08-18 16:46:27 -0700
Version 8.0
Hardware PC FreeBSD
CC blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments llvm-auto-no-assert-without-optimization.tgz (523673 bytes, application/x-compressed-tar)
Blocks
Blocked by
See also
Created attachment 22387
testcase

The attached testcase's behavior is different when it is built with -O2 and
without -O2.

With -O2 it fails with this Eigen exception:
> Assertion failed: (lhs.cols() == rhs.rows() && "invalid matrix product" &&
"if you wanted a coeff-wise or a dot product use the respective explicit
functions"), function Product, file
/usr/local/include/eigen3/Eigen/src/Core/Product.h, line 97.
> Abort trap

Without -O2 it doesn't print the exception and succeeds.

The line labeled with "// BUG" seems to be related.
It produces some Eigen-specific type
(N5Eigen7ProductINS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEES2_Li0EEE) in place of
"auto" that later crashes with -O2.
If this "auto" is replaced with "M" (regular matrix) - it doesn't crash with -
O2.

While looking at this code, I can't tell why does it fail conditionally on -O2
like this. Nothing there alters that matrix, or any arguments of that
multiplication.

Optimization level should not trigger changes of behavior like this, especially
additional asserts.

clang-8 and clang-9 on FreeBSD 12 amd64.
Quuxplusone commented 5 years ago

Attached llvm-auto-no-assert-without-optimization.tgz (523673 bytes, application/x-compressed-tar): testcase