aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-27 21:59:50 +0000
committerDan Gohman <gohman@apple.com>2009-07-27 21:59:50 +0000
commit79c87141f1800ba06140b5228f4752e84242b2d8 (patch)
tree161a14a199031030e3bdd2f569e70aeea84f8471
parent3e5bc0c33e0565b84c429caf2bbff0da70e549c2 (diff)
downloadexternal_llvm-79c87141f1800ba06140b5228f4752e84242b2d8.zip
external_llvm-79c87141f1800ba06140b5228f4752e84242b2d8.tar.gz
external_llvm-79c87141f1800ba06140b5228f4752e84242b2d8.tar.bz2
Add a comment about the "getelementptr null" trick.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77262 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/VMCore/LLVMContext.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/VMCore/LLVMContext.cpp b/lib/VMCore/LLVMContext.cpp
index d7f4594..722e29e 100644
--- a/lib/VMCore/LLVMContext.cpp
+++ b/lib/VMCore/LLVMContext.cpp
@@ -419,6 +419,7 @@ Constant* LLVMContext::getConstantExprInsertValue(Constant* Agg, Constant* Val,
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);