Teach lib/VMCore/ConstantFold.cpp how to set the inbounds keyword and
how to fold notionally-out-of-bounds array getelementptr indices instead
of just doing these in lib/Analysis/ConstantFolding.cpp, because it can
be done in a fairly general way without TargetData, and because not all
constants are visited by lib/Analysis/ConstantFolding.cpp. This enables
more constant folding.
Also, set the "inbounds" flag when the getelementptr indices are
one-past-the-end.
llvm-svn: 81483
diff --git a/llvm/lib/VMCore/ConstantFold.h b/llvm/lib/VMCore/ConstantFold.h
index afa9978..f4452c9 100644
--- a/llvm/lib/VMCore/ConstantFold.h
+++ b/llvm/lib/VMCore/ConstantFold.h
@@ -64,6 +64,7 @@
const Constant *C1,
const Constant *C2);
Constant *ConstantFoldGetElementPtr(LLVMContext &Context, const Constant *C,
+ bool inBounds,
Constant* const *Idxs, unsigned NumIdx);
} // End llvm namespace