[llvm] r261071 - Fix the hash function.

David Jones via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 17 18:39:36 PST 2016


This change appears to trigger -Werror=parentheses. I've attached two
patches: one with the semantically equivalent change (binding the +
more tightly than |), and another with what I believe is (probably?)
the intended behavior (binding | tighter than +, which matches the
original behavior of +=). Both pass check-llvm.



On Tue, Feb 16, 2016 at 11:00 PM, David Blaikie via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: dblaikie
> Date: Wed Feb 17 01:00:22 2016
> New Revision: 261071
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261071&view=rev
> Log:
> Fix the hash function.
>
> Modified:
>     llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
>
> Modified: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp?rev=261071&r1=261070&r2=261071&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp (original)
> +++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp Wed Feb 17 01:00:22 2016
> @@ -203,7 +203,7 @@ static void writeIndex(MCStreamer &Out,
>      while (Buckets[H]) {
>        assert(S != IndexEntries[Buckets[H] - 1].Signature &&
>               "Duplicate type unit");
> -      H += ((S >> 32) & Mask) | 1;
> +      H = (H + ((S >> 32) & Mask) | 1) % Buckets.size();
>      }
>      Buckets[H] = i + 1;
>    }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
-------------- next part --------------
diff --git a/tools/llvm-dwp/llvm-dwp.cpp b/tools/llvm-dwp/llvm-dwp.cpp
index 02fcc15..9bc3276 100644
--- a/tools/llvm-dwp/llvm-dwp.cpp
+++ b/tools/llvm-dwp/llvm-dwp.cpp
@@ -238,7 +238,7 @@ static void writeIndex(MCStreamer &Out, MCSection *Section,
     while (Buckets[H]) {
       assert(S != IndexEntries[Buckets[H] - 1].Signature &&
              "Duplicate type unit");
-      H = (H + ((S >> 32) & Mask) | 1) % Buckets.size();
+      H = (H + (((S >> 32) & Mask) | 1)) % Buckets.size();
     }
     Buckets[H] = i + 1;
   }
-------------- next part --------------
diff --git a/tools/llvm-dwp/llvm-dwp.cpp b/tools/llvm-dwp/llvm-dwp.cpp
index 02fcc15..93d00e3 100644
--- a/tools/llvm-dwp/llvm-dwp.cpp
+++ b/tools/llvm-dwp/llvm-dwp.cpp
@@ -238,7 +238,7 @@ static void writeIndex(MCStreamer &Out, MCSection *Section,
     while (Buckets[H]) {
       assert(S != IndexEntries[Buckets[H] - 1].Signature &&
              "Duplicate type unit");
-      H = (H + ((S >> 32) & Mask) | 1) % Buckets.size();
+      H = ((H + ((S >> 32) & Mask)) | 1) % Buckets.size();
     }
     Buckets[H] = i + 1;
   }


More information about the llvm-commits mailing list