Teach mergefunc that intptr_t is the same width as a pointer. We still can't
authorNick Lewycky <nicholas@mxc.ca>
Wed, 26 Jan 2011 09:13:58 +0000 (09:13 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Wed, 26 Jan 2011 09:13:58 +0000 (09:13 +0000)
merge vector<intptr_t>::push_back() and vector<void*>::push_back() because
Enumerate() doesn't realize that "i64* null" and "i8** null" are equivalent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124285 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/MergeFunctions.cpp

index 8aa7cb24b959f6ca2cc3808dd66b2cece0d32fe8..49679baaeb78ace404c182f6a5e0eb7596f2368f 100644 (file)
@@ -286,8 +286,14 @@ bool FunctionComparator::isEquivalentType(const Type *Ty1,
                                           const Type *Ty2) const {
   if (Ty1 == Ty2)
     return true;
-  if (Ty1->getTypeID() != Ty2->getTypeID())
+  if (Ty1->getTypeID() != Ty2->getTypeID()) {
+    if (TD) {
+      LLVMContext &Ctx = Ty1->getContext();
+      if (isa<PointerType>(Ty1) && Ty2 == TD->getIntPtrType(Ctx)) return true;
+      if (isa<PointerType>(Ty2) && Ty1 == TD->getIntPtrType(Ctx)) return true;
+    }
     return false;
+  }
 
   switch(Ty1->getTypeID()) {
   default: