Commit Graph

3082 Commits

Author SHA1 Message Date
Chris Lattner cf295039e4 Fix PR5023: The instruction form of DominatorTree::dominates did not
take into consideration that the result of an invoke is only valid in
the normal dest, not the unwind dest.  This caused 'PHINode::hasConstantValue'
to return true in an invalid situation, causing mem2reg to delete a phi that
was actually needed.  This caused a crash building 483.xalancbmk.

llvm-svn: 82491
2009-09-21 22:39:35 +00:00
Chris Lattner 22151ce5e9 move DominatorTree::dominates for instructions out of line,
no functionality change.

llvm-svn: 82490
2009-09-21 22:30:50 +00:00
Chris Lattner 7d08da6b2a tidy up
llvm-svn: 82489
2009-09-21 22:27:34 +00:00
Nuno Lopes 2c7e72cf42 initialize SymbolsCanStartWithDigit to false by default
llvm-svn: 82454
2009-09-21 14:11:56 +00:00
Nick Lewycky 9b3ed87506 Peer through zext and sext to eliminate them when it is safe to do so.
llvm-svn: 82389
2009-09-20 07:31:25 +00:00
Nick Lewycky b0225ba289 Fold 'icmp eq (icmp), true' into an xor(icmp).
llvm-svn: 82386
2009-09-20 07:21:39 +00:00
Nick Lewycky ff550aa36d Correct the comment; this applies to fcmp too.
llvm-svn: 82380
2009-09-20 06:27:35 +00:00
Nick Lewycky 0f8348e85b Remove tab, again.
llvm-svn: 82379
2009-09-20 06:26:34 +00:00
Nick Lewycky 28260409f2 Teach the constant folder how to not a cmpinst.
llvm-svn: 82378
2009-09-20 06:24:51 +00:00
Nick Lewycky 4a03452077 Try turning icmp(bitcast(x), bitcast(y)) into icmp(bitcast(bitcast(x)), y) in
the hopes that the two bitcasts will merge.

llvm-svn: 82371
2009-09-20 05:48:50 +00:00
Nick Lewycky 2b31b53d97 Remove tabs I added.
llvm-svn: 82369
2009-09-20 05:47:45 +00:00
Nick Lewycky 9e085545f8 Clean up the usage of evaluateICmpRelation's return value.
Add another line to the ConstantExprFold test to demonstrate the GEPs may not
wrap around in either the signed or unsigned senses.

llvm-svn: 82361
2009-09-20 04:27:06 +00:00
Daniel Dunbar 6058b51f8c Strip trailing whitespace.
llvm-svn: 82359
2009-09-20 04:03:34 +00:00
Nick Lewycky 2949a2398c Remove dead store by taking a guess at what Chris meant. I wasn't able to
design a testcase that would tickle this behaviour.

llvm-svn: 82357
2009-09-20 03:48:46 +00:00
Daniel Dunbar 7d6781b0fe Tabs -> spaces, and remove trailing whitespace.
llvm-svn: 82355
2009-09-20 02:20:51 +00:00
Nick Lewycky 595b3dfcbe Delete dead code. sext and zext can not turn integers into pointers. Further,
the optimization described in the comment is only valid with target data.

llvm-svn: 82353
2009-09-20 02:11:47 +00:00
Nick Lewycky e0332983fd Value* were never meant to be const. Removing constness from the constant
folder removes a lot of const_casting and requires no changes to clang or
llvm-gcc.

llvm-svn: 82349
2009-09-20 01:35:59 +00:00
Nick Lewycky 605109d151 Teach the constant folder how to handle a few simple i1 cases.
llvm-svn: 82340
2009-09-20 00:04:02 +00:00
Devang Patel af206b8c88 Write and read metadata attachments.
llvm-svn: 82259
2009-09-18 19:26:43 +00:00
Victor Hernandez 788eaabd18 Update malloc call creation code (AllocType is now the element type of the malloc, not the resulting type).
In getMallocArraySize(), fix bug in the case that array size is the product of 2 constants.

Extend isArrayMalloc() and getMallocArraySize() to handle case where malloc is used as char array.

Ensure that ArraySize in LowerAllocations::runOnBasicBlock() is correct type.

Extend Instruction::isSafeToSpeculativelyExecute() to handle malloc calls.

Add verification for malloc calls.

Reviewed by Dan Gohman.

llvm-svn: 82257
2009-09-18 19:20:02 +00:00
Anton Korobeynikov 592638ae05 Allow symbols to start from the digit if target requests it. This allows, e.g. pinning
variables to specified absolute address. Make use of this feature for MSP430.
This unbreaks PR4776.

llvm-svn: 82227
2009-09-18 16:57:42 +00:00
Benjamin Kramer 5ff90ed33e Initialize HasMetadata to zero.
llvm-svn: 82145
2009-09-17 14:51:57 +00:00
Devang Patel dec23fd825 Print debug info attached with an instruction.
llvm-svn: 82075
2009-09-16 20:21:17 +00:00
Devang Patel d5497a4bf8 Add llvm::Metadata to manage metadata used in a context.
This interface will be used to attach metadata with an instruction.

llvm-svn: 82060
2009-09-16 18:09:00 +00:00
Dan Gohman 0ea0e1b4af Fix an accidental inversion of the inbounds flag.
llvm-svn: 81862
2009-09-15 16:00:30 +00:00
Dan Gohman e4532f30b1 When a constant's type is refined, update the constant in place
instead of cloning and RAUWing it.

 - Make AbstractTypeUser a friend of Value so that it can offer
   its subclasses a way to update a Value's type in place. This
   is better than a universally visible setType method on Value,
   and it's sufficient for the immediate need.

 - Eliminate the constant "convert" functions. This eliminates a
   lot of logic duplication, and fixes a complicated bug where a
   constant can't actually be cloned during the type refinement
   process because some of the types that its folder needs are
   half-destroyed, being in the middle of refinement themselves.

 - Move the getValType functions from being static overloaded
   functions in Constants.cpp to be members of class template
   specializations in ConstantsContext.h. This means that the
   code ends up getting instantiated twice, however it also
   makes it possible to eliminate all "convert" functions, so
   it's not a big net code size increase. And if desired, the
   duplicate instantiations could be eliminated with some
   reorganization.

llvm-svn: 81861
2009-09-15 15:58:07 +00:00
Nick Lewycky c5cb3bd927 Forbid arrays of function-type and structures with function-typed fields.
While I'm there, change code that does:
  SomeTy == Type::getFooType(Context)
into:
  SomeTy->getTypeID() == FooTyID
to decrease the amount of useless type creation which may involve locking, etc.

llvm-svn: 81846
2009-09-15 06:28:26 +00:00
Chris Lattner ee8f74f5d1 fix PR4963: folding insertvalue would sometimes turn a packed struct into
an unpacked one.

llvm-svn: 81845
2009-09-15 06:28:12 +00:00
Chris Lattner d4d966f500 make -debug-pass=Executions show information about what call graph nodes
are in the SCC for each execution of a CGSCC pass.

llvm-svn: 81838
2009-09-15 05:03:04 +00:00
Chris Lattner f82f27be3f add some missing quotes in debug output
llvm-svn: 81836
2009-09-15 04:45:26 +00:00
Nick Lewycky a22585ada9 Fix a pair of comment typos.
llvm-svn: 81750
2009-09-14 02:25:34 +00:00
Nick Lewycky 22c4a497ab Fifth time's a charm! Remove ourselves as abstract type listeners once we've
been told that the type is no longer abstract.

llvm-svn: 81749
2009-09-14 02:25:19 +00:00
Nick Lewycky c9f9367785 Don't leak! Always remove oneself as a listener after adding oneself.
llvm-svn: 81736
2009-09-14 00:36:52 +00:00
Nick Lewycky 64f18eceaf Actually remove old types from the set.
Also break the type verification stuff into its own TypeSet to keep the
Verifier pass from becoming an AbstractTypeUser.

llvm-svn: 81729
2009-09-13 23:45:39 +00:00
Nick Lewycky 6133026331 Storing a set of PATypeHolders is a bad idea because their sort order will
change as types are refined. Remove abstract types from CheckedTypes when they
we're informed that they have been refined. The only way types get refined in
the verifier is when later function passes start optimizing. Fixes PR4970.

llvm-svn: 81716
2009-09-13 21:07:59 +00:00
Chris Lattner 3d6c8ebb58 Make the MC symbol printer and llvm::Mangler exactly agree on mangling
for systems that don't support quoting (PR4966).

llvm-svn: 81682
2009-09-13 18:04:46 +00:00
Dan Gohman f436e87813 Preserve the inbounds flag, so that the constant folder doesn't
recompute it.

llvm-svn: 81634
2009-09-12 22:02:17 +00:00
Dan Gohman 07b5c40ed8 Fix the build when DEBUG_SYMBOL_TABLE is set.
llvm-svn: 81633
2009-09-12 21:56:48 +00:00
Daniel Dunbar b918900995 Fix -Asserts warning.
llvm-svn: 81580
2009-09-11 22:07:31 +00:00
Chris Lattner 7730dcc858 reject attempts to take the address of an intrinsic, PR4949.
llvm-svn: 81530
2009-09-11 17:05:29 +00:00
Chris Lattner c827f53495 fix prefix ordering, it's L_foo not _Lfoo
llvm-svn: 81506
2009-09-11 05:51:29 +00:00
Chris Lattner 840c8d72d0 add a new Mangler::getNameWithPrefix API which returns the
(uniqued if unnamed) global variable name with the prefix that
it is supposed to get.  It doesn't do "mangling" in the sense of
adding quotes and hacking on bad characters.

llvm-svn: 81505
2009-09-11 05:40:42 +00:00
Dan Gohman 11ff570292 Fix indentation.
llvm-svn: 81484
2009-09-11 00:05:10 +00:00
Dan Gohman 21c6216c87 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 7190d48075 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
Devang Patel 5ffc3854f6 Fix whitespaces.
llvm-svn: 81468
2009-09-10 22:36:12 +00:00
Benjamin Kramer 4bf4e8686c Add some braces to make newer GCCs happy and update CMakeLists.
llvm-svn: 81443
2009-09-10 11:31:39 +00:00
Evan Cheng 1d9d4bdc99 Add malloc call utility functions. Patch by Victor Hernandez.
llvm-svn: 81426
2009-09-10 04:36:43 +00:00
Devang Patel cbde073d8c Take lock before removing a node from MDNodeSet.
llvm-svn: 81356
2009-09-09 17:44:26 +00:00
Devang Patel 9a767cb5c0 Enable MDNode uniquing.
llvm-svn: 81355
2009-09-09 17:30:04 +00:00
Devang Patel 93056ec4e2 Gracefully destroy MDNodes.
llvm-svn: 81353
2009-09-09 17:07:07 +00:00
Devang Patel 926fc3d68d Remove dead code.
llvm-svn: 81235
2009-09-08 18:14:36 +00:00
Nick Lewycky 12c77d73a9 Hoist out the test+insert to CheckedTypes. This doesn't seem to affect
performance.

llvm-svn: 81193
2009-09-08 05:46:15 +00:00
Nick Lewycky 984161af16 Simplify from my last change. Assert1 is a macro that makes its caller return,
so "Assert1(isa<>); cast<>" is a valid idiom.

Actually check the PHI node's odd-numbered operands for BasicBlock-ness, like
the comment said.

llvm-svn: 81182
2009-09-08 02:02:39 +00:00
Nick Lewycky b2b0467e18 Verify types. Invalid types can be constructed when assertions are off.
Make the verifier more robust by avoiding unprotected cast<> calls. Notably,
Assert1(isa<>); cast<> is not safe as Assert1 does not terminate the program.

llvm-svn: 81179
2009-09-08 01:23:52 +00:00
Dan Gohman 1b84908f92 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
Nick Lewycky d7fb16d895 Express this in the canonical way.
llvm-svn: 81157
2009-09-07 21:50:24 +00:00
Nick Lewycky 3fc89804a6 Homogenize whitespace.
llvm-svn: 81156
2009-09-07 20:44:51 +00:00
Daniel Dunbar 10fcf3354b Disable MDNode uniquing.
- Hopefully this unbreaks some llvm-gcc bootstraps.

llvm-svn: 81141
2009-09-07 04:05:49 +00:00
Duncan Sands 0f5bbb585c Public and private corrections, warned about by icc (#304).
Patch by Erick Tryzelaar.

llvm-svn: 81107
2009-09-06 08:55:57 +00:00
Duncan Sands 2fbeaf084f Remove some unused variables and methods warned about by
icc (#177, partial).  Patch by Erick Tryzelaar.

llvm-svn: 81106
2009-09-06 08:33:48 +00:00
Daniel Dunbar 10ea8bb8e0 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
Devang Patel a33c5a922d While replacing an MDNode elment, properly update MDNode's operand list.
MDNode's operand list does not include all elements.

llvm-svn: 81045
2009-09-04 21:32:05 +00:00
Dan Gohman 0c2477c26b 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 e4ca02da1b 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 2a53b30f6d 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 85dac4771f Use WeakVH to hold dead mdnodes. Check use_empty() before deleting a node.
llvm-svn: 80928
2009-09-03 17:03:47 +00:00
Dan Gohman 22571485b3 Change PHINode::hasConstantValue to have a DominatorTree argument
instead of a bool argument, and to do the dominator check itself.
This makes it eaiser to use when DominatorTree information is
available.

llvm-svn: 80920
2009-09-03 15:34:35 +00:00
Gabor Greif 2d60e1ec0c back out my recent commit (r80858), it seems to break self-hosting buildbot's stage 2 configure
llvm-svn: 80871
2009-09-03 02:02:59 +00:00
Devang Patel f7188325ef 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
Gabor Greif 14dfba6d66 re-commit r66920 (which has been backed out in r66953) I may have more luck this time. I'll back out if needed...
llvm-svn: 80858
2009-09-03 00:18:58 +00:00
Devang Patel c180029be4 Revert 80839 for now. It causes test failures.
llvm-svn: 80841
2009-09-02 21:49:26 +00:00
Devang Patel 36309cd391 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
Torok Edwin 82131d6ad7 Opaque types didn't work if llvm_is_multithreaded().
AlwaysOpaqueTy is always NULL at this point, and it causes an assertion failure.
Fix it by using the just constructed tmp instead.

llvm-svn: 80780
2009-09-02 12:23:05 +00:00
Torok Edwin 18e03dd70c Fix DbgStopPointInst->getFileName/getDirectory, broken by the MDNodification in
r80406, and readd a -print-dbginfo test.

llvm-svn: 80778
2009-09-02 11:13:56 +00:00
Sandeep Patel 68c5f477fa Retype from unsigned to CallingConv::ID accordingly. Approved by Bob Wilson.
llvm-svn: 80773
2009-09-02 08:44:58 +00:00
Devang Patel 8c7f86e698 For now disable MDNode uniquing. This fixes llvm-gcc bootstrap failure on certain Mac OS X 10.5. I am working on a proper fix.
llvm-svn: 80738
2009-09-01 23:56:42 +00:00
Torok Edwin d18e668fbc Free the constants that have no uses in ~LLVMContext.
This fixes leaks from LLVMContext in multithreaded apps.
Since constants are only deleted if they have no uses, it is safe to not delete
a Module on shutdown, as many single-threaded tools do.
Multithreaded apps should however delete the Module before destroying the
Context to ensure that there are no leaks (assuming they use a different context
for each thread).

llvm-svn: 80590
2009-08-31 16:14:59 +00:00
Dan Gohman 062d378603 Cleanup whitespace and indentation.
llvm-svn: 80451
2009-08-29 23:35:16 +00:00
Dan Gohman 07d0a55a9b Remove some unused fields.
llvm-svn: 80450
2009-08-29 23:34:14 +00:00
Devang Patel 80ae34974b Reapply 79977.
Use MDNodes to encode debug info in llvm IR.

llvm-svn: 80406
2009-08-28 23:24:31 +00:00
Dan Gohman 4ce5ade09d Teach getUnderlyingObject and skipPointerCasts about GlobalAliases.
llvm-svn: 80265
2009-08-27 17:55:13 +00:00
Devang Patel 7b8f61f3c8 Remove an entry from ValueMap before removing elements.
llvm-svn: 80247
2009-08-27 15:32:38 +00:00
Devang Patel f08e35d9dc Revert 79977. It causes llvm-gcc bootstrap failures on some platforms.
llvm-svn: 80073
2009-08-26 05:01:18 +00:00
Dale Johannesen 2aaf539564 Add an 'inline hint' attribute to represent source
code hints that it would be a good idea to inline
a function ("inline" keyword).  No functional change
yet; FEs do not emit this and inliner does not use it.

llvm-svn: 80063
2009-08-26 01:08:21 +00:00
Dan Gohman e5af8cd13b Fix the InsertAtEnd form of ShuffleVectorInst constructor to use
the correct type.

llvm-svn: 80050
2009-08-25 23:27:45 +00:00
Dan Gohman ad1f0a1101 Eliminate the unused Context argument on one of the ICmpInst and FCmpInst
constructors.

llvm-svn: 80049
2009-08-25 23:17:54 +00:00
Dan Gohman faf516f34d Use covariant return types for Instruction::clone, and eliminate
the forms of ExtractElementInst and InsertElementInst that are
equivalent to clone.

llvm-svn: 80041
2009-08-25 22:29:08 +00:00
Dan Gohman 23d2c76f31 This should use isIndenticalToWhenDefined.
llvm-svn: 80039
2009-08-25 22:24:20 +00:00
Dan Gohman c8a27f2a5c Rename Instruction::isIdenticalTo to Instruction::isIdenticalToWhenDefined,
and introduce a new Instruction::isIdenticalTo which tests for full
identity, including the SubclassOptionalData flags. Also, fix the
Instruction::clone implementations to preserve the SubclassOptionalData
flags. Finally, teach several optimizations how to handle
SubclassOptionalData correctly, given these changes.

This fixes the counterintuitive behavior of isIdenticalTo not comparing
the full value, and clone not returning an identical clone, as well as
some subtle bugs that could be caused by these.

Thanks to Nick Lewycky for reporting this, and for an initial patch!

llvm-svn: 80038
2009-08-25 22:11:20 +00:00
Dan Gohman 97d2cb8394 Allocate the basic types inside the LLVMContextImpl instance,
rather than separately with new. Move the members above the
TypeMap members to avoid destruction order issues. This fixes
a leak of these objects, and eliminates an extra level of
indirection in Type::getInt32Ty and friends.

llvm-svn: 79997
2009-08-25 16:00:35 +00:00
Devang Patel 02aac922b4 Update DebugInfo interface to use metadata, instead of special named llvm.dbg.... global variables, to encode debugging information in llvm IR. This is mostly a mechanical change that tests metadata support very well.
This change speeds up llvm-gcc by more then 6% at "-O0 -g" (measured by compiling InstructionCombining.cpp!)

llvm-svn: 79977
2009-08-25 05:24:07 +00:00
Benjamin Kramer 1a25d733f9 Kill off more cerr/cout uses and prune includes a bit.
llvm-svn: 79852
2009-08-23 11:37:21 +00:00
Chris Lattner 1362602eb2 Change Pass::print to take a raw ostream instead of std::ostream,
update all code that this affects.

llvm-svn: 79830
2009-08-23 06:03:38 +00:00
Chris Lattner b1d782bec9 eliminate the std::ostream form of WriteAsOperand and update clients.
This also updates dominator related stuff.

llvm-svn: 79825
2009-08-23 05:17:37 +00:00
Chris Lattner 3924bb5792 remove the std::ostream version of module and type printing.
llvm-svn: 79823
2009-08-23 04:52:46 +00:00
Chris Lattner 34822f6ec7 remove some DOUTs
llvm-svn: 79821
2009-08-23 04:44:11 +00:00
Chris Lattner b25de3ff60 eliminate the "Value" printing methods that print to a std::ostream.
This required converting a bunch of stuff off DOUT and other cleanups.

llvm-svn: 79819
2009-08-23 04:37:46 +00:00
Owen Anderson 3fb4aabc06 Use standard LLVM-style headers.
llvm-svn: 79817
2009-08-23 04:24:24 +00:00
Chris Lattner 78683a7013 switch a couple things off std::ostream
llvm-svn: 79816
2009-08-23 04:02:03 +00:00