<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54240>54240</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang segfaults in llvm::TargetLowering::LowerCallTo
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          wierton
      </td>
    </tr>
</table>

<pre>
    Reproducer:

$ cat new.c
```
typedef unsigned __int128 T;

T b;

static __attribute__((noipa)) T foo(
    T c, T d, T e, T f, T g, T h) {
  __builtin_mul_overflow((unsigned char)h, -16, &h);
  return b + h;
}

int main() {
  int ctf0_idx;
  ctf0_idx = (int)0x00000000;
  int ctf0_constval;
  ctf0_constval = (int)0x00000000;
  int *ctf0_arr[] = {&ctf0_constval};
  int ctf1_idx;
  ctf1_idx = (int)0x00000000;
  int ctf1_constval;
  ctf1_constval = (int)0x00000000;
  int *ctf1_arr[] = {&ctf1_constval};
  T x = foo(0, 0, 0, 0, 0,
      ((*ctf0_arr[ctf0_idx]) << (*ctf1_arr[ctf1_idx])));
  int ctf2_idx;
  ctf2_idx = (int)0x00000000;
  int ctf2_constval;
  ctf2_constval = (int)0x00000000;
  int *ctf2_arr[] = {&ctf2_constval};
  int ctf3_idx;
  ctf3_idx = (int)0x00000000;
  int ctf3_constval;
  ctf3_constval = (int)0x00000000;
  int *ctf3_arr[] = {&ctf3_constval};
  if (((*ctf2_arr[ctf2_idx]) << (*ctf3_arr[ctf3_idx])))
    __builtin_abort();
  return 0;
}
```

$ clang-11 -O0 -mllvm -polly -fwrapv new.c
```
new.c:5:23: warning: unknown attribute 'noipa' ignored [-Wunknown-attributes]
static __attribute__((noipa)) T foo(
                      ^
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_M_construct null not valid
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /usr/lib/llvm-11/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name new.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-11/lib/clang/11.0.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-11/lib/clang/11.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -fdebug-compilation-dir /home/wierton/L-fuzz.buglist/3 -ferror-limit 19 -fwrapv -fgnuc-version=4.2.1 -fcolor-diagnostics -mllvm -polly -faddrsig -o /tmp/new-bb46d3.o -x c new.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'new.c'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@foo'
 #0 0x00007f72de77042f llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xaa642f)
 #1 0x00007f72de76e790 llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xaa4790)
 #2 0x00007f72de770905 (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xaa6905)
 #3 0x00007f72e58293c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
 #4 0x00007f72dd7cd03b raise /build/glibc-sMfBJT/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f72dd7ac859 abort /build/glibc-sMfBJT/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f72ddb86911 (/lib/x86_64-linux-gnu/libstdc++.so.6+0x9e911)
 #7 0x00007f72ddb9238c (/lib/x86_64-linux-gnu/libstdc++.so.6+0xaa38c)
 #8 0x00007f72ddb923f7 (/lib/x86_64-linux-gnu/libstdc++.so.6+0xaa3f7)
 #9 0x00007f72ddb926a9 (/lib/x86_64-linux-gnu/libstdc++.so.6+0xaa6a9)
#10 0x00007f72ddb8921e std::__throw_logic_error(char const*) (/lib/x86_64-linux-gnu/libstdc++.so.6+0xa121e)
#11 0x00007f72ded96e16 (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x10cce16)
#12 0x00007f72e0794050 (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x2aca050)
#13 0x00007f72e07920e6 (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x2ac80e6)
#14 0x00007f72ded5eca7 llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x1094ca7)
#15 0x00007f72decec5a1 (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x10225a1)
#16 0x00007f72dece17b8 (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x10177b8)
#17 0x00007f72decf702d (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x102d02d)
#18 0x00007f72decfafde llvm::SelectionDAG::LegalizeTypes() (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x1030fde)
#19 0x00007f72dedd1dc6 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x1107dc6)
#20 0x00007f72dedd1502 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x1107502)
#21 0x00007f72dedcf201 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x1105201)
#22 0x00007f72e076a6c5 (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x2aa06c5)
#23 0x00007f72dea4239e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xd7839e)
#24 0x00007f72de87f579 llvm::FPPassManager::runOnFunction(llvm::Function&) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xbb5579)
#25 0x00007f72de884b23 llvm::FPPassManager::runOnModule(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xbbab23)
#26 0x00007f72de87fb90 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xbb5b90)
#27 0x00007f72e41ef1a6 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> >) (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x15811a6)
#28 0x00007f72e44ad076 (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x183f076)
#29 0x00007f72e3578003 clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x90a003)
#30 0x00007f72e4b425c8 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1ed45c8)
#31 0x00007f72e4af88c1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1e8a8c1)
#32 0x00007f72e4ba7f50 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1f39f50)
#33 0x00000000004125ff cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-11/bin/clang+0x4125ff)
#34 0x0000000000410a3e (/usr/lib/llvm-11/bin/clang+0x410a3e)
#35 0x000000000041084a main (/usr/lib/llvm-11/bin/clang+0x41084a)
#36 0x00007f72dd7ae0b3 __libc_start_main /build/glibc-sMfBJT/glibc-2.31/csu/../csu/libc-start.c:342:3
#37 0x000000000040dcde _start (/usr/lib/llvm-11/bin/clang+0x40dcde)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 11.0.0-2~ubuntu20.04.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/new-a4a34b.c
clang: note: diagnostic msg: /tmp/new-a4a34b.sh
clang: note: diagnostic msg:

********************
```

my clang version:
```
$ clang-11 -v
Ubuntu clang version 11.0.0-2~ubuntu20.04.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/lib/cuda, version 10.1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNWsly4zgS_Rr5gqCCO6mDD7JsVdWEa-woq6fnpgBBUGI3RXK4eOmv7weAoggtZVnVjhgHLW5A5ssFmQmAURG_Xf_gZVXELePVyJmOzNuRuf21Xc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