<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 - "Assertion `Ty == cast<PointerType>(Ptr->getType())->getElementType()' failed." with -instcombine on "strlen(i16*)""
   href="https://bugs.llvm.org/show_bug.cgi?id=40626">40626</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>"Assertion `Ty == cast<PointerType>(Ptr->getType())->getElementType()' failed." with -instcombine on "strlen(i16*)"
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mikael.holmen@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21439" name="attach_21439" title="reproducer">attachment 21439</a> <a href="attachment.cgi?id=21439&action=edit" title="reproducer">[details]</a></span>
reproducer

Running

 opt -instcombine -S -o - call-strlen.ll

yields

opt: ../lib/IR/Instructions.cpp:1185: llvm::LoadInst::LoadInst(llvm::Type *,
llvm::Value *, const llvm::Twine &, bool, unsigned int, llvm::AtomicOrdering,
SyncScope::ID, llvm::Instruction *): Assertion `Ty ==
cast<PointerType>(Ptr->getType())->getElementType()' failed.
Stack dump:
0.      Program arguments: build-all/bin/opt -instcombine -S -o -
call-strlen.ll 
1.      Running pass 'Function Pass Manager' on module 'call-strlen.ll'.
2.      Running pass 'Combine redundant instructions' on function '@test_it'
 #0 0x00000000022ab7e4 PrintStackTraceSignalHandler(void*)
(build-all/bin/opt+0x22ab7e4)
 #1 0x00000000022a97f0 llvm::sys::RunSignalHandlers()
(build-all/bin/opt+0x22a97f0)
 #2 0x00000000022abb48 SignalHandler(int) (build-all/bin/opt+0x22abb48)
 #3 0x00007efebd1cf330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
 #4 0x00007efebbdbec37 gsignal
/build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
 #5 0x00007efebbdc2028 abort
/build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
 #6 0x00007efebbdb7bf6 __assert_fail_base
/build/eglibc-ripdx6/eglibc-2.19/assert/assert.c:92:0
 #7 0x00007efebbdb7ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
 #8 0x0000000001c8f5eb llvm::LoadInst::LoadInst(llvm::Type*, llvm::Value*,
llvm::Twine const&, bool, unsigned int, llvm::AtomicOrdering, unsigned char,
llvm::Instruction*) (build-all/bin/opt+0x1c8f5eb)
 #9 0x0000000001c8f3a3 llvm::LoadInst::LoadInst(llvm::Type*, llvm::Value*,
llvm::Twine const&, llvm::Instruction*) (build-all/bin/opt+0x1c8f3a3)
#10 0x000000000239c053
llvm::LibCallSimplifier::optimizeStringLength(llvm::CallInst*,
llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&,
unsigned int) (build-all/bin/opt+0x239c053)
#11 0x00000000023a823c
llvm::LibCallSimplifier::optimizeStringMemoryLibCall(llvm::CallInst*,
llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&)
(build-all/bin/opt+0x23a823c)
#12 0x00000000023a91f8 llvm::LibCallSimplifier::optimizeCall(llvm::CallInst*)
(build-all/bin/opt+0x23a91f8)
#13 0x0000000001e606c6 llvm::InstCombiner::tryOptimizeCall(llvm::CallInst*)
(build-all/bin/opt+0x1e606c6)
#14 0x0000000001e5c164 llvm::InstCombiner::visitCallBase(llvm::CallBase&)
(build-all/bin/opt+0x1e5c164)
#15 0x0000000001e5a1f2 llvm::InstCombiner::visitCallInst(llvm::CallInst&)
(build-all/bin/opt+0x1e5a1f2)
#16 0x0000000001e1ad79 llvm::InstCombiner::run() (build-all/bin/opt+0x1e1ad79)
#17 0x0000000001e1ce11 combineInstructionsOverFunction(llvm::Function&,
llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&,
llvm::TargetLibraryInfo&, llvm::DominatorTree&,
llvm::OptimizationRemarkEmitter&, bool, llvm::LoopInfo*)
(build-all/bin/opt+0x1e1ce11)
#18 0x0000000001e1d4eb
llvm::InstructionCombiningPass::runOnFunction(llvm::Function&)
(build-all/bin/opt+0x1e1d4eb)
#19 0x0000000001caf3cd llvm::FPPassManager::runOnFunction(llvm::Function&)
(build-all/bin/opt+0x1caf3cd)
#20 0x0000000001caf688 llvm::FPPassManager::runOnModule(llvm::Module&)
(build-all/bin/opt+0x1caf688)
#21 0x0000000001cafaea llvm::legacy::PassManagerImpl::run(llvm::Module&)
(build-all/bin/opt+0x1cafaea)
#22 0x00000000007a322b main (build-all/bin/opt+0x7a322b)
#23 0x00007efebbda9f45 __libc_start_main
/build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#24 0x0000000000788c7d _start (build-all/bin/opt+0x788c7d)
Abort


This started happening after commit r352911 but possibly it was broken before
too, even if the reproducer above didn't trigger the assertion then.

Also see
 <a href="http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190204/624646.html">http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190204/624646.html</a>
and the reply
 <a href="http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190204/624810.html">http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190204/624810.html</a></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>