[llvm-bugs] [Bug 24643] New: FoldingSetNodeID::AddPointer is unnecessarily slow

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 31 13:49:38 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24643

            Bug ID: 24643
           Summary: FoldingSetNodeID::AddPointer is unnecessarily slow
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Support Libraries
          Assignee: unassignedbugs at nondot.org
          Reporter: ben.craig at codeaurora.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

FoldingSetNodeID houses the hash and equality material for FoldingSet's
intrusive hash map data structure.  The raw material is stored as a
SmallVector<unsigned, 32>.  The current implementation of AddPointer does a
ranged append, like so...

Bits.append(reinterpret_cast<unsigned *>(&Ptr),
            reinterpret_cast<unsigned *>(&Ptr+1));

This is done in order to support 32-bit and 64-bit pointers.  Unfortunately,
SmallVector::append with 1 element is slower than SmallVector::push_back with 1
element.  Append with 2 elements is also slower than two push_backs.

On MSVC, the append call eventually turns into a memmove + some bookkeeping. 
With push_back, it turns into a memcpy + some bookkeeping.

When using the Clang static analyzer, AddPointer ends up being one of the top
hits for exclusive / self time.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150831/88afd91d/attachment-0001.html>


More information about the llvm-bugs mailing list