From ec80da28b6bb82771044cf4c1120d24d30902873 Mon Sep 17 00:00:00 2001 From: Robert Dewar Date: Tue, 26 Jan 2010 10:55:29 +0000 Subject: [PATCH] get_scos.adb (Get_SCOs): Implement new form of CS entries (multiple entries per line... 2010-01-26 Robert Dewar * get_scos.adb (Get_SCOs): Implement new form of CS entries (multiple entries per line, one for each statement in the sequence). * par_sco.adb (Traverse_Declarations_Or_Statements): Increase array size from 100 to 10_000 for SC_Array to avoid any real possibility of overflow. Output decisions in for loops. Exclude labels from CS lines. * scos.ads: Clarify that label is not included in the entry point From-SVN: r156243 --- gcc/ada/ChangeLog | 10 ++++++++++ gcc/ada/get_scos.adb | 47 ++++++++++++++++++++++++++++++++++++++++++-- gcc/ada/par_sco.adb | 34 +++++++++++++++++++++----------- gcc/ada/scos.ads | 3 ++- 4 files changed, 80 insertions(+), 14 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 3914678a7e0..f8261fbea73 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2010-01-26 Robert Dewar + + * get_scos.adb (Get_SCOs): Implement new form of CS entries (multiple + entries per line, one for each statement in the sequence). + * par_sco.adb (Traverse_Declarations_Or_Statements): Increase array + size from 100 to 10_000 for SC_Array to avoid any real possibility of + overflow. Output decisions in for loops. + Exclude labels from CS lines. + * scos.ads: Clarify that label is not included in the entry point + 2010-01-26 Robert Dewar * par_sco.adb (Traverse_Declarations_Or_Statments): Implement new diff --git a/gcc/ada/get_scos.adb b/gcc/ada/get_scos.adb index 733263adb0a..5dd33f4bbf1 100644 --- a/gcc/ada/get_scos.adb +++ b/gcc/ada/get_scos.adb @@ -39,6 +39,11 @@ procedure Get_SCOs is use ASCII; -- For CR/LF + function At_EOL return Boolean; + -- Skips any spaces, then checks if we are the end of a line. If so, + -- returns True (but does not skip over the EOL sequence). If not, + -- then returns False. + procedure Check (C : Character); -- Checks that file is positioned at given character, and if so skips past -- it, If not, raises Data_Error. @@ -63,6 +68,16 @@ procedure Get_SCOs is -- Skips zero or more spaces at the current position, leaving the file -- positioned at the first non-blank character (or Types.EOF). + ------------ + -- At_EOL -- + ------------ + + function At_EOL return Boolean is + begin + Skip_Spaces; + return Nextc = CR or else Nextc = LF; + end At_EOL; + ----------- -- Check -- ----------- @@ -236,8 +251,36 @@ begin -- Statement entry when 'S' => - Get_Sloc_Range (Loc1, Loc2); - Add_SCO (C1 => 'S', From => Loc1, To => Loc2); + declare + Typ : Character; + Key : Character; + + begin + Skip_Spaces; + Key := 'S'; + + loop + Typ := Nextc; + + if Typ in '1' .. '9' then + Typ := ' '; + else + Skipc; + end if; + + Get_Sloc_Range (Loc1, Loc2); + + Add_SCO + (C1 => Key, + C2 => C, + From => Loc1, + To => Loc2, + Last => At_EOL); + + exit when At_EOL; + Key := 's'; + end loop; + end; -- Exit entry diff --git a/gcc/ada/par_sco.adb b/gcc/ada/par_sco.adb index bee56cd540a..e0e9318076c 100644 --- a/gcc/ada/par_sco.adb +++ b/gcc/ada/par_sco.adb @@ -766,7 +766,7 @@ package body Par_SCO is end record; -- Used to store a single entry in the following array - SC_Array : array (Nat range 1 .. 100) of SC_Entry; + SC_Array : array (Nat range 1 .. 10_000) of SC_Entry; SC_Last : Nat; -- Used to store statement components for a CS entry to be output -- as a result of the call to this procedure. SC_Last is the last @@ -777,11 +777,12 @@ package body Par_SCO is -- the temporary caching of results in this array is that we want -- the SCO table entries for a given CS line to be contiguous, and -- the processing may output intermediate entries such as decision - -- entries. Note that the limit of 100 here is arbitrary, but does - -- not cause any trouble, if we encounter more than 100 statements + -- entries. Note that the limit of 10_000 here is arbitrary, but does + -- not cause any trouble, if we encounter more than 10_000 statements -- we simply break the current CS sequence at that point, which is -- harmless, since this is only used for back annotation and it is - -- not critical that back annotation always work in all cases. + -- not critical that back annotation always work in all cases. Anyway + -- exceeding 10,000 statements in a basic block is very unlikely. procedure Extend_Statement_Sequence (N : Node_Id; Typ : Character); -- Extend the current statement sequence to encompass the node N. Typ @@ -941,15 +942,14 @@ package body Par_SCO is Set_Statement_Entry; Process_Decisions (Condition (N), 'E'); - -- Label, which breaks the current statement sequence, and then - -- we include the label in the subsequent statement sequence. + -- Label, which breaks the current statement sequence, but the + -- label itself is not included in the next statement sequence, + -- since it generates no code. when N_Label => Set_Statement_Entry; - Extend_Statement_Sequence (N, ' '); - -- Block statement, which breaks the current statement seqeunce - -- it probably does not need to, but for now it does. + -- Block statement, which breaks the current statement sequence when N_Block_Statement => Set_Statement_Entry; @@ -1043,8 +1043,20 @@ package body Par_SCO is when N_Loop_Statement => if Present (Iteration_Scheme (N)) then - Extend_Statement_Sequence (N, Iteration_Scheme (N), 'F'); - Process_Decisions (Condition (Iteration_Scheme (N)), 'W'); + declare + ISC : constant Node_Id := Iteration_Scheme (N); + + begin + Extend_Statement_Sequence (N, ISC, 'F'); + + if Present (Condition (ISC)) then + Process_Decisions + (Condition (ISC), 'W'); + else + Process_Decisions + (Loop_Parameter_Specification (ISC), 'X'); + end if; + end; end if; Set_Statement_Entry; diff --git a/gcc/ada/scos.ads b/gcc/ada/scos.ads index e9c1d159215..b8dd08d0350 100644 --- a/gcc/ada/scos.ads +++ b/gcc/ada/scos.ads @@ -127,7 +127,8 @@ package SCOs is -- body or block statement that has a non-empty declarative part -- the first statement after a compound statement -- the first statement after an EXIT, RAISE or GOTO statement - -- any statement with a label + -- any statement with a label (the label itself is not part of the + -- entry point that is recorded). -- Each entry point must appear as the first entry on a CS line. -- The idea is that if any simple statement on a CS line is known to have -- 2.30.2