From 97190a2c9389abef09fdd6eaad763dba4f02f0a4 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 17 Jul 2009 19:23:21 +0000 Subject: GetElementPtr instructions default to having no overflow. llvm-svn: 76222 --- llvm/lib/VMCore/Instructions.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index 6a259fb9251..a5e082c2377 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -1022,6 +1022,9 @@ void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx, OL[i+1] = Idx[i]; setName(Name); + + // GetElementPtr instructions have undefined results on overflow by default. + setHasNoPointerOverflow(true); } void GetElementPtrInst::init(Value *Ptr, Value *Idx, const std::string &Name) { @@ -1031,6 +1034,9 @@ void GetElementPtrInst::init(Value *Ptr, Value *Idx, const std::string &Name) { OL[1] = Idx; setName(Name); + + // GetElementPtr instructions have undefined results on overflow by default. + setHasNoPointerOverflow(true); } GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI) @@ -1042,6 +1048,9 @@ GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI) Use *GEPIOL = GEPI.OperandList; for (unsigned i = 0, E = NumOperands; i != E; ++i) OL[i] = GEPIOL[i]; + + // Transfor the hasNoPointerOverflow() value from the original GEPI. + setHasNoPointerOverflow(GEPI.hasNoPointerOverflow()); } GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, -- cgit v1.2.3