[cfe-dev] [cfe-commits] r67438 - in /cfe/trunk/lib/CodeGen: CGExpr.cpp CodeGenModule.cpp CodeGenModule.h

Daniel Dunbar daniel at zuster.org
Sat Mar 21 18:05:36 PDT 2009


On Sat, Mar 21, 2009 at 4:51 PM, Chris Lattner <sabre at nondot.org> wrote:

>
> On Mar 21, 2009, at 3:35 PM, Daniel Dunbar wrote:
>
>  On 3/21/09, Chris Lattner <sabre at nondot.org> wrote:
>>
>>> Author: lattner
>>> Date: Sat Mar 21 02:48:31 2009
>>> New Revision: 67438
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=67438&view=rev
>>> Log:
>>> simplify and comment some code better.  Make BindRuntimeGlobals
>>> more optimistic that it will work (optimizing for the common case).
>>>
>>
>> I may be missing something, but wouldn't this be cleaner if we just
>> provided a Module method to return a reference to the entry for a
>> name? This would avoiding the shuffling with names and only do one
>> lookup.
>>
>
> We already have this through ValueSymbolTable.  I added this comment,
> though I don't really know if it is true:


I guess I wasn't clear... I was referring to this code:
--
    // See if there is a conflict against a function by setting the name and
    // seeing if we got the desired name.
    GV->setName(Name);
    if (GV->isName(Name.c_str()))
      continue;  // Yep, it worked!

    GV->setName(""); // Zap the bogus name until we work out the conflict.
    llvm::GlobalValue *Conflict = TheModule.getNamedValue(Name);
    assert(Conflict && "Must have conflicted!");
--,
and meant, why not use the common trick of only looking up the cell entry
once. Of course this is complicated because the symbol table and the names
are tied together. Something along the lines of:
--
  iterator Entry = TheModule.getValueSymbolTable().lookup(Name);
  if (Entry == TheModule.getValueSymbolTable().end()) {
    // There is no conflict.
    GV->setName(Name, Entry);
    continue;
  }

  // There is a conflict with *Entry.
--
Of course, now that I've typed it out I realize the API overhead to allow
this probably isn't worth it.

I would also like to eliminate RuntimeGlobals at some point.


Ok! Although I'm curious how...

 - Daniel


>
> -Chris
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090321/85aebe6c/attachment.html>


More information about the cfe-dev mailing list