Commit Graph

5768 Commits

Author SHA1 Message Date
Victor Hernandez e297149e26 Auto-upgrade free instructions to calls to the builtin free function.
Update all analysis passes and transforms to treat free calls just like FreeInst.
Remove RaiseAllocations and all its tests since FreeInst no longer needs to be raised.

llvm-svn: 84987
2009-10-24 04:23:03 +00:00
Victor Hernandez 8acf2956b8 Remove AllocationInst. Since MallocInst went away, AllocaInst is the only subclass of AllocationInst, so it no longer is necessary.
llvm-svn: 84969
2009-10-23 21:09:37 +00:00
Dan Gohman 41d00ac45b Make LoopDeletion check the maximum backedge taken count, rather than the
exact backedge taken count, when checking for infinite loops. This allows
it to delete loops with multiple exit conditions.

llvm-svn: 84952
2009-10-23 17:10:01 +00:00
Chris Lattner cf7e8947e9 move another load optimization from instcombine -> libanalysis.
llvm-svn: 84841
2009-10-22 06:44:07 +00:00
Chris Lattner 51d2f70e32 move 'loading i32 from string' optimization from instcombine
to libanalysis.  Instcombine shrinking... does this even 
make sense???

llvm-svn: 84840
2009-10-22 06:38:35 +00:00
Chris Lattner 1664a4fd86 Move some constant folding logic for loads out of instcombine into
Analysis/ConstantFolding.cpp.  This doesn't change the behavior of
instcombine but makes other clients of ConstantFoldInstruction
able to handle loads.  This was partially extracted from Eli's patch
in PR3152.

llvm-svn: 84836
2009-10-22 06:25:11 +00:00
Chris Lattner c7a962d3b3 fix PR5262.
llvm-svn: 84810
2009-10-22 00:17:26 +00:00
Devang Patel 27e0be274e Derive metadata hierarchy from Value instead of User.
llvm-svn: 84801
2009-10-21 23:57:35 +00:00
Chris Lattner 966526cbfb revert r84754, it isn't the right approach. Edwin, please propose
patches for fixes like this instead of committing them directly.

llvm-svn: 84799
2009-10-21 23:41:58 +00:00
Victor Hernandez be9e179104 Make changes to rev 84292 as requested by Chris Lattner.
Most changes are cleanup, but there is 1 correctness fix:
I fixed InstCombine so that the icmp is removed only if the malloc call is removed (which requires explicit removal because the Worklist won't DCE any calls since they can have side-effects).

llvm-svn: 84772
2009-10-21 19:11:40 +00:00
Torok Edwin 1539a352a6 Fix PR5262: when folding select into PHI, make sure all operands are available
in the PHI's Basic Block. This uses a conservative approach, because we don't
have dominator info in instcombine.

llvm-svn: 84754
2009-10-21 10:49:00 +00:00
Chris Lattner 8ed7bef409 make GVN work better when TD is not around:
"In the existing code, if the load and the value to replace it with are
of different types *and* target data is available, it tries to use the
target data to coerce the replacement value to the type of the load.
Otherwise, it skips all effort to handle the type mismatch and just
feeds the wrongly-typed replacement value to replaceAllUsesWith, which
triggers an assertion.

The patch replaces it with an outer if checking for type mismatch, and
an inner if-else that checks whether target data is available and, if
not, returns false rather than trying to replace the load."

Patch by Kenneth Uildriks!

llvm-svn: 84739
2009-10-21 04:11:19 +00:00
Devang Patel 1d7f7d21dc Do not remove dead metadata for now.
llvm-svn: 84731
2009-10-21 02:21:34 +00:00
Chris Lattner 7f903681ac alternate fix for PR5258 which avoids worklist problems, with reduced testcase.
llvm-svn: 84667
2009-10-20 20:27:49 +00:00
Dan Gohman b6b8ec769c Restore LoopUnswitch's block-oriented threshold. LoopUnswitch now checks both
the estimated code size and the number of blocks when deciding whether to
do a non-trivial unswitch. This protects it from some very undesirable
worst-case behavior on large numbers of loop-unswitchable conditions, such
as in the testcase in PR5259.

llvm-svn: 84661
2009-10-20 20:06:09 +00:00
Torok Edwin cf10ec951d Fix PR5258, jump-threading creating invalid PHIs.
When an incoming value for a PHI is updated, we must also updated all other
incoming values for the same BB to match, otherwise we create invalid PHIs.

llvm-svn: 84638
2009-10-20 15:42:00 +00:00
Torok Edwin 729d92bd74 Fix PR4313: IPSCCP was not setting the lattice value for the invoke instruction
when the invoke had multiple return values: it set the lattice value only on the
extractvalue.
This caused the invoke's lattice value to remain the default (undefined), and
later propagated to extractvalue's operand, which incorrectly introduces
undefined behavior.

llvm-svn: 84637
2009-10-20 15:15:09 +00:00
Owen Anderson 168ad6985e Refactor lookup_or_add to contain _MUCH_ less duplicated code. Add support for
numbering first class aggregate instructions while we're at it.

llvm-svn: 84547
2009-10-19 22:14:22 +00:00
Victor Hernandez 5c704d505c Malloc calls are marked NoAlias, so the code below the isMalloc() check makes it redundant. Removing the isMalloc() check.
llvm-svn: 84541
2009-10-19 21:47:22 +00:00
Owen Anderson 1059b5b32d Simplify some code.
llvm-svn: 84533
2009-10-19 21:14:57 +00:00
Dan Gohman 8f986672a1 Fix SplitBlockPredecessors' LoopInfo updating code to handle the case
where a loop's header is being split and it has predecessors which are not
contained by the most-nested loop which contains the loop.
This fixes PR5235.

llvm-svn: 84505
2009-10-19 16:04:50 +00:00
Dan Gohman 511d2e26dd Change instnamer to name arguments "arg" instead of "tmp" for clarity, and
to name basic blocks "bb" instead of "BB", for consistency.

llvm-svn: 84502
2009-10-19 14:47:32 +00:00
Chris Lattner 1fa98f0d74 remove the IndMemRemPass, which only made sense for when malloc/free were intrinsic
instructions.

llvm-svn: 84404
2009-10-18 05:02:09 +00:00
Daniel Dunbar 8eff29d805 Use raw_ostream::write_escaped instead of EscapeString.
llvm-svn: 84356
2009-10-17 20:43:19 +00:00
Chris Lattner 88b36f1140 Simplify some code (first hunk) and fix PR5208 (second hunk) by
updating the callgraph when introducing a call.

llvm-svn: 84310
2009-10-17 05:39:39 +00:00
Victor Hernandez a3aaf85e23 Remove MallocInst from LLVM Instructions.
llvm-svn: 84299
2009-10-17 01:18:07 +00:00
Victor Hernandez c7d6a8327c Autoupgrade malloc insts to malloc calls.
Update testcases that rely on malloc insts being present.

Also prematurely remove MallocInst handling from IndMemRemoval and RaiseAllocations to help pass tests in this incremental step.

llvm-svn: 84292
2009-10-17 00:00:19 +00:00
Victor Hernandez 264da3274e HeapAllocSRoA also needs to check if malloc array size can be computed.
llvm-svn: 84288
2009-10-16 23:12:25 +00:00
Dan Gohman 99429a00ff Move zext and sext casts fed by loads into the same block as the
load, to help SelectionDAG fold them into the loads, unless
conditions are unfavorable.

llvm-svn: 84271
2009-10-16 20:59:35 +00:00
Duncan Sands 0058c7bcb0 Strip trailing white space.
llvm-svn: 84256
2009-10-16 15:20:13 +00:00
Victor Hernandez 13020b1faf Fix bug where array malloc with unexpected computation of the size argument resulted in MallocHelper
identifying the malloc as a non-array malloc.  This broke GlobalOpt's optimization of stores of mallocs 
to global variables.

The fix is to classify malloc's into 3 categories:
1. non-array mallocs
2. array mallocs whose array size can be determined
3. mallocs that cannot be determined to be of type 1 or 2 and cannot be optimized

getMallocArraySize() returns NULL for category 3, and all users of this function must avoid their 
malloc optimization if this function returns NULL.

Eventually, currently unexpected codegen for computing the malloc's size argument will be supported in
isArrayMalloc() and getMallocArraySize(), extending malloc optimizations to those examples.

llvm-svn: 84199
2009-10-15 20:14:52 +00:00
Chris Lattner c855b45b78 only try to fold constantexpr operands when the worklist is first populated,
don't bother every time going around the main worklist.  This speeds up a 
release-asserts opt -std-compile-opts on 403.gcc by about 4% (1.5s).  It
seems to speed up the most expensive instances of instcombine by ~10%.

llvm-svn: 84171
2009-10-15 04:59:28 +00:00
Chris Lattner dd1f68a10c don't bother calling ConstantFoldInstruction unless there is a use of the
instruction (which disqualifies stores, unreachable, etc) and at least the
first operand is a constant.  This filters out a lot of obvious cases that
can't be folded.  Also, switch the IRBuilder to a TargetFolder, which tries
harder.

llvm-svn: 84170
2009-10-15 04:13:44 +00:00
Devang Patel 92f8619923 Use isVoidTy()
llvm-svn: 84118
2009-10-14 17:29:00 +00:00
Chris Lattner 6b9044db01 make instcombine's instruction sinking more aggressive in the
presence of PHI nodes.

llvm-svn: 84103
2009-10-14 15:21:58 +00:00
Devang Patel a677136900 Check void type before using RAUWd.
llvm-svn: 84049
2009-10-13 22:56:32 +00:00
Devang Patel 115741ba79 Do not check use_empty() before replaceAllUsesWith(). This gives ValueHandles a chance to get properly updated.
llvm-svn: 84033
2009-10-13 21:41:20 +00:00
Dan Gohman 2dc6f8de03 Use the new CodeMetrics class to compute code size instead of
manually counting instructions.

llvm-svn: 84016
2009-10-13 20:12:23 +00:00
Ted Kremenek 113d959f1b Update CMake file.
llvm-svn: 84001
2009-10-13 18:48:07 +00:00
Dan Gohman 54463e837a Commit the removal of this file, which is now moved to lib/Analysis.
llvm-svn: 83999
2009-10-13 18:37:20 +00:00
Dan Gohman 4552e3cd73 Move the InlineCost code from Transforms/Utils to Analysis.
llvm-svn: 83998
2009-10-13 18:30:07 +00:00
Dan Gohman 5b3e05bcaa Start refactoring the inline cost estimation code so that it can be used
for purposes other than inlining.

llvm-svn: 83997
2009-10-13 18:24:11 +00:00
Chris Lattner 19788ca686 change simplifycfg to not duplicate 'unwind' instructions. Hopefully
this will increase the likelihood of common code getting sunk towards
the unwind.

llvm-svn: 83996
2009-10-13 18:13:05 +00:00
Dan Gohman 71ca652475 Make LoopUnswitch's cost estimation count Instructions, rather than
BasicBlocks, so that it doesn't blindly procede in the presence of
large individual BasicBlocks. This addresses a class of code-size
expansion problems.

llvm-svn: 83992
2009-10-13 17:50:43 +00:00
Evan Cheng f815861591 Make licm debug message readable.
llvm-svn: 83908
2009-10-12 22:25:23 +00:00
Dale Johannesen 4c9f0e8f53 Fix warning.
llvm-svn: 83870
2009-10-12 18:45:32 +00:00
Chris Lattner 8abd572dae populate instcombine's initial worklist more carefully, causing
it to visit instructions from the start of the function to the
end of the function in the first path.  This greatly speeds up
some pathological cases (e.g. PR5150).

Try #3, this time with some unneeded debug info stuff removed
which was causing dead pointers to be added to the worklist.

llvm-svn: 83818
2009-10-12 03:58:40 +00:00
Chris Lattner 8ce6b36c86 revert r83814 for now, it is making the llvm-gcc bootstrap unhappy.
llvm-svn: 83817
2009-10-11 23:56:08 +00:00
Chris Lattner 78d6310429 populate instcombine's initial worklist more carefully, causing
it to visit instructions from the start of the function to the
end of the function in the first path.  This greatly speeds up
some pathological cases (e.g. PR5150). 

llvm-svn: 83814
2009-10-11 23:17:43 +00:00
Chris Lattner 2c2deae5ac remove some harmful code that would turn an insertelement on an undef
into a shuffle even if it was used by another insertelement.  If the
visitation order of instcombine was wrong, this would turn a chain of
insertelements into a chain of shufflevectors, which was quite painful.

Since CollectShuffleElements handles these cases, the code can just
be nuked.

llvm-svn: 83810
2009-10-11 23:02:46 +00:00