[llvm-commits] [PATCH] Try to figure out <size> argument in llvm.lifetime intrinsics
Nick Lewycky
nlewycky at gmail.com
Sun Nov 11 13:49:08 PST 2012
================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:678
@@ +677,3 @@
+ Type *AllocaType = AI->getAllocatedType();
+ SizeValue *= IFI.TD->getTypeAllocSize(AllocaType);
+ AllocaSize = ConstantInt::get(Type::getInt64Ty(AI->getContext()),
----------------
What about overflow here?
I don't know of any shared utility to multiply and detect overflow, but I've needed to do the exact same thing before. See umul_ov() at ScalarEvolution.cpp:1826.
================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:676
@@ +675,3 @@
+ if (IFI.TD != 0) {
+ uint64_t SizeValue = AllocaArraySize->getLimitedValue();
+ Type *AllocaType = AI->getAllocatedType();
----------------
What if the array size is an i128, and greater than fits in a uint64_t? getLimitedValue() will return -1 (~0ULL). Maybe you want to bail in that case?
http://llvm-reviews.chandlerc.com/D110
More information about the llvm-commits
mailing list