[llvm-commits] [PATCH] Patch to fix bug14172

Duncan Sands baldrick at free.fr
Tue Nov 6 00:56:57 PST 2012


Hi Micah, please send the patch to the mailing list too.  I see several problems
with it:
(1) it doesn't make any sense.

> Constant *ConstantExpr::getSizeOf(Type* Ty, unsigned AS) {
>   // sizeof is implemented as: (i64) gep (Ty addrspace(AS)*)null, 1
>   // Note that a non-inbounds gep is used, as null isn't within any object.
>   Constant *GEPIdx = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
>   Constant *GEP = getGetElementPtr(
>                  Constant::getNullValue(PointerType::get(Ty, AS)), GEPIdx);

^ Adding an address space here should make no difference to the computed size,
which isn't anything to do with the size of a pointer to Ty, it's computed the
size of Ty.

>   return getPtrToInt(GEP,
>                      Type::getInt64Ty(Ty->getContext()));
> }

(2) there is no testcase.

Ciao, Duncan.



More information about the llvm-commits mailing list