[llvm-commits] Fix for bug 14986

David Blaikie dblaikie at gmail.com
Wed Jan 23 08:32:43 PST 2013


My answer isn't very authoritative (I work mostly in clang) but this seems
like a test that accidentally treated the old buggy behavior. This isn't
uncommon (tests are often accidentally over constrained by someone copy
pasting the current output as the expected output. It's not uncommon to
have to fix up tests like this when fixing a bug)
On Jan 23, 2013 1:42 AM, "Sebastien DELDON-GNB" <sebastien.deldon at st.com>
wrote:

> Hi all,
>
> This is my first post on this mailing list, so hope I'm doing the right
> thing. If not sorry about it.
> Here is my proposed fix for bug 14986, filed by myself. One problem with
> this fix is that
> getelementptr.ll test reports an error. I think error reported by
> getelementptr.ll test might not be correct,
> here is error I've got:
>
> /work1/tools/llvm/trunk/sources/test/Transforms/InstCombine/getelementptr.ll:438:10:
> error: expected string not found in input
> ; CHECK: ret i8* getelementptr ([11 x i8]* @array, i64
> 1676976733973595601, i64 4)
>          ^
> <stdin>:253:19: note: scanning from here
> define i8* @test36() nounwind {
>                   ^
> <stdin>:254:2: note: possible intended match here
>  ret i8* getelementptr ([11 x i8]* @array, i64 -1, i64 10)
>  ^
> --
>
> Here is my proposed patch.
>
> Index: ConstantFolding.cpp
> ===================================================================
> --- ConstantFolding.cpp (revision 173137)
> +++ ConstantFolding.cpp (working copy)
> @@ -736,8 +736,13 @@
>        else {
>          // The element size is non-zero divide the offset by the element
>          // size (rounding down), to compute the index at this level.
> -        APInt NewIdx = Offset.udiv(ElemSize);
> +        APInt NewIdx = Offset.sdiv(ElemSize);
>          Offset -= NewIdx * ElemSize;
> +
> +        if (Offset.isNegative()) {
> +            NewIdx-- ;
> +            Offset += ElemSize ;
> +        }
>          NewIdxs.push_back(ConstantInt::get(IntPtrTy, NewIdx));
>        }
>        Ty = ATy->getElementType();
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130123/0d1b33a0/attachment.html>


More information about the llvm-commits mailing list