| Index: src/IceGlobalContext.cpp
|
| diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
|
| index d77a5ddb554c4e1f3ec68232da712a6cc72152d3..7bb0f71e03848333e071403e42c3fbe73cc57d1d 100644
|
| --- a/src/IceGlobalContext.cpp
|
| +++ b/src/IceGlobalContext.cpp
|
| @@ -74,6 +74,29 @@ private:
|
| uint32_t NextPoolID;
|
| };
|
|
|
| +// UndefPool maps ICE types to the corresponding ConstantUndef values.
|
| +class UndefPool {
|
| + UndefPool(const UndefPool &) LLVM_DELETED_FUNCTION;
|
| + UndefPool &operator=(const UndefPool &) LLVM_DELETED_FUNCTION;
|
| +
|
| +public:
|
| + UndefPool() : NextPoolID(0) {}
|
| +
|
| + ConstantUndef *getOrAdd(GlobalContext *Ctx, Type Ty) {
|
| + ContainerType::iterator I = Pool.find(Ty);
|
| + if (I != Pool.end())
|
| + return I->second;
|
| + ConstantUndef *Undef = ConstantUndef::create(Ctx, Ty, NextPoolID++);
|
| + Pool[Ty] = Undef;
|
| + return Undef;
|
| + }
|
| +
|
| +private:
|
| + uint32_t NextPoolID;
|
| + typedef std::map<Type, ConstantUndef *> ContainerType;
|
| + ContainerType Pool;
|
| +};
|
| +
|
| // The global constant pool bundles individual pools of each type of
|
| // interest.
|
| class ConstantPool {
|
| @@ -86,6 +109,7 @@ public:
|
| TypePool<double, ConstantDouble, true> Doubles;
|
| TypePool<uint64_t, ConstantInteger> Integers;
|
| TypePool<RelocatableTuple, ConstantRelocatable> Relocatables;
|
| + UndefPool Undefs;
|
| };
|
|
|
| GlobalContext::GlobalContext(llvm::raw_ostream *OsDump,
|
| @@ -191,6 +215,10 @@ Constant *GlobalContext::getConstantSym(Type Ty, int64_t Offset,
|
| this, Ty, RelocatableTuple(Offset, Name, SuppressMangling));
|
| }
|
|
|
| +Constant *GlobalContext::getConstantUndef(Type Ty) {
|
| + return ConstPool->Undefs.getOrAdd(this, Ty);
|
| +}
|
| +
|
| ConstantList GlobalContext::getConstantPool(Type Ty) const {
|
| switch (Ty) {
|
| case IceType_i1:
|
|
|