[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Analyzer.cpp Reader.cpp

Reid Spencer rspencer at reidspencer.com
Thu Apr 12 11:54:47 PDT 2007


Hi Lauro,

On Thu, 2007-04-12 at 13:33 -0500, Lauro Ramos Venancio wrote:
> 
> Changes in directory llvm/lib/Bytecode/Reader:
> 
> Analyzer.cpp updated: 1.39 -> 1.40
> Reader.cpp updated: 1.247 -> 1.248
> ---
> Log message:
> 
> Implement the "thread_local" keyword.

Meta comment: I didn't see a commit to the BytecodeFormat.html document
but you have changed the bytecode format. Please update the document.
In general, I would prefer that you update the BytecodeFormat.html
document before making these kinds of changes. This way everyone gets to
review the proposed changes ahead of time and can make comments. The
bytecode stuff is notoriously sensitive to bugs.

Reid.

> 
> 
> ---
> Diffs of the changes:  (+8 -5)
> 
>  Analyzer.cpp |    4 +++-
>  Reader.cpp   |    9 +++++----
>  2 files changed, 8 insertions(+), 5 deletions(-)
> 
> 
> Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
> diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.39 llvm/lib/Bytecode/Reader/Analyzer.cpp:1.40
> --- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.39	Wed Feb 14 21:39:18 2007
> +++ llvm/lib/Bytecode/Reader/Analyzer.cpp	Thu Apr 12 13:32:50 2007
> @@ -154,12 +154,14 @@
>      GlobalValue::LinkageTypes Linkage,
>      GlobalValue::VisibilityTypes Visibility,
>      unsigned SlotNum,
> -    unsigned initSlot
> +    unsigned initSlot,
> +    bool isThreadLocal
>    ) {
>      if (os) {
>        *os << "      GV: "
>            << ( initSlot == 0 ? "Uni" : "I" ) << "nitialized, "
>            << ( isConstant? "Constant, " : "Variable, ")
> +          << " Thread Local = " << ( isThreadLocal? "yes, " : "no, ")
>            << " Linkage=" << Linkage
>            << " Visibility="<< Visibility
>            << " Type=";
> 
> 
> Index: llvm/lib/Bytecode/Reader/Reader.cpp
> diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.247 llvm/lib/Bytecode/Reader/Reader.cpp:1.248
> --- llvm/lib/Bytecode/Reader/Reader.cpp:1.247	Mon Apr  9 15:28:40 2007
> +++ llvm/lib/Bytecode/Reader/Reader.cpp	Thu Apr 12 13:32:50 2007
> @@ -1704,11 +1704,12 @@
>    unsigned VarType = read_vbr_uint();
>    while (VarType != Type::VoidTyID) { // List is terminated by Void
>      // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3,4 =
> -    // Linkage, bit4+ = slot#
> -    unsigned SlotNo = VarType >> 5;
> +    // Linkage, bit5 = isThreadLocal, bit6+ = slot#
> +    unsigned SlotNo = VarType >> 6;

This cuts in half the number of global variables that can handled. We're
now down to 26 bits. I suppose that's okay but perhaps its time to use
the "highest value means actual value follows in next word" trick.  I.e.
this should check to see if SlotNo is 2^26-1 and if it is it should read
a uint64_t to get the actual slot number. The writer obviously needs to
be changed too.

>      unsigned LinkageID = (VarType >> 2) & 7;
>      unsigned VisibilityID = 0;
>      bool isConstant = VarType & 1;
> +    bool isThreadLocal = (VarType >> 5) & 1;
>      bool hasInitializer = (VarType & 2) != 0;
>      unsigned Alignment = 0;
>      unsigned GlobalSectionID = 0;
> @@ -1764,7 +1765,7 @@
>  
>      // Create the global variable...
>      GlobalVariable *GV = new GlobalVariable(ElTy, isConstant, Linkage,
> -                                            0, "", TheModule);
> +                                            0, "", TheModule, isThreadLocal);
>      GV->setAlignment(Alignment);
>      GV->setVisibility(Visibility);
>      insertValue(GV, SlotNo, ModuleValues);
> @@ -1781,7 +1782,7 @@
>      // Notify handler about the global value.
>      if (Handler)
>        Handler->handleGlobalVariable(ElTy, isConstant, Linkage, Visibility,
> -                                    SlotNo, initSlot);
> +                                    SlotNo, initSlot, isThreadLocal);
>  
>      // Get next item
>      VarType = read_vbr_uint();
> 
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list