Slightly simplify code with helper functions

e.g. Use Ty->getPointerElementType()
instead of cast<PointerType>(Ty)->getElementType()