[PATCH] Fixes -fsanitize=undefined warning about left-shifting a negative signed value.

Eric Christopher echristo at gmail.com
Thu Jan 8 13:55:24 PST 2015


Hi Artem,

Thanks for the patch.

Couple of things:

a) It's usually good to specify when you send the patch out exactly what
the problem is and how this fixes it. It solves a lot of back and forth
during review.
b) It's nice to attach the patch file (yes, this is different than a lot of
projects) or use Phabricator for reviews. (Phabricator documentation is at
llvm.org/docs/Phabricator).

Thanks!

-eric

On Thu Jan 08 2015 at 1:46:20 PM Artem Belevich <tra at google.com> wrote:

> Ping!
>
> BTW, the issue the patch fixes is a ubsan warning in the following test
> case:
>
> test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s
> /tmp/foo.o
> third_party/llvm/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h:186:47:
> runtime error: left shift of negative value -57344
>
> --Artem
>
> On Tue, Dec 23, 2014 at 1:02 PM, Artem Belevich <tra at google.com> wrote:
> >
> > ---
> >  lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h | 5
> +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git
> a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
> b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
> > index 274c552..8fc58ee 100644
> > --- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
> > +++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
> > @@ -183,8 +183,9 @@ public:
> >        assert(isInt<33>(Addend) && "Invalid page reloc value.");
> >
> >        // Encode the addend into the instruction.
> > -      uint32_t ImmLoValue = (uint32_t)(Addend << 17) & 0x60000000;
> > -      uint32_t ImmHiValue = (uint32_t)(Addend >> 9) & 0x00FFFFE0;
> > +      uint64_t AddressBits = Addend & 0x1FFFFF000;
> > +      uint32_t ImmLoValue = (uint32_t)(AddressBits << 17) & 0x60000000;
> > +      uint32_t ImmHiValue = (uint32_t)(AddressBits >> 9) & 0x00FFFFE0;
> >        *p = (*p & 0x9F00001F) | ImmHiValue | ImmLoValue;
> >        break;
> >      }
> > --
> > 2.2.0.rc0.207.ga3a616c
> >
>
>
>
> --
> --Artem Belevich
>  _______________________________________________
> 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/20150108/48bfe9c5/attachment.html>


More information about the llvm-commits mailing list