[llvm-bugs] [Bug 40767] New: crash from IRBuilder with intrinsic already declared with type alias/substitute

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 18 14:29:29 PST 2019


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

            Bug ID: 40767
           Summary: crash from IRBuilder with intrinsic already declared
                    with type alias/substitute
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org

This is the same root cause as this fuzzer bug, but I made a slightly simpler
repro for instcombine:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13174

; Declaration with return type alias(?)
%0 = type { i32, i1 }
declare %0 @llvm.uadd.with.overflow.i32(i32, i32)

define i32 @no_carryin_i32(i32 %x, i32 %y, i8* %p) {
  %s = call { i8, i32 } @llvm.x86.addcarry.32(i8 0, i32 %x, i32 %y)
  %ov = extractvalue { i8, i32 } %s, 0
  store i8 %ov, i8* %p
  %r = extractvalue { i8, i32 } %s, 1
  ret i32 %r
}
declare { i8, i32 } @llvm.x86.addcarry.32(i8, i32, i32)

----------------------------------------------------------------------------

The existing intrinsic declaration causes a crash when we try to create a new
call to that intrinsic using IRBuilder.

$ opt -instcombine addcarry.ll -S
Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"),
function cast, file
/Users/spatel/GitHub/llvm-project/llvm/include/llvm/Support/Casting.h, line
254.
Stack dump:
0.      Program arguments: ./opt -instcombine addcarry.ll -S 
1.      Running pass 'Function Pass Manager' on module 'addcarry.ll'.
2.      Running pass 'Combine redundant instructions' on function
'@no_carryin_i32'
0  opt                      0x00000001035e8ab8
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  opt                      0x00000001035e79e8 llvm::sys::RunSignalHandlers() +
248
2  opt                      0x00000001035e90d8 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff75ac9b3d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000000020 _sigtramp + 2320721152
5  libsystem_c.dylib        0x00007fff759871c9 abort + 127
6  libsystem_c.dylib        0x00007fff7594f868 basename_r + 0
7  opt                      0x0000000102f1d0d2
llvm::Intrinsic::getDeclaration(llvm::Module*, llvm::Intrinsic::ID,
llvm::ArrayRef<llvm::Type*>) + 210
8  opt                      0x0000000102f2713e
llvm::IRBuilderBase::CreateIntrinsic(llvm::Intrinsic::ID,
llvm::ArrayRef<llvm::Type*>, llvm::ArrayRef<llvm::Value*>, llvm::Instruction*,
llvm::Twine const&) + 62
9  opt                      0x00000001030fdc61
llvm::InstCombiner::visitCallInst(llvm::CallInst&) + 10929

-- 
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/20190218/0c986930/attachment.html>


More information about the llvm-bugs mailing list