[llvm-bugs] [Bug 33346] New: __builtin_expect assertion failure ("cast<Ty>() argument of incompatible type!")

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 7 10:05:24 PDT 2017


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

            Bug ID: 33346
           Summary: __builtin_expect assertion failure ("cast<Ty>()
                    argument of incompatible type!")
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: greg_bedwell at sn.scee.net
                CC: llvm-bugs at lists.llvm.org, xinliangli at gmail.com

Our internal testing spotted a new compile time assertion failure on trunk.
I've included a reduced C++ example that demonstrates the issue. 

Using:
clang version 5.0.0 (trunk 304912)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/greg/public_git/./build/bin


$ cat 1.cpp
// ====================================
long foo(long a) { return __builtin_expect(a, a); }
// ====================================

$ ./build/bin/clang -c 1.cpp -O1
clang-5.0: /home/greg/public_git/llvm/include/llvm/Support/Casting.h:254:
typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X =
llvm::ConstantInt; Y = llvm::Value; typename llvm::cast_retty<X, Y*>::ret_type
= llvm::ConstantInt*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of
incompatible type!"' failed.


We've bisected it to r304517 (
http://llvm.org/viewvc/llvm-project?view=revision&revision=304517 ):

~~
[Profile] Enhance expect lowering to handle correlated branches

builtin_expect applied on && or || expressions were not
handled properly before. With this patch, the problem is fixed.

Differential Revision: http://reviews.llvm.org/D33164
~~

-- 
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/20170607/a0733640/attachment.html>


More information about the llvm-bugs mailing list