aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/User.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore/User.cpp')
-rw-r--r--lib/VMCore/User.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/VMCore/User.cpp b/lib/VMCore/User.cpp
index 9601da7011..f01fa349ad 100644
--- a/lib/VMCore/User.cpp
+++ b/lib/VMCore/User.cpp
@@ -40,8 +40,10 @@ void User::replaceUsesOfWith(Value *From, Value *To) {
//===----------------------------------------------------------------------===//
Use *User::allocHungoffUses(unsigned N) const {
- Use *Begin = static_cast<Use*>(::operator new(sizeof(Use) * N
- + sizeof(Use::UserRef)));
+ // Allocate the array of Uses, followed by a pointer (with bottom bit set) to
+ // the User.
+ size_t size = N * sizeof(Use) + sizeof(Use::UserRef);
+ Use *Begin = static_cast<Use*>(::operator new(size));
Use *End = Begin + N;
(void) new(End) Use::UserRef(const_cast<User*>(this), 1);
return Use::initTags(Begin, End);