[PATCH] Initial contribution of llgo, a Go frontend

Rui Ueyama ruiu at google.com
Mon Nov 24 14:52:27 PST 2014


================
Comment at: tools/llgo/irgen/annotations.go:22
@@ +21,3 @@
+	"go/token"
+	"llvm.org/llvm/bindings/go/llvm"
+)
----------------
Is this how gofmt sorted?

================
Comment at: tools/llgo/irgen/cabi.go:42
@@ +41,3 @@
+	width  int
+	signed bool
+}
----------------
This field doesn't seems to be used at all. Is this needed?

================
Comment at: tools/llgo/irgen/cabi.go:95
@@ +94,3 @@
+	}
+	return o
+}
----------------
Doesn't this have to include the padding after the last member? I mean if we have a struct, say struct { int; char; }, it's size would be calculated as 5 by this function, but I think it should be 8. (If it's 5, sizeof [2]struct{ int; char; } would become 10?)

================
Comment at: tools/llgo/irgen/cabi.go:103
@@ +102,3 @@
+func (tm *llvmTypeMap) classify(t ...types.Type) abiArgInfo {
+	if tm.sizeofStruct(t...) > 16 {
+		return AIK_Indirect
----------------
Oh okay, so the function is used only here. Then the thing I pointed out above is not actually a problem.

================
Comment at: tools/llgo/irgen/cabi.go:207
@@ +206,3 @@
+			}
+		}
+
----------------
Not very sure what this piece of code does... but is it going to create for example 1 million values if we have [1024 * 1024]sometype in source code?

================
Comment at: tools/llgo/irgen/strings.go:72
@@ +71,3 @@
+	fr.builder.CreateStore(result[0], indexptr.value)
+	ok := fr.builder.CreateIsNotNull(result[0], "")
+	ok = fr.builder.CreateZExt(ok, llvm.Int8Type(), "")
----------------
Does this compare a value of type int as a pointer? stringiter2 returns (int, rune), not (*sometype, rune).

Oh but this may be intentional -- currently, in all architectures sizeof(int) == sizeof(pointer).

http://reviews.llvm.org/D6327






More information about the llvm-commits mailing list