<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56809>56809</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLVM 15.x fatal assert when having both @llvm.global_ctors and @llvm.global_dtors
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jmaebe
</td>
</tr>
</table>
<pre>
15.x branch, d77882e
Happens both with opaque and with typed pointers.
Repro: `llc tt.ll`
```
Assertion failed: (C->getType() == Ty->getElementType() && "Wrong type in array element initializer"), function getImpl, file /Data/dev/llvm/llvm/lib/IR/Constants.cpp, line 1254.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /Data/dev/llvminst/bin/llc tt.ll
1. Running pass 'Lower @llvm.global_dtors via `__cxa_atexit`' on module 'tt.ll'.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 llc 0x000000010278d45b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 43
1 llc 0x000000010278c451 llvm::sys::RunSignalHandlers() + 97
2 llc 0x000000010278dad6 SignalHandler(int) + 278
3 libsystem_platform.dylib 0x00007fff6f362b5d _sigtramp + 29
4 libsystem_platform.dylib 0x000000010f36b938 _sigtramp + 18446603343200554488
5 libsystem_c.dylib 0x00007fff6f21c6a6 abort + 127
6 libsystem_c.dylib 0x00007fff6f1e520d basename_r + 0
7 llc 0x00000001031fbb43 llvm::ConstantArray::getImpl(llvm::ArrayType*, llvm::ArrayRef<llvm::Constant*>) (.cold.31) + 35
8 llc 0x0000000101ee8eae llvm::ConstantArray::getImpl(llvm::ArrayType*, llvm::ArrayRef<llvm::Constant*>) + 3198
9 llc 0x0000000101ee817f llvm::ConstantArray::get(llvm::ArrayType*, llvm::ArrayRef<llvm::Constant*>) + 31
10 llc 0x000000010284d671 appendToGlobalArray(char const*, llvm::Module&, llvm::Function*, int, llvm::Constant*) + 961
11 llc 0x000000010284076b runImpl(llvm::Modu
le&) + 4971
12 llc 0x0000000101fc5d3a llvm::legacy::PassManagerImpl::run(llvm::Module&) + 906
13 llc 0x000000010108ea50 main + 8032
14 libdyld.dylib 0x00007fff6f1773d5 start + 1
15 libdyld.dylib 0x0000000000000002 start + 18446603338652355630
Abort trap: 6
```
If either the ctors or dtors line is commented out from tt.ll, it works fine. It even repros if you just duplicate the ctors line and rename it to dtors, or vice versa (so it's not related to the fact that one contains an external global and the other a function declaration).
[tt.ll.txt](https://github.com/llvm/llvm-project/files/9222225/tt.ll.txt)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFV9tu4zYQ_Rr7ZbCGROr64Afnst0ACRokQYv2xaCkkc1dSVRJyon79Tuk5MTeBFi3QFFBkCVeDg9nhjPHhar2yzBevEChRVduZ-wSqjTNMoaz4GoWrMbnF9H32BkolN3Cs6SH6sVfA4LoqvHb7nusoFeys6jN4njyA_ZazfgKZknQNCVYu2gaej8e4z7H23-ujEFtpeqgFrLBys9m2eWnGb_eoH2ixehzxnKY8Su64Wk_dV032GJ3MoIldNMP-12rbuOZguxAaC32gON4apBWikb-jZpG0jxniXroSs-CgG_avvFtxIfAPl8JK-inwh09m2bXHv3Igp43D_S4VJ2xorNmUfa9m97IDiFkcTSZ6P72evV4DWYoWmlBQDFsQGOvtAWrYGttb2jzhET3hgw9FItStadLfiL7fsXS0qc0ZkBDL94zsiuboUKwW4RSC7OFQpTfrBYlTss_WmqAamh7t4pvCqgrv9dqo0VLRtoMzj5m9MD7XUvaH70WsvMNB-96pNAhPQxdJ8nsvTCGENJb9YwaZlHgZi82jSpEs66s0gZ2UrgYWa_LF7EWFl-kdRHBUiAXtKoavOXTcQWWvtuCj0Q1WDD7tlANdKJFt2ZGoTtohL0aYCt2CN5o4yDncBcN1KfhfvX0BZQGg9bbDLudpJjxAbIT2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