Update clang to r339409b.
Change-Id: Ied8a188bb072c40035320acedc86164b66d920af
diff --git a/linux-x64/clang/include/llvm/Analysis/MemorySSA.h b/linux-x64/clang/include/llvm/Analysis/MemorySSA.h
index d445e44..6200837 100644
--- a/linux-x64/clang/include/llvm/Analysis/MemorySSA.h
+++ b/linux-x64/clang/include/llvm/Analysis/MemorySSA.h
@@ -280,9 +280,10 @@
friend class MemorySSAUpdater;
MemoryUseOrDef(LLVMContext &C, MemoryAccess *DMA, unsigned Vty,
- DeleteValueTy DeleteValue, Instruction *MI, BasicBlock *BB)
- : MemoryAccess(C, Vty, DeleteValue, BB, 1), MemoryInstruction(MI),
- OptimizedAccessAlias(MayAlias) {
+ DeleteValueTy DeleteValue, Instruction *MI, BasicBlock *BB,
+ unsigned NumOperands)
+ : MemoryAccess(C, Vty, DeleteValue, BB, NumOperands),
+ MemoryInstruction(MI), OptimizedAccessAlias(MayAlias) {
setDefiningAccess(DMA);
}
@@ -308,11 +309,6 @@
Optional<AliasResult> OptimizedAccessAlias;
};
-template <>
-struct OperandTraits<MemoryUseOrDef>
- : public FixedNumOperandTraits<MemoryUseOrDef, 1> {};
-DEFINE_TRANSPARENT_OPERAND_ACCESSORS(MemoryUseOrDef, MemoryAccess)
-
/// Represents read-only accesses to memory
///
/// In particular, the set of Instructions that will be represented by
@@ -323,7 +319,8 @@
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(MemoryAccess);
MemoryUse(LLVMContext &C, MemoryAccess *DMA, Instruction *MI, BasicBlock *BB)
- : MemoryUseOrDef(C, DMA, MemoryUseVal, deleteMe, MI, BB) {}
+ : MemoryUseOrDef(C, DMA, MemoryUseVal, deleteMe, MI, BB,
+ /*NumOperands=*/1) {}
// allocate space for exactly one operand
void *operator new(size_t s) { return User::operator new(s, 1); }
@@ -381,27 +378,28 @@
MemoryDef(LLVMContext &C, MemoryAccess *DMA, Instruction *MI, BasicBlock *BB,
unsigned Ver)
- : MemoryUseOrDef(C, DMA, MemoryDefVal, deleteMe, MI, BB), ID(Ver) {}
+ : MemoryUseOrDef(C, DMA, MemoryDefVal, deleteMe, MI, BB,
+ /*NumOperands=*/2),
+ ID(Ver) {}
- // allocate space for exactly one operand
- void *operator new(size_t s) { return User::operator new(s, 1); }
+ // allocate space for exactly two operands
+ void *operator new(size_t s) { return User::operator new(s, 2); }
static bool classof(const Value *MA) {
return MA->getValueID() == MemoryDefVal;
}
void setOptimized(MemoryAccess *MA) {
- Optimized = MA;
- OptimizedID = getDefiningAccess()->getID();
+ setOperand(1, MA);
+ OptimizedID = MA->getID();
}
MemoryAccess *getOptimized() const {
- return cast_or_null<MemoryAccess>(Optimized);
+ return cast_or_null<MemoryAccess>(getOperand(1));
}
bool isOptimized() const {
- return getOptimized() && getDefiningAccess() &&
- OptimizedID == getDefiningAccess()->getID();
+ return getOptimized() && OptimizedID == getOptimized()->getID();
}
void resetOptimized() {
@@ -417,13 +415,34 @@
const unsigned ID;
unsigned OptimizedID = INVALID_MEMORYACCESS_ID;
- WeakVH Optimized;
};
template <>
-struct OperandTraits<MemoryDef> : public FixedNumOperandTraits<MemoryDef, 1> {};
+struct OperandTraits<MemoryDef> : public FixedNumOperandTraits<MemoryDef, 2> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(MemoryDef, MemoryAccess)
+template <>
+struct OperandTraits<MemoryUseOrDef> {
+ static Use *op_begin(MemoryUseOrDef *MUD) {
+ if (auto *MU = dyn_cast<MemoryUse>(MUD))
+ return OperandTraits<MemoryUse>::op_begin(MU);
+ return OperandTraits<MemoryDef>::op_begin(cast<MemoryDef>(MUD));
+ }
+
+ static Use *op_end(MemoryUseOrDef *MUD) {
+ if (auto *MU = dyn_cast<MemoryUse>(MUD))
+ return OperandTraits<MemoryUse>::op_end(MU);
+ return OperandTraits<MemoryDef>::op_end(cast<MemoryDef>(MUD));
+ }
+
+ static unsigned operands(const MemoryUseOrDef *MUD) {
+ if (const auto *MU = dyn_cast<MemoryUse>(MUD))
+ return OperandTraits<MemoryUse>::operands(MU);
+ return OperandTraits<MemoryDef>::operands(cast<MemoryDef>(MUD));
+ }
+};
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(MemoryUseOrDef, MemoryAccess)
+
/// Represents phi nodes for memory accesses.
///
/// These have the same semantic as regular phi nodes, with the exception that
@@ -689,8 +708,13 @@
/// access associated with it. If passed a basic block gets the memory phi
/// node that exists for that block, if there is one. Otherwise, this will get
/// a MemoryUseOrDef.
- MemoryUseOrDef *getMemoryAccess(const Instruction *) const;
- MemoryPhi *getMemoryAccess(const BasicBlock *BB) const;
+ MemoryUseOrDef *getMemoryAccess(const Instruction *I) const {
+ return cast_or_null<MemoryUseOrDef>(ValueToMemoryAccess.lookup(I));
+ }
+
+ MemoryPhi *getMemoryAccess(const BasicBlock *BB) const {
+ return cast_or_null<MemoryPhi>(ValueToMemoryAccess.lookup(cast<Value>(BB)));
+ }
void dump() const;
void print(raw_ostream &) const;
@@ -750,6 +774,9 @@
/// all uses, uses appear in the right places). This is used by unit tests.
void verifyMemorySSA() const;
+ /// Check clobber sanity for an access.
+ void checkClobberSanityAccess(const MemoryAccess *MA) const;
+
/// Used in various insertion functions to specify whether we are talking
/// about the beginning or end of a block.
enum InsertionPlace { Beginning, End };
@@ -764,6 +791,7 @@
void verifyDomination(Function &F) const;
void verifyOrdering(Function &F) const;
void verifyDominationNumbers(const Function &F) const;
+ void verifyClobberSanity(const Function &F) const;
// This is used by the use optimizer and updater.
AccessList *getWritableBlockAccesses(const BasicBlock *BB) const {
@@ -796,7 +824,8 @@
InsertionPlace);
void insertIntoListsBefore(MemoryAccess *, const BasicBlock *,
AccessList::iterator);
- MemoryUseOrDef *createDefinedAccess(Instruction *, MemoryAccess *);
+ MemoryUseOrDef *createDefinedAccess(Instruction *, MemoryAccess *,
+ const MemoryUseOrDef *Template = nullptr);
private:
class CachingWalker;
@@ -806,6 +835,7 @@
void buildMemorySSA();
void optimizeUses();
+ void prepareForMoveTo(MemoryAccess *, BasicBlock *);
void verifyUseInDefs(MemoryAccess *, MemoryAccess *) const;
using AccessMap = DenseMap<const BasicBlock *, std::unique_ptr<AccessList>>;
@@ -816,7 +846,8 @@
void markUnreachableAsLiveOnEntry(BasicBlock *BB);
bool dominatesUse(const MemoryAccess *, const MemoryAccess *) const;
MemoryPhi *createMemoryPhi(BasicBlock *BB);
- MemoryUseOrDef *createNewAccess(Instruction *);
+ MemoryUseOrDef *createNewAccess(Instruction *,
+ const MemoryUseOrDef *Template = nullptr);
MemoryAccess *findDominatingDef(BasicBlock *, enum InsertionPlace);
void placePHINodes(const SmallPtrSetImpl<BasicBlock *> &);
MemoryAccess *renameBlock(BasicBlock *, MemoryAccess *, bool);