Hi,
Thanks, Than, for the answer.
So, if the .go file I'm compiling is the one with "package main" "func 
main()", I can remove the "module asm" lines without any consequences?

Khanh

On Friday, September 10, 2021 at 9:09:12 PM UTC+8 th...@google.com wrote:

> Hi,
>
> The "module asm" at the start of your bitcode dump is actually the export 
> data for the package, so it plays a pretty crucial role.
>
> Deleting the export data from the "main" package may work in some cases 
> (since nobody imports main), but it will certainly cause problems if you 
> delete the export data from some other non-main package.
>
> Export data tends to be substantial because it is based on the transitive 
> closure of the imported packages (e.g. "fmt" imports "io", then "io" 
> imports "sync", then "sync" imports "runtime", and so on).
>
> On the other hand, Go export data is *way* smaller than the volume of 
> header information that would have to be consumed by a C++ compiler when 
> building your average C++ source file.
>
> Than
>
> On Thu, Sep 9, 2021 at 6:31 AM Khanh TN <tnkh...@gmail.com> wrote:
>
>> A Helloworld written in C++ is around 75 lines in LLVM IR. 
>> However, a Helloworld written in Golang compiled with gollvm is around 
>> 900/1000 lines of .ll file. I produced the LLVM IR with instructions from 
>> https://go.googlesource.com/gollvm/
>> I'm using LLVM11, so, older compatible commit of gollvm, not sure newer 
>> versions are different.
>>
>> How can I produce shorter/simplified LLVM IR?
>> Thanks!
>>
>> Cheers,
>> Khanh
>>
>>
>> P/S: 
>> An LLVM IR file has a lot of  module asm at the start, like:
>> module asm "\09.section \22.go_export\22,\22e\22,@progbits"
>> module asm "\09.ascii \22v3;\\n\22"
>> module asm "\09.ascii \22package \22"
>> module asm "\09.ascii \22main\22"
>> module asm "\09.ascii \22\\n\22"
>> module asm "\09.ascii \22pkgpath \22"
>> module asm "\09.ascii \22main\22"
>>
>> I figure I can delete all the module asm line and my program still  runs 
>> correctly (I only tested 2 times on simple programs). Is this a legit 
>> optimization?
>>
>> -- 
>> 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/8ee91024-b270-4d1e-99b9-dbcd3e25d4c4n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/8ee91024-b270-4d1e-99b9-dbcd3e25d4c4n%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/5076e1b4-8010-4667-9827-e8856d112388n%40googlegroups.com.

Reply via email to