summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-04-19 23:06:44 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-04-19 23:06:44 +0000
commit630e6e14229abf9bdecb2418709658fef472a4c5 (patch)
treea958d6332f10302efb09dbfd69ab6bb16813310e /llvm/lib
parentd26206b54735c4671ef87ca7a413d4d28c9f1cb7 (diff)
downloadbcm5719-llvm-630e6e14229abf9bdecb2418709658fef472a4c5.tar.gz
bcm5719-llvm-630e6e14229abf9bdecb2418709658fef472a4c5.zip
MergeFunc: Make pointer and integer types generate the same hash.
The logic that actually compares the types considers pointers and integers the same if they are of the same size. This created a strange mismatch between hash and reality and made the test case for this fail on some platforms (yay, test cases). llvm-svn: 179905
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/MergeFunctions.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
index 05f68dbcabf..4ce749cfec0 100644
--- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
@@ -72,6 +72,15 @@ STATISTIC(NumThunksWritten, "Number of thunks generated");
STATISTIC(NumAliasesWritten, "Number of aliases generated");
STATISTIC(NumDoubleWeak, "Number of new functions created");
+/// Returns the type id for a type to be hashed. We turn pointer types into
+/// integers here because the actual compare logic below considers pointers and
+/// integers of the same size as equal.
+static Type::TypeID getTypeIDForHash(Type *Ty) {
+ if (Ty->isPointerTy())
+ return Type::IntegerTyID;
+ return Ty->getTypeID();
+}
+
/// Creates a hash-code for the function which is the same for any two
/// functions that will compare equal, without looking at the instructions
/// inside the function.
@@ -83,9 +92,9 @@ static unsigned profileFunction(const Function *F) {
ID.AddInteger(F->getCallingConv());
ID.AddBoolean(F->hasGC());
ID.AddBoolean(FTy->isVarArg());
- ID.AddInteger(FTy->getReturnType()->getTypeID());
+ ID.AddInteger(getTypeIDForHash(FTy->getReturnType()));
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
- ID.AddInteger(FTy->getParamType(i)->getTypeID());
+ ID.AddInteger(getTypeIDForHash(FTy->getParamType(i)));
return ID.ComputeHash();
}
OpenPOWER on IntegriCloud