[PATCH] D26581: Make WholeProgramDevirt understand ConstStruct vtables.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 21:20:38 PST 2016


Hi, do you expect that you'll be able to make my suggested changes any time
soon? I can take the patch over if you'd like; I think I'll need something
like it to support one of my upcoming Clang changes.

Peter

On Nov 28, 2016 2:33 PM, "Peter Collingbourne via Phabricator" <
reviews at reviews.llvm.org> wrote:

> pcc added inline comments.
>
>
> ================
> Comment at: lib/Transforms/IPO/WholeProgramDevirt.cpp:386
>
> +Optional<unsigned>
> +DevirtModule::getOpAtOffset(const Constant *I, const uint64_t Offset) {
> ----------------
> Could be simpler to return a `const Constant *` from this function.
>
>
> ================
> Comment at: lib/Transforms/IPO/WholeProgramDevirt.cpp:428-429
>
> -    auto Init = dyn_cast<ConstantArray>(TM.Bits->GV->getInitializer());
> -    if (!Init)
> -      return false;
> -    ArrayType *VTableTy = Init->getType();
> -
> -    uint64_t ElemSize =
> -        M.getDataLayout().getTypeAllocSize(VTableTy->getElementType());
> -    uint64_t GlobalSlotOffset = TM.Offset + ByteOffset;
> -    if (GlobalSlotOffset % ElemSize != 0)
> -      return false;
> +    const Constant *I = TM.Bits->GV->getInitializer();
> +    const uint64_t GlobalSlotOffset = TM.Offset + ByteOffset;
> +    Optional<unsigned> Op = getOpAtOffset(I, GlobalSlotOffset);
> ----------------
> These two could be folded into the only use (after applying my suggestion
> above).
>
>
> ================
> Comment at: test/Transforms/WholeProgramDevirt/non-array-vtable.ll:1
>  ; RUN: opt -S -wholeprogramdevirt %s | FileCheck %s
>
> ----------------
> struct-vtable.ll would be a better name for this test.
>
>
> https://reviews.llvm.org/D26581
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161207/f3b0f848/attachment.html>


More information about the llvm-commits mailing list