A couple of things on this.
First, the "-dump-ir" option to llvm-goc shows the LLVM IR after the front end and bridge are done with creating it -- at this point no LLVM passes will have been run, so you would not expect to see any address space casts removed. Probably what you want here is "-emit-llvm", which will show LLVM IR after all the various module and function passes have run (before the switch to machine-dependent IR). Example:
$ llvm-goc -S -emit-llvm -enable-gc=1 test.go
$ cat test.ll
...
$
A second thing is that the cast-removal pass you mention isn't removing every cast, only casts on initialized global variables fed with constants. If you look at this source code
https://go.googlesource.com/gollvm/+/38bada572789a19cf881201c923e6b56ed32ae53/passes/RemoveAddrSpace.cpp#95
you can see that it's visiting only initialized globals. If you want to examples of cast removal, try running your compile on a larger and more interesting test case, like
https://golang.org/test/method5.goIn general if you are unsure about whether a pass is running and/or what the effects of the pass are, there are developer options you can try (note: available only in a pure debug build) that can show you more. Example:
# Dump LLVM IR before a pass
$ ./bin/llvm-goc -O2 -c -emit-llvm -S -enable-gc=1 -mllvm -print-before=remove-addrspacecast test.go 1> before.dump.txt 2>&1
# Dump LLVM IR after a pass
$ ./bin/llvm-goc -O2 -c -emit-llvm -S -enable-gc=1 -mllvm -print-after=remove-addrspacecast test.go 1> after.dump.txt 2>&1
Hope this helps.
Thanks, Than