[PATCH] D30016: WholeProgramDevirt: For VCP use a 32-bit ConstantInt for the byte offset.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 17 10:53:03 PST 2017


pcc added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:934
     // Rewrite each call to a load from OffsetByte/OffsetBit.
-    Constant *ByteConst = ConstantInt::get(Int64Ty, OffsetByte);
+    Constant *ByteConst = ConstantInt::get(Int32Ty, OffsetByte);
     Constant *BitConst = ConstantInt::get(Int8Ty, 1ULL << OffsetBit);
----------------
tejohnson wrote:
> What happens if OffsetByte is bigger than 2^32? Is that possible?
Not without exceeding limits that are already in place. You would either need a vtable larger than 2^31 bytes (i.e. a vtable containing more than 2^29 (32-bit) or 2^28 (64-bit) virtual functions, which not only far exceeds the recommended minimum limits of the C++ standard, but by itself exceeds the limits of the small memory model) or enough VCP eligible virtual calls to cause the size of the vtable's constant region to extend beyond 2^31 (that would require at least 2^28 such vcalls, and most likely the instructions making up those vcalls would by themselves push the size beyond the small memory model limit).

And of course, neither scenario is very realistic.


https://reviews.llvm.org/D30016





More information about the llvm-commits mailing list