Hi again, Sorry for the delay, I have been offline for a while.
You wrote: >Regarding address spaces, I saw that there is a pass to remove address space casts. But if I generate IR using `llvm-goc -dump-ir -enable-gc=1 test.go` for the following go file, I still can see the addrspacecast instruction. What is the reason to see that addrspacecast? I feel that pass is not running. Can you help me to understand this problem? 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.go In 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 On Mon, Jul 5, 2021 at 3:08 AM Kavindu Gimhan Zoysa <kavindu...@gmail.com> wrote: > Hi, > > Regarding address spaces, I saw that there is a pass to remove address > space casts. But if I generate IR using `*llvm-goc -dump-ir -enable-gc=1 > test.go*` for the following go file, I still can see the *addrspacecast* > instruction. What is the reason to see that *addrspacecast? *I feel that > pass is not running. Can you help me to understand this problem? > > > *package main* > > *func main() {* > * _ = stackIt2()* > *}* > *//go:noinline* > *func stackIt2() *int {* > * y := 2* > * res := y * 2* > * return &res* > *}* > > Thank you, > Kavindu > On Tuesday, 29 June 2021 at 18:22:14 UTC+5:30 th...@google.com wrote: > >> See https://llvm.org/docs/Statepoints.html for more on this. >> >> Thanks, Than >> >> >> On Mon, Jun 28, 2021 at 5:40 AM Kavindu Gimhan Zoysa <kavin...@gmail.com> >> wrote: >> >>> Hi all, >>> >>> Can you please explain the reason to use different address space when GC >>> is enabled as shown in the below line? >>> >>> >>> https://go.googlesource.com/gollvm/+/refs/heads/master/driver/CompileGo.cpp#559 >>> >>> Thank you, >>> Kavindu >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "golang-nuts" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to golang-nuts...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/golang-nuts/d95934ca-4488-4071-8c07-bb33122be387n%40googlegroups.com >>> <https://groups.google.com/d/msgid/golang-nuts/d95934ca-4488-4071-8c07-bb33122be387n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/c26ff4b9-84a9-4aa2-a450-5d1796aba1c0n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/c26ff4b9-84a9-4aa2-a450-5d1796aba1c0n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CA%2BUr55Gqi9p4jDbiUWAAE_amhMsrCLf4gUc5-XTR8wd4pVjMEg%40mail.gmail.com.