Add a comment about the "getelementptr null" trick.
llvm-svn: 77262
diff --git a/llvm/lib/VMCore/LLVMContext.cpp b/llvm/lib/VMCore/LLVMContext.cpp
index d7f4594..722e29e 100644
--- a/llvm/lib/VMCore/LLVMContext.cpp
+++ b/llvm/lib/VMCore/LLVMContext.cpp
@@ -419,6 +419,7 @@
Constant* LLVMContext::getConstantExprSizeOf(const Type* Ty) {
// sizeof is implemented as: (i64) gep (Ty*)null, 1
+ // Note that a non-inbounds gep is used, as null isn't within any object.
Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1);
Constant *GEP = getConstantExprGetElementPtr(
getNullValue(getPointerTypeUnqual(Ty)), &GEPIdx, 1);