1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
Commit Graph

389 Commits

Author SHA1 Message Date
Dan Gohman
aa66e3d968 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
2009-09-11 00:04:14 +00:00
Dan Gohman
58a0550024 Factor out the code for checking that all indices in a getelementptr are
within the notional bounds of the static type of the getelementptr (which
is not the same as "inbounds") from GlobalOpt into a utility routine,
and use it in ConstantFold.cpp to check whether there are any mis-behaved
indices.

llvm-svn: 81478
2009-09-10 23:37:55 +00:00
Dan Gohman
1147a7ba87 Reappy r80998, now that the GlobalOpt bug that it exposed on MiniSAT is fixed.
llvm-svn: 81172
2009-09-07 23:54:19 +00:00
Daniel Dunbar
452643b58c Revert "Include optional subclass flags, such as inbounds, nsw, etc., ...", this
breaks MiniSAT on x86_64.

llvm-svn: 81098
2009-09-06 00:11:24 +00:00
Dan Gohman
8b386a0b63 Include optional subclass flags, such as inbounds, nsw, etc., in the
Constant uniquing tables. This allows distinct ConstantExpr objects
with the same operation and different flags.

Even though a ConstantExpr "a + b" is either always overflowing or
never overflowing (due to being a ConstantExpr), it's still necessary
to be able to represent it both with and without overflow flags at
the same time within the IR, because the safety of the flag may
depend on the context of the use. If the constant really does overflow,
it wouldn't ever be safe to use with the flag set, however the use
may be in code that is never actually executed.

This also makes it possible to merge all the flags tests into a single test.

llvm-svn: 80998
2009-09-04 12:08:11 +00:00
Dan Gohman
b9b2864a49 Revert 80959. It isn't sufficient to solve the full problem. And it
introduced regressions in the Ocaml bindings tests.

llvm-svn: 80969
2009-09-03 23:34:49 +00:00
Dan Gohman
e5ec3c1a26 Remove the API for creating ConstantExprs with the nsw, nuw, inbounds,
and exact flags. Because ConstantExprs are uniqued, creating an
expression with this flag causes all expressions with the same operands
to have the same flag, which may not be safe. Add, sub, mul, and sdiv
ConstantExprs are usually folded anyway, so the main interesting flag
here is inbounds, and the constant folder already knows how to set the
inbounds flag automatically in most cases, so there isn't an urgent need
for the API support.

This can be reconsidered in the future, but for now just removing these
API bits eliminates a source of potential trouble with little downside.

llvm-svn: 80959
2009-09-03 22:17:40 +00:00
Devang Patel
27616c3c80 Now Bitcode reader bug is fixed. Reapply 80839.
Use CallbackVH, instead of WeakVH, to hold MDNode elements.
Use FoldingSetNode to unique MDNodes in a context.
Use CallbackVH hooks to update context's MDNodeSet appropriately.

llvm-svn: 80868
2009-09-03 01:39:20 +00:00
Devang Patel
317ab82083 Revert 80839 for now. It causes test failures.
llvm-svn: 80841
2009-09-02 21:49:26 +00:00
Devang Patel
c4be6559c4 Use CallbackVH, instead of WeakVH, to hold MDNode elements.
Use FoldingSetNode to unique MDNodes in a context.
Use CallbackVH hooks to update context's MDNodeSet appropriately.

llvm-svn: 80839
2009-09-02 21:22:09 +00:00
Chris Lattner
2d541e612d switch a couple things off std::ostream
llvm-svn: 79816
2009-08-23 04:02:03 +00:00
Dan Gohman
6ec8176e22 Rename hasNoUnsignedOverflow and hasNoSignedOverflow to hasNoUnsignedWrap
and hasNoSignedWrap, for consistency with the nuw and nsw properties.

llvm-svn: 79539
2009-08-20 17:11:38 +00:00
Erick Tryzelaar
d7980d95e8 Add helper functions to ConstantInt and ConstantFP to accept strings.
llvm-svn: 79212
2009-08-16 23:36:33 +00:00
Dan Gohman
a7f21f1767 Add a getOffsetOf, for building a target-independent expression for
offsetof, similar to getSizeOf for sizeof.

llvm-svn: 79208
2009-08-16 21:26:11 +00:00
Owen Anderson
9df206d02d Push LLVMContexts through the IntegerType APIs.
llvm-svn: 78948
2009-08-13 21:58:54 +00:00
Dan Gohman
b0c54f532c Add convenience functions for creating nsw add operators.
llvm-svn: 78707
2009-08-11 20:20:39 +00:00
Dan Gohman
76887b6f2b Don't set the isexact flag if an sdiv operator has been folded into
something else.

llvm-svn: 78702
2009-08-11 19:56:00 +00:00
Daniel Dunbar
490f80eb1c Simplify ConstantExpr::getInBoundsGetElementPtr and fix a possible crash, if
constant folding eliminated the GEP instruction.
 - clang was hitting this on its test suite (for x86_64, at least).

llvm-svn: 78698
2009-08-11 18:28:09 +00:00
Dan Gohman
aed57ee5b0 Add convenience functions for creating inbounds GEPs.
llvm-svn: 78695
2009-08-11 17:57:01 +00:00
Dan Gohman
82b3823bb7 Add convenience functions for creating exact sdiv operators, and
use them in CreatePtrDiff.

llvm-svn: 78682
2009-08-11 17:05:24 +00:00
Owen Anderson
4cd02c843b Change the MDNode uniquing to a ValueMap, at Devang's request.
llvm-svn: 78577
2009-08-10 18:16:08 +00:00
Owen Anderson
3d0e1b855d Privatize the StructType table, which unfortunately involves routing contexts through a number of APIs.
llvm-svn: 78258
2009-08-05 23:16:16 +00:00
Owen Anderson
762987e14b Privatize the last bit of Constant-creation state.
llvm-svn: 78097
2009-08-04 20:25:11 +00:00
Dan Gohman
39f93f6443 Add a new Constant::getIntegerValue helper function, and convert a
few places in InstCombine to use it, to fix problems handling pointer
types. This fixes the recent llvm-gcc bootstrap error.

llvm-svn: 78005
2009-08-03 22:07:33 +00:00
Owen Anderson
5370346117 Privatize all but one of the remaining constant tables.
llvm-svn: 77748
2009-07-31 22:45:43 +00:00
Owen Anderson
1dc40e205b Move a few more APIs back to 2.5 forms. The only remaining ones left to change back are
metadata related, which I'm waiting on to avoid conflicting with Devang.

llvm-svn: 77721
2009-07-31 20:28:14 +00:00
Owen Anderson
d0e6352c97 Move getTrue() and getFalse() to 2.5-like APIs.
llvm-svn: 77685
2009-07-31 17:39:07 +00:00
Owen Anderson
93ccaf5c60 Move more code back to 2.5 APIs.
llvm-svn: 77635
2009-07-30 23:03:37 +00:00
Owen Anderson
881d928f9b Move types back to the 2.5 API.
llvm-svn: 77516
2009-07-29 22:17:13 +00:00
Owen Anderson
0ce2151b36 Move ConstantExpr to 2.5 API.
llvm-svn: 77494
2009-07-29 18:55:55 +00:00
Devang Patel
cb23671431 Rename MDNode.h header. It defines MDnode and other metadata classes.
New name is Metadata.h.

llvm-svn: 77370
2009-07-28 21:49:47 +00:00
Owen Anderson
390e9778d4 Return ConstantVector to 2.5 API.
llvm-svn: 77366
2009-07-28 21:19:26 +00:00
Owen Anderson
aa8c94b051 Change ConstantArray to 2.5 API.
llvm-svn: 77347
2009-07-28 18:32:17 +00:00
Owen Anderson
d729f993b8 Move ConstantStruct back to 2.5 API.
llvm-svn: 77266
2009-07-27 22:29:26 +00:00
Daniel Dunbar
89c8a88449 Unbreak build.
llvm-svn: 77256
2009-07-27 21:47:07 +00:00
Owen Anderson
256c2c250e Move ConstantFP construction back to the 2.5-ish API.
llvm-svn: 77247
2009-07-27 20:59:43 +00:00
Owen Anderson
cc33e89571 Revert the ConstantInt constructors back to their 2.5 forms where possible, thanks to contexts-on-types. More to come.
llvm-svn: 77011
2009-07-24 23:12:02 +00:00
Chris Lattner
2cae10056c make Constant::getRelocationInfo return an enum, as suggested by Duncan.
llvm-svn: 76938
2009-07-24 03:27:21 +00:00
Owen Anderson
be00de7dfe Privatize the ConstantVector tables.
llvm-svn: 76922
2009-07-24 00:36:24 +00:00
Owen Anderson
d449007c92 Privatize the ConstantStruct table.
llvm-svn: 76912
2009-07-23 23:25:33 +00:00
Devang Patel
6b2162686a Derive MDNode from MetadataBase instead of Constant. Emit MDNodes into METADATA_BLOCK in bitcode file.
llvm-svn: 76834
2009-07-23 01:07:34 +00:00
Devang Patel
5794cb80ad Introduce MetadataBase, a base class for MDString and MDNode.
Derive MDString directly from MetadataBase. 
Introduce new bitcode block to hold metadata.

llvm-svn: 76759
2009-07-22 17:43:22 +00:00
Chris Lattner
48dffde0d7 reimplement Constant::ContainsRelocations as
Constant::getRelocationInfo(), which has a much simpler
to use API.  It still should not be part of libvmcore, but
is better than it was.  Also teach it to be smart about 
hidden visibility.

llvm-svn: 76700
2009-07-22 00:05:44 +00:00
Owen Anderson
a8637e9824 Privatize the ConstantArray table.
llvm-svn: 76639
2009-07-21 20:55:28 +00:00
Owen Anderson
bdcb99324a Privatize the first of the value maps.
llvm-svn: 76634
2009-07-21 20:13:12 +00:00
Owen Anderson
b64eef73cf Move a bit more state over to the LLVMContext.
llvm-svn: 76533
2009-07-21 02:47:59 +00:00
Dan Gohman
00b05492f1 Revert the addition of hasNoPointerOverflow to GEPOperator.
Getelementptrs that are defined to wrap are virtually useless to
optimization, and getelementptrs that are undefined on any kind
of overflow are too restrictive -- it's difficult to ensure that
all intermediate addresses are within bounds. I'm going to take
a different approach.

Remove a few optimizations that depended on this flag.

llvm-svn: 76437
2009-07-20 17:43:30 +00:00
Dan Gohman
8c7d396617 Make GetElementPtr ConstantExprs default to having no pointer overflow.
llvm-svn: 76280
2009-07-18 01:49:22 +00:00
Daniel Dunbar
cfd362eb0e Fix compile warning.
llvm-svn: 76210
2009-07-17 18:33:52 +00:00
Owen Anderson
1c2b8cc518 Privatize the MDNode uniquing table.
llvm-svn: 76126
2009-07-16 23:44:30 +00:00