diff options
Diffstat (limited to 'llvm/lib/IR/User.cpp')
-rw-r--r-- | llvm/lib/IR/User.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/llvm/lib/IR/User.cpp b/llvm/lib/IR/User.cpp index 4a3eba9e8cf79..7da592f401273 100644 --- a/llvm/lib/IR/User.cpp +++ b/llvm/lib/IR/User.cpp @@ -9,6 +9,7 @@ #include "llvm/IR/User.h" #include "llvm/IR/Constant.h" #include "llvm/IR/GlobalValue.h" +#include "llvm/IR/IntrinsicInst.h" namespace llvm { class BasicBlock; @@ -39,20 +40,18 @@ void User::replaceUsesOfWith(Value *From, Value *To) { void User::allocHungoffUses(unsigned N, bool IsPhi) { assert(HasHungOffUses && "alloc must have hung off uses"); - static_assert(alignof(Use) >= alignof(Use::UserRef), - "Alignment is insufficient for 'hung-off-uses' pieces"); - static_assert(alignof(Use::UserRef) >= alignof(BasicBlock *), + static_assert(alignof(Use) >= alignof(BasicBlock *), "Alignment is insufficient for 'hung-off-uses' pieces"); - // 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); + // Allocate the array of Uses + size_t size = N * sizeof(Use); if (IsPhi) size += N * sizeof(BasicBlock *); Use *Begin = static_cast<Use*>(::operator new(size)); Use *End = Begin + N; - (void) new(End) Use::UserRef(const_cast<User*>(this), 1); - setOperandList(Use::initTags(Begin, End)); + setOperandList(Begin); + for (; Begin != End; Begin++) + new (Begin) Use(this); } void User::growHungoffUses(unsigned NewNumUses, bool IsPhi) { @@ -73,10 +72,8 @@ void User::growHungoffUses(unsigned NewNumUses, bool IsPhi) { // If this is a Phi, then we need to copy the BB pointers too. if (IsPhi) { - auto *OldPtr = - reinterpret_cast<char *>(OldOps + OldNumUses) + sizeof(Use::UserRef); - auto *NewPtr = - reinterpret_cast<char *>(NewOps + NewNumUses) + sizeof(Use::UserRef); + auto *OldPtr = reinterpret_cast<char *>(OldOps + OldNumUses); + auto *NewPtr = reinterpret_cast<char *>(NewOps + NewNumUses); std::copy(OldPtr, OldPtr + (OldNumUses * sizeof(BasicBlock *)), NewPtr); } Use::zap(OldOps, OldOps + OldNumUses, true); @@ -105,6 +102,12 @@ MutableArrayRef<uint8_t> User::getDescriptor() { reinterpret_cast<uint8_t *>(DI) - DI->SizeInBytes, DI->SizeInBytes); } +bool User::isDroppable() const { + if (const auto *Intr = dyn_cast<IntrinsicInst>(this)) + return Intr->getIntrinsicID() == Intrinsic::assume; + return false; +} + //===----------------------------------------------------------------------===// // User operator new Implementations //===----------------------------------------------------------------------===// @@ -128,7 +131,8 @@ void *User::allocateFixedOperandUser(size_t Size, unsigned Us, Obj->NumUserOperands = Us; Obj->HasHungOffUses = false; Obj->HasDescriptor = DescBytes != 0; - Use::initTags(Start, End); + for (; Start != End; Start++) + new (Start) Use(Obj); if (DescBytes != 0) { auto *DescInfo = reinterpret_cast<DescriptorInfo *>(Storage + DescBytes); @@ -191,4 +195,4 @@ LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE void User::operator delete(void *Usr) { } } -} // End llvm namespace +} // namespace llvm |