Repository: go
Issue: gollvm: build aborted when creating a self-referential ArrayT type in TypeManager::buildDIType
Labels: NeedsInvestigation

TypeManager::buildDIType does not create a replacement type for ArrayT type, and the build will be aborted when creating a self-referential ArrayT type.

### What version of Go are you using (`go version`)?

gollvm master 

DCMAKE_BUILD_TYPE=Debug

<pre>
$ go version
go version unknown linux/amd64
</pre>

### Does this issue reproduce with the latest release?

Yes

### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env

</pre></details>

### What did you do?

The issue may be reproduced with the following sample:

go run a.go 

File a.go

```go
package a

const size = 1

type S struct {
	Array [size]*S
}

// not pass
type S1 struct {
	Array [size]*S
}
// type S1 S // not pass
// type S1 = S // pass

func (p *S1) Init() {

}
```



### What did you expect to see?

No error, successful build.

### What did you see instead?

```bash
[root@kwephis525702 test]# go run a.go 
# command-line-arguments
llvm-goc: /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm-typemanager.cpp:1889: llvm::DIType* TypeManager::buildDIType(Btype*, DIBuildHelper&): Assertion `tcit->second != nullptr' failed.
 #0 0x0000000002c53ad9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:0
 #1 0x0000000002c53b90 PrintStackTraceSignalHandler(void*) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:0
 #2 0x0000000002c51b55 llvm::sys::RunSignalHandlers() /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/lib/Support/Signals.cpp:97:0
 #3 0x0000000002c5351d SignalHandler(int) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:0
 #4 0x00007fe7e07fd5a0 (/usr/lib64/libpthread.so.0+0x135a0)
 #5 0x00007fe7e00f078b raise (/usr/lib64/libc.so.6+0x3978b)
 #6 0x00007fe7e00f1ab1 abort (/usr/lib64/libc.so.6+0x3aab1)
 #7 0x00007fe7e00e904a (/usr/lib64/libc.so.6+0x3204a)
 #8 0x00007fe7e00e90c2 (/usr/lib64/libc.so.6+0x320c2)
 #9 0x000000000064bf55 TypeManager::buildDIType(Btype*, DIBuildHelper&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm-typemanager.cpp:1890:0
#10 0x000000000064ba31 TypeManager::buildStructDIType(BStructType*, DIBuildHelper&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm-typemanager.cpp:1834:0
#11 0x000000000064c7e9 TypeManager::buildDIType(Btype*, DIBuildHelper&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm-typemanager.cpp:1988:0
#12 0x000000000064c4f8 TypeManager::buildDIType(Btype*, DIBuildHelper&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm-typemanager.cpp:1968:0
#13 0x000000000064c5df TypeManager::buildDIType(Btype*, DIBuildHelper&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm-typemanager.cpp:1975:0
#14 0x000000000064ba31 TypeManager::buildStructDIType(BStructType*, DIBuildHelper&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm-typemanager.cpp:1834:0
#15 0x000000000064c7e9 TypeManager::buildDIType(Btype*, DIBuildHelper&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm-typemanager.cpp:1988:0
#16 0x000000000064c4f8 TypeManager::buildDIType(Btype*, DIBuildHelper&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm-typemanager.cpp:1968:0
#17 0x000000000064c88f TypeManager::buildDIType(Btype*, DIBuildHelper&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm-typemanager.cpp:1996:0
#18 0x00000000006241a6 DIBuildHelper::beginFunction(Bfunction*, Bnode*, llvm::BasicBlock*) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm-dibuildhelper.cpp:108:0
#19 0x0000000000542b04 GenBlocks::GenBlocks(llvm::LLVMContext&, Llvm_backend*, Bfunction*, Bnode*, DIBuildHelper*, llvm::BasicBlock*) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm.cpp:2991:0
#20 0x0000000000547199 Llvm_backend::function_set_body(Bfunction*, Bstatement*) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/bridge/go-llvm.cpp:4052:0
#21 0x000000000045b760 Function::build(Gogo*, Named_object*) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/gofrontend/go/gogo.cc:6686:0
#22 0x00000000004620cd Named_object::get_backend(Gogo*, std::vector<Bexpression*, std::allocator<Bexpression*> >&, std::vector<Btype*, std::allocator<Btype*> >&, std::vector<Bfunction*, std::allocator<Bfunction*> >&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/gofrontend/go/gogo.cc:8880:0
#23 0x000000000044c4ed Gogo::write_globals() /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/gofrontend/go/gogo.cc:1595:0
#24 0x000000000044494c go_write_globals() /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/gofrontend/go/go.cc:198:0
#25 0x0000000000428ca6 gollvm::driver::CompileGoImpl::invokeFrontEnd() /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/driver/CompileGo.cpp:790:0
#26 0x000000000042628e gollvm::driver::CompileGoImpl::performAction(gollvm::driver::Compilation&, gollvm::driver::Action const&, llvm::SmallVector<gollvm::driver::Artifact*, 3u> const&, gollvm::driver::Artifact const&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/driver/CompileGo.cpp:192:0
#27 0x0000000000429a76 gollvm::driver::CompileGo::performAction(gollvm::driver::Compilation&, gollvm::driver::Action const&, llvm::SmallVector<gollvm::driver::Artifact*, 3u> const&, gollvm::driver::Artifact const&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/driver/CompileGo.cpp:1005:0
#28 0x000000000041a06d gollvm::driver::Driver::processAction(gollvm::driver::Action*, gollvm::driver::Compilation&, bool) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/driver/Driver.cpp:706:0
#29 0x000000000041a1ee gollvm::driver::Driver::processActions(gollvm::driver::Compilation&) /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/driver/Driver.cpp:729:0
#30 0x000000000040e41e main /usr1/ywq/code/gollvm-workarea/llvm-project/llvm/tools/gollvm/driver-main/llvm-goc.cpp:228:0
#31 0x00007fe7e00dcc67 __libc_start_main (/usr/lib64/libc.so.6+0x25c67)
#32 0x000000000040d8ea _start (/usr1/ywq/code/gollvm-workarea/gollvm-install-debug/bin/llvm-goc+0x40d8ea)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /usr1/ywq/code/gollvm-workarea/gollvm-install-debug/bin/llvm-goc -c -O2 -g -m64 -fdebug-prefix-map=/usr1/tmp/go-build3317449572=/tmp/go-build -gno-record-gcc-switches -o $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ ./a.go $WORK/b001/_gomod_.go
```