[llvm-commits] [llvm] r157741 - in /llvm/trunk: docs/LangRef.html lib/VMCore/Verifier.cpp test/Verifier/range-1.ll test/Verifier/range-2.ll

Benjamin Kramer benny.kra at googlemail.com
Thu May 31 07:49:35 PDT 2012


On 31.05.2012, at 15:45, Rafael Espindola wrote:

> Author: rafael
> Date: Thu May 31 08:45:46 2012
> New Revision: 157741
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=157741&view=rev
> Log:
> Require intervals in the range metadata to be in a canonical form: They must
> be non contiguous, non overlapping and sorted by the lower end.
> 
> While this is technically a backward incompatibility, every frontent currently
> produces range metadata with a single interval and we don't have any pass
> that merges intervals yet, so no existing bitcode files should be rejected by
> this.
> 
> Modified:
>    llvm/trunk/docs/LangRef.html
>    llvm/trunk/lib/VMCore/Verifier.cpp
>    llvm/trunk/test/Verifier/range-1.ll
>    llvm/trunk/test/Verifier/range-2.ll
> 
> Modified: llvm/trunk/docs/LangRef.html
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=157741&r1=157740&r2=157741&view=diff
> ==============================================================================
> --- llvm/trunk/docs/LangRef.html (original)
> +++ llvm/trunk/docs/LangRef.html Thu May 31 08:45:46 2012
> @@ -3054,6 +3054,8 @@
>    <li>The range should not represent the full or empty set. That is,
>        <tt>a!=b</tt>. </li>
> </ul>
> +<p> In addiion, the pairs must be in signed order of the lower bound and
> +  they must be non contigous.</p>

Typos: addition, non-contiguous

- Ben
> 
> <p>Examples:</p>
> <div class="doc_code">
> @@ -3061,10 +3063,12 @@
>   %a = load i8* %x, align 1, !range !0 ; Can only be 0 or 1
>   %b = load i8* %y, align 1, !range !1 ; Can only be 255 (-1), 0 or 1
>   %c = load i8* %z, align 1, !range !2 ; Can only be 0, 1, 3, 4 or 5
> +  %d = load i8* %z, align 1, !range !3 ; Can only be -2, -1, 3, 4 or 5
> ...
> !0 = metadata !{ i8 0, i8 2 }
> !1 = metadata !{ i8 255, i8 2 }
> !2 = metadata !{ i8 0, i8 2, i8 3, i8 6 }
> +!3 = metadata !{ i8 -2, i8 0, i8 3, i8 6 }
> </pre>
> </div>
> </div>
> 
> Modified: llvm/trunk/lib/VMCore/Verifier.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=157741&r1=157740&r2=157741&view=diff
> ==============================================================================
> --- llvm/trunk/lib/VMCore/Verifier.cpp (original)
> +++ llvm/trunk/lib/VMCore/Verifier.cpp Thu May 31 08:45:46 2012
> @@ -1383,6 +1383,8 @@
>     Assert1(NumOperands % 2 == 0, "Unfinished range!", Range);
>     unsigned NumRanges = NumOperands / 2;
>     Assert1(NumRanges >= 1, "It should have at least one range!", Range);
> +
> +    APInt LastHigh;
>     for (unsigned i = 0; i < NumRanges; ++i) {
>       ConstantInt *Low = dyn_cast<ConstantInt>(Range->getOperand(2*i));
>       Assert1(Low, "The lower limit must be an integer!", Low);
> @@ -1391,8 +1393,20 @@
>       Assert1(High->getType() == Low->getType() &&
>               High->getType() == ElTy, "Range types must match load type!",
>               &LI);
> -      Assert1(High->getValue() != Low->getValue(), "Range must not be empty!",
> -              Range);
> +
> +      APInt HighV = High->getValue();
> +      APInt LowV = Low->getValue();
> +      Assert1(HighV != LowV, "Range must not be empty!", Range);
> +      if (i != 0) {
> +        Assert1(Low->getValue().sgt(LastHigh),
> +                "Intervals are overlapping, contiguous or not in order", Range);
> +        if (i == NumRanges - 1 && HighV.slt(LowV)) {
> +          APInt First = dyn_cast<ConstantInt>(Range->getOperand(0))->getValue();
> +          Assert1(First.sgt(HighV),
> +                  "First and last intervals are contiguous or overlap", Range);
> +        }
> +      }
> +      LastHigh = High->getValue();
>     }
>   }
> 
> 
> Modified: llvm/trunk/test/Verifier/range-1.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/range-1.ll?rev=157741&r1=157740&r2=157741&view=diff
> ==============================================================================
> --- llvm/trunk/test/Verifier/range-1.ll (original)
> +++ llvm/trunk/test/Verifier/range-1.ll Thu May 31 08:45:46 2012
> @@ -76,3 +76,43 @@
> }
> !8 = metadata !{i8 0, i8 0}
> ; CHECK: Range must not be empty!
> +
> +define i8 @f10(i8* %x) {
> +entry:
> +  %y = load i8* %x, align 1, !range !9
> +  ret i8 %y
> +}
> +!9 = metadata !{i8 0, i8 2, i8 1, i8 3}
> +; CHECK: Intervals are overlapping, contiguous or not in order
> +
> +define i8 @f11(i8* %x) {
> +entry:
> +  %y = load i8* %x, align 1, !range !10
> +  ret i8 %y
> +}
> +!10 = metadata !{i8 0, i8 2, i8 2, i8 3}
> +; CHECK: Intervals are overlapping, contiguous or not in order
> +
> +define i8 @f12(i8* %x) {
> +entry:
> +  %y = load i8* %x, align 1, !range !11
> +  ret i8 %y
> +}
> +!11 = metadata !{i8 1, i8 2, i8 -1, i8 0}
> +; CHECK: Intervals are overlapping, contiguous or not in order
> +
> +define i8 @f13(i8* %x) {
> +entry:
> +  %y = load i8* %x, align 1, !range !12
> +  ret i8 %y
> +}
> +!12 = metadata !{i8 1, i8 3, i8 5, i8 1}
> +; CHECK: First and last intervals are contiguous or overlap
> +
> +define i8 @f14(i8* %x) {
> +entry:
> +  %y = load i8* %x, align 1, !range !13
> +  ret i8 %y
> +}
> +!13 = metadata !{i8 1, i8 3, i8 5, i8 2}
> +; CHECK: First and last intervals are contiguous or overlap
> 
> Modified: llvm/trunk/test/Verifier/range-2.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/range-2.ll?rev=157741&r1=157740&r2=157741&view=diff
> ==============================================================================
> --- llvm/trunk/test/Verifier/range-2.ll (original)
> +++ llvm/trunk/test/Verifier/range-2.ll Thu May 31 08:45:46 2012
> @@ -20,3 +20,17 @@
>   ret i8 %y
> }
> !2 = metadata !{i8 1, i8 3, i8 5, i8 42}
> +
> +define i8 @f4(i8* %x) {
> +entry:
> +  %y = load i8* %x, align 1, !range !3
> +  ret i8 %y
> +}
> +!3 = metadata !{i8 -1, i8 0, i8 1, i8 2}
> +
> +define i8 @f5(i8* %x) {
> +entry:
> +  %y = load i8* %x, align 1, !range !4
> +  ret i8 %y
> +}
> +!4 = metadata !{i8 -1, i8 0, i8 1, i8 -2}
> 
> 
> _______________________________________________
> 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