[llvm] r179905 - MergeFunc: Make pointer and integer types generate the same hash.

Bill Wendling wendling at apple.com
Fri Apr 19 16:18:13 PDT 2013


Yay! Thanks. :)

-bw

On Apr 19, 2013, at 4:06 PM, Benjamin Kramer <benny.kra at googlemail.com> wrote:

> Author: d0k
> Date: Fri Apr 19 18:06:44 2013
> New Revision: 179905
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=179905&view=rev
> Log:
> 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).
> 
> Modified:
>    llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
>    llvm/trunk/test/Transforms/MergeFunc/inttoptr.ll
> 
> Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=179905&r1=179904&r2=179905&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Fri Apr 19 18:06:44 2013
> @@ -72,6 +72,15 @@ STATISTIC(NumThunksWritten, "Number of t
> 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 Fu
>   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();
> }
> 
> 
> Modified: llvm/trunk/test/Transforms/MergeFunc/inttoptr.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MergeFunc/inttoptr.ll?rev=179905&r1=179904&r2=179905&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/MergeFunc/inttoptr.ll (original)
> +++ llvm/trunk/test/Transforms/MergeFunc/inttoptr.ll Fri Apr 19 18:06:44 2013
> @@ -1,4 +1,4 @@
> -; RUN: opt -mtriple i386-pc-linux-gnu -mergefunc -S < %s | FileCheck %s
> +; RUN: opt -mergefunc -S < %s | FileCheck %s
> ; PR15185
> target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
> target triple = "i386-pc-linux-gnu"
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list