Make GetElementPtr ConstantExprs default to having no pointer overflow.
authorDan Gohman <gohman@apple.com>
Sat, 18 Jul 2009 01:49:22 +0000 (01:49 +0000)
committerDan Gohman <gohman@apple.com>
Sat, 18 Jul 2009 01:49:22 +0000 (01:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76280 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Constants.cpp

index 81f544b0e827b0fa45b94129f937215f6f5533e7..f6d8e86850f4ff5efb6f3984fb2a1d3df2782676 100644 (file)
@@ -18,6 +18,7 @@
 #include "llvm/Instructions.h"
 #include "llvm/MDNode.h"
 #include "llvm/Module.h"
+#include "llvm/Operator.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
@@ -474,8 +475,11 @@ public:
   static GetElementPtrConstantExpr *Create(Constant *C,
                                            const std::vector<Constant*>&IdxList,
                                            const Type *DestTy) {
-    return new(IdxList.size() + 1)
+    GetElementPtrConstantExpr *Result = new(IdxList.size() + 1)
       GetElementPtrConstantExpr(C, IdxList, DestTy);
+    // Getelementptr defaults to having no pointer overflow.
+    cast<GEPOperator>(Result)->setHasNoPointerOverflow(true);
+    return Result;
   }
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);