[PATCH] [llgo] irgen: fix canAvoid*

Andrew Wilkins axwalk at gmail.com
Tue Dec 16 17:39:21 PST 2014


================
Comment at: irgen/ssa.go:702
@@ +701,3 @@
+		switch ref := ref.(type) {
+		case *ssa.Field:
+		case *ssa.Index:
----------------
pcc wrote:
> Can you leave the `// ok` comment here? This would make it a little clearer that we intend to accept the referrer rather than falling through.
ok

================
Comment at: irgen/ssa.go:718
@@ -714,3 +717,3 @@
 func (fr *frame) canAvoidLoad(instr *ssa.UnOp, op llvm.Value) bool {
 	if fr.types.Sizeof(instr.Type()) < 16 {
 		// Don't bother with small values.
----------------
pcc wrote:
> If we make this hard-coded constant something like 2*sizeof(int), we can probably be guaranteed that we will never need to check for indexes below.
Good point, array indices are always converted to int. Done.

================
Comment at: irgen/ssa.go:733
@@ -729,3 +732,3 @@
 			esc = true
-		case *ssa.Field, *ssa.Index:
-			// ok
+		case *ssa.Field:
+		case *ssa.Index:
----------------
pcc wrote:
> Likewise here.
Done.

================
Comment at: irgen/ssa.go:735
@@ +734,3 @@
+		case *ssa.Index:
+			if ref.X != instr {
+				return false
----------------
pcc wrote:
> Note that (as far as I can tell) this comparison would always fail  because `instr` at this point cannot be an appropriate size to be used as an index. We might want to panic in the body of this if statement to make it clear what our assumptions are, or just revert this part.
I've changed it to panic, and added a comment in case someone makes the same mistake I did in the future.

http://reviews.llvm.org/D6676

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list