[PATCH] D26581: Make WholeProgramDevirt understand ConstStruct vtables.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 28 14:33:42 PST 2016
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
More information about the llvm-commits
mailing list