[LLVMdev] Ada bound checks

Andre Tavares andrelct at dcc.ufmg.br
Wed May 27 10:31:05 PDT 2009


Dear Duncan,

Everything worked out with your help. Thanks. I'm now looking at bound
checks that an Ada program has, so I can remove all possible. It seams
that Ada already does some optimization to remove bound checks. Do you
know how are they done, and where?

I tested two codes (below) and the first code did not produce any bound
check and the second produced two bound checks.

--
-- Simple array example.
--
with Gnat.Io; use Gnat.Io;
procedure Arr2 is
   A: array(1..5) of Integer;   -- Array subscripts 1 to 5.
   I: Integer;
begin
   -- Read 'em in.
   for I in 1..5 loop
      Put("> ");
      Get(A(I));
   end loop;

   -- Put 'em out in reverse order.
   Put("[");
   for I in reverse A'Range loop
      Put(A(I));
      if I > A'First then
         Put(' ');
      end if;
   end loop;
   Put_Line("]");
end Arr2;


--
-- Simple array example 2
--
with Gnat.Io; use Gnat.Io;
procedure Arr1 is
   A: array(1..5) of Integer;   -- Array subscripts 1 to 5.
   I: Integer;
begin
    Get(I);
    Put(A(I));
    Put(A(I+1));
end Arr1;



-- 
Andre Tavares
Master Student in Computer Science - UFMG - Brasil
http://dcc.ufmg.br/~andrelct





More information about the llvm-dev mailing list