stephen <chency666@xxxxxxxxx> writes: > we want to set a scope id for each statement, for example, > > void main() > { > int i=1; Â Â Â Â -------------------> Âscope = 1; > if (i>1) > { > Âi=2; Â Â Â Â Â Â--------------------> scope =2; because it is inside a brace; > Âif(i == 2) > Â{ > Â i=i+1; Â Â Â Â --------------------> scope =3; because it is inside two brace; > Â i=3; Â Â Â Â Â --------------------> scope =3; because it is inside two brace; > Â} > Âi=i-1; Â Â Â Â Â--------------------> scope =2; because it is inside a brace; > } > i=i+1; Â Â Â Â Â --------------------> scope =1; > } > > And we want to add this scope information in the assembler code, like > this. (As soon as it reaches a "{", the scope will add "1" and the > scope will remove "1" when it reaches a "}" ) gcc doesn't work that way. It renames the local variables, throws away the scopes, and rearranges statements across scopes. > But I also found basic block struct has a variable "loop_depth", can I use it? loop_depth refers to the number of nested loops, not nested scopes. There can be loops without scopes (e.g., using goto statements) and scopes without loops (e.g., the above code). Ian