[PATCH] Initial contribution of llgo, a Go frontend

Peter Collingbourne peter at pcc.me.uk
Mon Nov 24 16:56:50 PST 2014


================
Comment at: tools/llgo/irgen/annotations.go:22
@@ +21,3 @@
+	"go/token"
+	"llvm.org/llvm/bindings/go/llvm"
+)
----------------
ruiu wrote:
> Is this how gofmt sorted?
Reformatted (here and elsewhere).

================
Comment at: tools/llgo/irgen/cabi.go:42
@@ +41,3 @@
+	width  int
+	signed bool
+}
----------------
ruiu wrote:
> This field doesn't seems to be used at all. Is this needed?
This field ought to be used to control whether certain arguments receive a signext or zeroext attribute, but it seems we've somehow gotten away with not doing this up to now. Fixed.

================
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
----------------
ruiu wrote:
> Oh okay, so the function is used only here. Then the thing I pointed out above is not actually a problem.
Right.

================
Comment at: tools/llgo/irgen/cabi.go:207
@@ +206,3 @@
+			}
+		}
+
----------------
ruiu wrote:
> 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?
It shouldn't do. This function is only used when passing an argument directly (i.e. in registers), and with the System V x86-64 calling convention that can only happen with arguments of size <= 16 bytes.

================
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(), "")
----------------
ruiu wrote:
> 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).
See include/llvm/IR/IRBuilder.h line 1469 or thereabouts -- this will compare the given value against the null value of its type, which in this case would just be integer zero.

http://reviews.llvm.org/D6327






More information about the llvm-commits mailing list