RFA: TREE_READONLY in LLVM-GCC

Hi LLVM-GCC hackers!

I have a global variable that I want to mark as "TREE_READONLY" so that it will become a "constant" in LLVM IR. This is for the new blocks-related stuff, but that's not necessarily important for this question. In particular, I want to mark the "block_holder" created in "build_block_literal_tmp()" as read-only.

My question to you is: Considering that LLVM-GCC uses only a small part of the GCC source base, what affect will marking the "block_holder" variable as TREE_READONLY have? Does LLVM-GCC run through code that looks at this flag and act differently before it generates the LLVM IR?

I know that this is a broad question and difficult to answer. I'm mostly looking for people's gut reactions to this proposal. My current plan is to "test it out and see if it works," but the testing might not be comprehensive enough to ferret out potential problems.

Thanks in advance!

-bw

Hi Bill,

I think this change is fine and should go into the normal apple GCC as well. Setting TREE_READONLY means that it can go into the "constant" section of the executable, go in ROM, etc. This is the same as the llvm constant bit on globals.

-Chris

Hi LLVM-GCC hackers!

I have a global variable that I want to mark as "TREE_READONLY" so
that it will become a "constant" in LLVM IR. This is for the new
blocks-related stuff, but that's not necessarily important for this
question. In particular, I want to mark the "block_holder" created in
"build_block_literal_tmp()" as read-only.

My question to you is: Considering that LLVM-GCC uses only a small
part of the GCC source base, what affect will marking the
"block_holder" variable as TREE_READONLY have? Does LLVM-GCC run
through code that looks at this flag and act differently before it
generates the LLVM IR?

Hi Bill,

I think this change is fine and should go into the normal apple GCC as
well.

I think Fariborz is resistant to this idea, but I can run it past him again.

Setting TREE_READONLY means that it can go into the "constant"
section of the executable, go in ROM, etc. This is the same as the
llvm constant bit on globals.

Okay. I'll make the patch. Thanks!

-bw

Hi Chris,

I think this change is fine and should go into the normal apple GCC as
well. Setting TREE_READONLY means that it can go into the "constant"
section of the executable, go in ROM, etc. This is the same as the
llvm constant bit on globals.

for this I think it has to be static as well as readonly.

Ciao,

Duncan.

I did mark it as TREE_CONSTANT. Is that enough?

-bw

No idea - if it works I guess it was enough :slight_smile: I was
actually thinking of TREE_STATIC:

/* In a VAR_DECL, nonzero means allocate static storage.
   In a FUNCTION_DECL, nonzero if function has been defined.
   In a CONSTRUCTOR, nonzero means allocate static storage.

   ??? This is also used in lots of other nodes in unclear ways which
   should be cleaned up some day. */
#define TREE_STATIC(NODE) ((NODE)->common.static_flag)

Ciao,

Duncan.

I went ahead and just kept it as "TREE_CONSTANT". :slight_smile:

-bw