[PATCH] D12535: [PR24643] Speeding up FoldingSetNodeID::AddPointer
Ben Craig via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 1 09:59:43 PDT 2015
bcraig created this revision.
bcraig added reviewers: chandlerc, krememek.
bcraig added a subscriber: llvm-commits.
The old code resulted in placement new calls on Linux64, and memmove
calls on Windows. The new code gets to use memcpy instead. This
change makes an analysis of a large .c file on Linux64 go from
6m57.730s to 6m44.317s.
This effectively reverts r135364.
The commit log for that change is...
Simplify & microoptimize code. No intended functionality change.
It doesn't include any rationale or metrics regarding the speedup.
http://reviews.llvm.org/D12535
Files:
lib/Support/FoldingSet.cpp
Index: lib/Support/FoldingSet.cpp
===================================================================
--- lib/Support/FoldingSet.cpp
+++ lib/Support/FoldingSet.cpp
@@ -54,9 +54,17 @@
// depend on the host. It doesn't matter, however, because hashing on
// pointer values is inherently unstable. Nothing should depend on the
// ordering of nodes in the folding set.
- Bits.append(reinterpret_cast<unsigned *>(&Ptr),
- reinterpret_cast<unsigned *>(&Ptr+1));
+ uintptr_t casted = reinterpret_cast<uintptr_t>(Ptr);
+ if (sizeof(uintptr_t) == sizeof(unsigned))
+ AddInteger(unsigned(casted));
+ else if (sizeof(uintptr_t) == sizeof(unsigned long))
+ AddInteger((unsigned long)casted);
+ else if (sizeof(uintptr_t) == sizeof(unsigned long long))
+ AddInteger((unsigned long long)casted);
+ else
+ llvm_unreachable("unexpected pointer size");
}
+
void FoldingSetNodeID::AddInteger(signed I) {
Bits.push_back(I);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12535.33706.patch
Type: text/x-patch
Size: 953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150901/ca8e3703/attachment.bin>
More information about the llvm-commits
mailing list