how gollvm produces a project llvm-ir

169 views
Skip to first unread message

ZHOU PERTER

unread,
May 10, 2021, 8:09:53 AM5/10/21
to golang-nuts
Hi,
i want to use gollvm to produces a project llvm-ir
i use `go build -work -x . 1> transcript.txt 2>&1` and `egrep '(WORK=|llvm-goc -c)' transcript.txt`
to ever `llvm-goc -c` command add `-S -emit-llvm` to produces .ll for each .go file
then i use https://github.com/llir/llvm to transfer llvm ir to go build-in struct,but llir only parse one file 
for simple file it's ok
```
package main
import (
    "fmt"
)
func main(){
    a := "hello_world"
    fmt.Println(a)
}
but for multiple packages project the error `unable to locate ParamAttr enum corresponding to "noundef"` occur when i only provide main.ll。
any way to merger mutli .ll to one .ll or other method so that  i can do multiple packages project data flow analysis?
Thankss,
PERTER

Than McIntosh

unread,
May 10, 2021, 8:29:53 AM5/10/21
to ZHOU PERTER, golang-nuts
Hi,

It wasn't clear from your email exactly what you are doing or what the error was you encountered (grepping in the gollvm/LLVM sources didn't turn up any error code similar to "unable to locate ParamAttr enum"), but I think it is safe to say that this isn't a supported use case for gollvm, at least I don't know of anyone who is doing this sort of thing already.

Generating a *.ll IR file for each translation unit and then reading them all together sounds difficult, seems as though you would need some sort of very strong type unification in order to match up types that are common/shared among translation units. Have you tried doing this on C code, for example?

Thanks, Than




--
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/2c329707-bc0f-4603-9e98-199102280cecn%40googlegroups.com.

ZHOU PERTER

unread,
May 10, 2021, 9:08:57 AM5/10/21
to golang-nuts
Hi Than,
Thanks for reply
For C or C++ code ,there is a tool wllvm and go version gllvm that can building whole-program llvm-ir,so i wonder is there any same tool in gollvm
PETER

Than McIntosh

unread,
May 10, 2021, 9:23:56 AM5/10/21
to ZHOU PERTER, golang-nuts
Hi,

I looked over the gllvm sources, looks interesting. There is no equivalent for gollvm, someone would need to contribute it. I don't see any fundamental reason why it would not work, but I am sure there would be challenges and wrinkles.

One thing to note is that gllvm is emitteding bitcode (*.bc) files, not LLVM IR dumps (*.ll). 

Thanks, Than


Reply all
Reply to author
Forward
0 new messages