The array element type doesn't always have a known size, which is why the ARRAY_REF supplies the size, extractable with array_ref_element_size. Fix and Ada testcase attached.
Ciao, Duncan.
Index: gcc.llvm.master/gcc/llvm-convert.cpp =================================================================== --- gcc.llvm.master.orig/gcc/llvm-convert.cpp 2007-03-08 13:56:56.000000000 +0100 +++ gcc.llvm.master/gcc/llvm-convert.cpp 2007-03-09 10:45:46.000000000 +0100 @@ -4591,9 +4591,8 @@ tree length = arrayLength(TREE_TYPE(Array)); if (length && !host_integerp(length, 1)) { // Make sure that ArrayAddr is of type ElementTy*, then do a 2-index gep. - tree ElTy = TREE_TYPE(TREE_TYPE(Array)); ArrayAddr = BitCastToType(ArrayAddr, PointerType::get(Type::Int8Ty)); - Value *Scale = Emit(TYPE_SIZE_UNIT(ElTy), 0); + Value *Scale = Emit(array_ref_element_size(exp), 0); if (Scale->getType() != IntPtrTy) Scale = CastToUIntType(Scale, IntPtrTy); @@ -4624,7 +4623,7 @@ // float foo(int w, float A[][w], int g) { return A[g][0]; } ArrayAddr = BitCastToType(ArrayAddr, PointerType::get(Type::Int8Ty)); - Value *TypeSize = Emit(TYPE_SIZE_UNIT(IndexedType), 0); + Value *TypeSize = Emit(array_ref_element_size(exp), 0); if (TypeSize->getType() != IntPtrTy) TypeSize = CastToUIntType(TypeSize, IntPtrTy);
Index: llvm.master/test/AdaFrontend/array_ref.adb =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ llvm.master/test/AdaFrontend/array_ref.adb 2007-03-09 10:47:22.000000000 +0100 @@ -0,0 +1,11 @@ +-- RUN: %llvmgcc -c %s -o /dev/null +procedure Array_Ref is + type A is array (Natural range <>, Natural range <>) of Boolean; + type A_Access is access A; + function Get (X : A_Access) return Boolean is + begin + return X (0, 0); + end; +begin + null; +end;
_______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits