From 2938437efc5155cc6c0730cb26a827bef1b9717f Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 23 Sep 2018 03:03:40 +0200 Subject: [PATCH] compiler: make string data unnamed addresses This ensures LLVM can merge identical strings, and thus reduces code size in some cases. --- compiler/compiler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/compiler.go b/compiler/compiler.go index efe3b2fb..f7f9db2b 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -2734,6 +2734,7 @@ func (c *Compiler) parseConst(prefix string, expr *ssa.Const) (llvm.Value, error global.SetInitializer(c.ctx.ConstString(str, false)) global.SetLinkage(llvm.InternalLinkage) global.SetGlobalConstant(true) + global.SetUnnamedAddr(true) zero := llvm.ConstInt(llvm.Int32Type(), 0, false) strPtr := c.builder.CreateInBoundsGEP(global, []llvm.Value{zero, zero}, "") strObj := llvm.ConstNamedStruct(c.mod.GetTypeByName("runtime._string"), []llvm.Value{strPtr, strLen})