Chandler Carruth
b3e8e6f10b
Reformat the implementation of mem2reg with clang-format so that my
...
subsequent changes don't introduce inconsistencies.
llvm-svn: 186775
2013-07-20 23:20:08 +00:00
Chandler Carruth
985eb0b550
Remove a DenseMapInfo specialization for std::pair -- we have one of
...
those baked into DenseMap now.
llvm-svn: 186773
2013-07-20 23:09:05 +00:00
Chandler Carruth
019516109d
Update mem2reg's comments to conform to the new doxygen standards. No
...
functionality changed.
llvm-svn: 186772
2013-07-20 22:20:05 +00:00
Craig Topper
af0dea1347
Use SmallVectorImpl::iterator/const_iterator instead of SmallVector to avoid specifying the vector size.
...
llvm-svn: 185606
2013-07-04 01:31:24 +00:00
Chandler Carruth
9fb823bbd4
Move all of the header files which are involved in modelling the LLVM IR
...
into their new header subdirectory: include/llvm/IR. This matches the
directory structure of lib, and begins to correct a long standing point
of file layout clutter in LLVM.
There are still more header files to move here, but I wanted to handle
them in separate commits to make tracking what files make sense at each
layer easier.
The only really questionable files here are the target intrinsic
tablegen files. But that's a battle I'd rather not fight today.
I've updated both CMake and Makefile build systems (I think, and my
tests think, but I may have missed something).
I've also re-sorted the includes throughout the project. I'll be
committing updates to Clang, DragonEgg, and Polly momentarily.
llvm-svn: 171366
2013-01-02 11:36:10 +00:00
Chandler Carruth
ed0881b2a6
Use the new script to sort the includes of every file under lib.
...
Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.
Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]
llvm-svn: 169131
2012-12-03 16:50:05 +00:00
Julien Lerouge
a302b6d95e
Fix typo.
...
llvm-svn: 166456
2012-10-23 00:38:15 +00:00
Julien Lerouge
d7fa5e420d
Explain why DenseMap is still used here instead of MapVector.
...
llvm-svn: 166454
2012-10-23 00:23:46 +00:00
Julien Lerouge
8cf84fa4e2
Iterating over a DenseMap<std::pair<BasicBlock*, unsigned>, PHINode*> is not
...
deterministic, replace it with a DenseMap<std::pair<unsigned, unsigned>,
PHINode*> (we already have a map from BasicBlock to unsigned).
<rdar://problem/12541389>
llvm-svn: 166435
2012-10-22 19:43:56 +00:00
Bill Wendling
f799efdedc
The DIBuilder class is just a wrapper around debug info creation
...
(a.k.a. MDNodes). The module doesn't belong in Analysis. Move it to the VMCore
instead.
llvm-svn: 159414
2012-06-29 08:32:07 +00:00
Bill Wendling
e38859dc8e
Move lib/Analysis/DebugInfo.cpp to lib/VMCore/DebugInfo.cpp and
...
include/llvm/Analysis/DebugInfo.h to include/llvm/DebugInfo.h.
The reasoning is because the DebugInfo module is simply an interface to the
debug info MDNodes and has nothing to do with analysis.
llvm-svn: 159312
2012-06-28 00:05:13 +00:00
Chandler Carruth
d95357a18e
Switch mem2reg to use the new hashing infrastructure.
...
llvm-svn: 152026
2012-03-05 11:29:56 +00:00
Chad Rosier
47eeddde24
Fix 80-column violation.
...
llvm-svn: 150998
2012-02-20 23:13:17 +00:00
Chad Rosier
c24b86ffbe
Propagate TargetLibraryInfo throughout ConstantFolding.cpp and
...
InstructionSimplify.cpp. Other fixups as needed.
Part of rdar://10500969
llvm-svn: 145559
2011-12-01 03:08:23 +00:00
Eli Friedman
01a67111d1
Add comments and test for atomic load/store and mem2reg.
...
llvm-svn: 137690
2011-08-15 23:55:52 +00:00
Nick Lewycky
3e334a42d7
Move onlyUsedByLifetimeMarkers to ValueTracking so that it can be used by other
...
passes as well.
llvm-svn: 133904
2011-06-27 04:20:45 +00:00
Nick Lewycky
e11f467dda
When promoting an alloca to registers discard any lifetime intrinsics.
...
llvm-svn: 133251
2011-06-17 10:09:00 +00:00
Cameron Zwarich
843bc7d673
Make LoadAndStorePromoter preserve debug info and create llvm.dbg.values when
...
promoting allocas to SSA variables. Fixes <rdar://problem/9479036>.
llvm-svn: 131953
2011-05-24 03:10:43 +00:00
Jay Foad
1a180156b6
Remove unused STL header includes.
...
llvm-svn: 130068
2011-04-23 19:53:52 +00:00
Jay Foad
5514afe6b2
PR9214: Convert Metadata API to use ArrayRef.
...
llvm-svn: 129932
2011-04-21 19:59:31 +00:00
Jay Foad
52131344a2
Remove PHINode::reserveOperandSpace(). Instead, add a parameter to
...
PHINode::Create() giving the (known or expected) number of operands.
llvm-svn: 128537
2011-03-30 11:28:46 +00:00
Devang Patel
8c0b16b0aa
Refactor into a separate utility function.
...
llvm-svn: 127832
2011-03-17 21:58:19 +00:00
Devang Patel
cedf928743
Do not use DIFactory. Use DIBuilder.
...
llvm-svn: 126398
2011-02-24 18:49:55 +00:00
Cameron Zwarich
07d6fe34b3
Convert two std::vectors to SmallVectors for a 3.4% speedup running -scalarrepl
...
on test-suite + SPEC2000 & SPEC2006.
llvm-svn: 124068
2011-01-23 08:03:04 +00:00
Cameron Zwarich
fc210c79b7
Convert a std::map to a DenseMap for another 1.7% speedup on -scalarrepl.
...
llvm-svn: 123732
2011-01-18 04:50:38 +00:00
Cameron Zwarich
6968c41ac8
Make a std::vector a SmallVector<*, 32> like the other vectors in the same
...
function. This seems to be about a 1.5% speedup of -scalarrepl on test-suite
with SPEC2000 and SPEC2006.
llvm-svn: 123731
2011-01-18 04:41:32 +00:00
Cameron Zwarich
4694e69540
Remove outdated references to dominance frontiers.
...
llvm-svn: 123724
2011-01-18 03:53:26 +00:00
Cameron Zwarich
b410858a5f
Roll r123609 back in with two changes that fix test failures with expensive
...
checks enabled:
1) Use '<' to compare integers in a comparison function rather than '<='.
2) Use the uniqued set DefBlocks rather than Info.DefiningBlocks to initialize
the priority queue.
The speedup of scalarrepl on test-suite + SPEC2000 + SPEC2006 is a bit less, at
just under 16% rather than 17%.
llvm-svn: 123662
2011-01-17 17:38:41 +00:00
Cameron Zwarich
67431d7943
Roll out r123609 due to failures on the llvm-x86_64-linux-checks bot.
...
llvm-svn: 123618
2011-01-17 07:26:51 +00:00
Cameron Zwarich
814cd9233e
Eliminate the use of dominance frontiers in PromoteMemToReg. In addition to
...
eliminating a potentially quadratic data structure, this also gives a 17%
speedup when running -scalarrepl on test-suite + SPEC2000 + SPEC2006. My initial
experiment gave a greater speedup around 25%, but I moved the dominator tree
level computation from dominator tree construction to PromoteMemToReg.
Since this approach to computing IDFs has a much lower overhead than the old
code using precomputed DFs, it is worth looking at using this new code for the
second scalarrepl pass as well.
llvm-svn: 123609
2011-01-17 01:08:59 +00:00
Chris Lattner
bf0aa927cc
split dom frontier handling stuff out to its own DominanceFrontier header,
...
so that Dominators.h is *just* domtree. Also prune #includes a bit.
llvm-svn: 122714
2011-01-02 22:09:33 +00:00
Duncan Sands
c6648eb4c3
Don't keep track of inserted phis in PromoteMemoryToRegister: the information
...
is never used. Patch by Cameron Zwarich.
llvm-svn: 119963
2010-11-22 09:41:24 +00:00
Duncan Sands
637049515f
Have a few places that want to simplify phi nodes use SimplifyInstruction
...
rather than calling hasConstantValue. No intended functionality change.
llvm-svn: 119352
2010-11-16 17:41:24 +00:00
Chris Lattner
b45de95345
remove some dead code.
...
llvm-svn: 111344
2010-08-18 02:41:56 +00:00
Dan Gohman
5c2e65b7bf
Don't look up the "dbg" metadata kind by name.
...
llvm-svn: 108961
2010-07-20 23:09:34 +00:00
Gabor Greif
a02f232c1b
cache result of operator*
...
llvm-svn: 107966
2010-07-09 14:18:23 +00:00
Dan Gohman
dd41bba517
Use A.append(...) instead of A.insert(A.end(), ...) when A is a
...
SmallVector, and other SmallVector simplifications.
llvm-svn: 106452
2010-06-21 19:47:52 +00:00
Devang Patel
36da24b546
Copy location info for current function argument from dbg.declare if respective store instruction does not have any location info.
...
llvm-svn: 105490
2010-06-04 22:27:30 +00:00
Devang Patel
3e0fbafab2
Fix typo.
...
llvm-svn: 104914
2010-05-28 01:29:50 +00:00
Devang Patel
e2099e8088
Fix typo.
...
llvm-svn: 104913
2010-05-28 01:17:51 +00:00
Devang Patel
7a9dedf0ab
Do not drop location info for inlined function args.
...
llvm-svn: 104884
2010-05-27 20:25:04 +00:00
Douglas Gregor
6739a89117
Fixes for Microsoft Visual Studio 2010, from Steven Watanabe!
...
llvm-svn: 103457
2010-05-11 06:17:44 +00:00
Devang Patel
32cc43c242
Wrap const MDNode * inside DIDescriptor.
...
llvm-svn: 103295
2010-05-07 20:54:48 +00:00
Devang Patel
4423abd734
Use overloaded operators instead of DIDescriptor::getNode()
...
llvm-svn: 103276
2010-05-07 18:19:32 +00:00
Gabor Greif
c78d720f02
rename use_const_iterator to const_use_iterator for consistency's sake
...
llvm-svn: 99564
2010-03-25 23:06:16 +00:00
Duncan Sands
19d0b47b1f
There are two ways of checking for a given type, for example isa<PointerType>(T)
...
and T->isPointerTy(). Convert most instances of the first form to the second form.
Requested by Chris.
llvm-svn: 96344
2010-02-16 11:11:14 +00:00
Victor Hernandez
006b53f199
mem2reg erases the dbg.declare intrinsics that it converts to dbg.val intrinsics
...
llvm-svn: 94763
2010-01-29 00:01:35 +00:00
Chris Lattner
65f4733b77
some cleanups.
...
llvm-svn: 94649
2010-01-27 02:12:20 +00:00
Chris Lattner
711e701f1c
no need to check for null
...
llvm-svn: 94648
2010-01-27 02:04:20 +00:00
Victor Hernandez
477d9274bb
When converting dbg.declare to dbg.value, attach promoted store's debug metadata to dbg.value
...
llvm-svn: 94634
2010-01-27 00:44:36 +00:00
Victor Hernandez
9ecd2f039f
Switch AllocaDbgDeclares to SmallVector and don't leak DIFactory
...
llvm-svn: 94567
2010-01-26 18:57:53 +00:00
Victor Hernandez
cd94410152
In mem2reg, for all alloca/stores that get promoted where the alloca has an associated llvm.dbg.declare instrinsic, insert an llvm.dbg.var intrinsic before each store.
...
llvm-svn: 94493
2010-01-26 02:42:15 +00:00
Victor Hernandez
8a588e1444
Revert r94260 until findDbgDeclare() is made more efficient
...
llvm-svn: 94432
2010-01-25 17:52:13 +00:00
Victor Hernandez
5006e43faf
In mem2reg, for all alloca/stores that get promoted where the alloca has an associated llvm.dbg.declare instrinsic, insert an llvm.dbg.var intrinsic before each store
...
llvm-svn: 94260
2010-01-23 00:17:34 +00:00
Victor Hernandez
5f8c8c034a
Keep ignoring pointer-to-pointer bitcasts
...
llvm-svn: 94194
2010-01-22 19:05:05 +00:00
Victor Hernandez
ae4d949721
DbgInfoIntrinsic no longer appear in an instruction's use list
...
llvm-svn: 94113
2010-01-21 23:08:36 +00:00
Dan Gohman
28943873e6
Use do+while instead of while for loops which obviously have a
...
non-zero trip count. Use SmallVector's pop_back_val().
llvm-svn: 92734
2010-01-05 16:27:25 +00:00
Chris Lattner
45d040bd85
Remove isPod() from DenseMapInfo, splitting it out to its own
...
isPodLike type trait. This is a generally useful type trait for
more than just DenseMap, and we really care about whether something
acts like a pod, not whether it really is a pod.
llvm-svn: 91421
2009-12-15 07:26:43 +00:00
Chandler Carruth
dcf5dacb2c
Don't leave pointers uninitialized in the default constructor. GCC complains
...
about the potential use of these uninitialized members under certain conditions.
llvm-svn: 91239
2009-12-13 07:04:45 +00:00
Nick Lewycky
15a1287c1f
Pull LLVMContext out of PromoteMemToReg.
...
llvm-svn: 89645
2009-11-23 03:50:44 +00:00
Chris Lattner
4e849162ef
fix a bug exposed by moving SRoA earlier which caused a crash building kc++
...
llvm-svn: 85786
2009-11-02 04:37:17 +00:00
Nick Lewycky
974e12b2d3
Remove includes of Support/Compiler.h that are no longer needed after the
...
VISIBILITY_HIDDEN removal.
llvm-svn: 85043
2009-10-25 06:57:41 +00:00
Nick Lewycky
02d5f77d26
Remove VISIBILITY_HIDDEN from class/struct found inside anonymous namespaces.
...
Chris claims we should never have visibility_hidden inside any .cpp file but
that's still not true even after this commit.
llvm-svn: 85042
2009-10-25 06:33:48 +00:00
Chris Lattner
e3ce1e2a37
tidy up
...
llvm-svn: 82488
2009-09-21 22:26:02 +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
Dan Gohman
a6d0afcb74
Fix a bunch of namespace pollution.
...
llvm-svn: 78363
2009-08-07 01:32:21 +00:00
Owen Anderson
b292b8ce70
Move more code back to 2.5 APIs.
...
llvm-svn: 77635
2009-07-30 23:03:37 +00:00
Daniel Dunbar
132f78395a
Twines: Don't allow implicit conversion from integers, this is too tricky.
...
llvm-svn: 77605
2009-07-30 17:37:43 +00:00
Daniel Dunbar
6afdc5e694
Switch obvious clients to Twine instead of utostr (when they were already using
...
a Twine, e.g., for names).
- I am a little ambivalent about this; we don't want the string conversion of
utostr, but using overload '+' mixed with string and integer arguments is
sketchy. On the other hand, this particular usage is something of an idiom.
llvm-svn: 77579
2009-07-30 04:20:37 +00:00
Owen Anderson
47db941fd3
Get rid of the Pass+Context magic.
...
llvm-svn: 76702
2009-07-22 00:24:57 +00:00
Owen Anderson
38264b1554
"LLVMContext* " --> "LLVMContext *"
...
llvm-svn: 74878
2009-07-06 23:00:19 +00:00
Owen Anderson
e70b637033
More LLVMContext-ification.
...
llvm-svn: 74807
2009-07-05 22:41:43 +00:00
Dan Gohman
9a6fef0a52
Simplify code by using SmallVector's pop_back_val() instead of
...
separate back() and pop_back() calls.
llvm-svn: 71089
2009-05-06 17:22:41 +00:00
Eli Friedman
929207fd1d
Fix for PR3944: make mem2reg O(N) instead of O(N^2) in the number of
...
incoming edges for a block with many predecessors.
llvm-svn: 69312
2009-04-16 21:40:28 +00:00
Dale Johannesen
073ab5acab
Tweak the check for promotable alloca's to handle
...
debug intrinsics correctly.
llvm-svn: 66225
2009-03-06 00:42:50 +00:00
Devang Patel
b63c74730c
Let AnalyzeAlloca() remove debug intrinsics.
...
llvm-svn: 59454
2008-11-17 18:37:53 +00:00
Daniel Dunbar
2b9dce2669
Rework r58829, allowing removal of dbg info intrinsics during alloca
...
promotion.
- Eliminate uses after free and simplify tests.
Devang: Please check that this is still doing what you intended.
llvm-svn: 58887
2008-11-08 04:12:17 +00:00
Bill Wendling
b9656df4ac
BCUI + 1 doesn't work. Use next instead.
...
llvm-svn: 58830
2008-11-07 01:59:41 +00:00
Devang Patel
b8e0d59ceb
Handle (delete) dbg intrinsics while promoting alloca.
...
llvm-svn: 58826
2008-11-07 01:30:07 +00:00
Chris Lattner
59b5691388
Rewrite all the 'PromoteLocallyUsedAlloca[s]' logic. With the power of
...
LargeBlockInfo, we can now dramatically simplify their implementation
and speed them up at the same time. Now the code has time proportional
to the number of uses of the alloca, not the size of the block.
This also eliminates code that tried to batch up different allocas which
are used in the same blocks, and eliminates the 'retry list' logic which
was baroque and no unneccesary. In addition to being a speedup for crazy
cases, this is also a nice cleanup:
PromoteMemoryToRegister.cpp | 270 +++++++++++++++-----------------------------
1 file changed, 96 insertions(+), 174 deletions(-)
llvm-svn: 58229
2008-10-27 07:05:53 +00:00
Chris Lattner
f594ecc453
Add a new LargeBlockInfo helper, which is just a wrapper around
...
a trivial dense map. Use this in RewriteSingleStoreAlloca to
avoid aggressively rescanning blocks over and over again. This
fixes PR2925, speeding up mem2reg on the testcase in that bug
from 4.56s to 0.02s in a debug build on my machine.
llvm-svn: 58227
2008-10-27 06:05:26 +00:00
Gabor Greif
e9ecc68d8f
API changes for class Use size reduction, wave 1.
...
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.
llvm-svn: 49277
2008-04-06 20:25:17 +00:00
Nick Lewycky
7698bfbe16
Update -mem2reg to use succ_iterator instead of iterating across TerminatorInst
...
successors. This makes it support nounwind.
llvm-svn: 48320
2008-03-13 02:42:41 +00:00
Chris Lattner
a838141957
Make RenamePass faster by making the 'is this a new phi node'
...
check more intelligent. This speeds up mem2reg from 5.29s to
0.79s on a synthetic testcase with tons of predecessors and
phi nodes.
llvm-svn: 46767
2008-02-05 21:26:23 +00:00
Chris Lattner
f3ebc3f3d2
Remove attribution from file headers, per discussion on llvmdev.
...
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Gordon Henriksen
d568767ecb
Finishing initial docs for all transformations in Passes.html.
...
Also cleaned up some comments in source files.
llvm-svn: 43674
2007-11-04 16:15:04 +00:00
Chris Lattner
0625bd6472
Merge DenseMapKeyInfo & DenseMapValueInfo into DenseMapInfo
...
Add a new DenseMapInfo::isEqual method to allow clients to redefine
the equality predicate used when probing the hash table.
llvm-svn: 42042
2007-09-17 18:34:04 +00:00
Anton Korobeynikov
24fb6b2f8c
Don't promote volatile loads/stores. This is needed (for example) to handle setjmp/longjmp properly.
...
This fixes PR1520.
llvm-svn: 41461
2007-08-26 21:43:30 +00:00
Chris Lattner
edce70d2fe
rewrite the code used to construct pruned SSA form with the IDF method.
...
In the old way, we computed and inserted phi nodes for the whole IDF of
the definitions of the alloca, then computed which ones were dead and
removed them.
In the new method, we first compute the region where the value is live,
and use that information to only insert phi nodes that are live. This
eliminates the need to compute liveness later, and stops the algorithm
from inserting a bunch of phis which it then later removes.
This speeds up the testcase in PR1432 from 2.00s to 0.15s (14x) in a
release build and 6.84s->0.50s (14x) in a debug build.
llvm-svn: 40825
2007-08-04 22:50:14 +00:00
Chris Lattner
d91576b01e
Factor out a whole bunch of code into it's own method.
...
llvm-svn: 40824
2007-08-04 21:14:29 +00:00
Chris Lattner
4e1b4140eb
Use getNumPreds(BB) instead of computing them manually. This is a very small but
...
measurable speedup.
llvm-svn: 40823
2007-08-04 21:06:15 +00:00
Chris Lattner
b6a4ba808b
Change the rename pass to be "tail recursive", only adding N-1 successors
...
to the worklist, and handling the last one with a 'tail call'. This speeds
up PR1432 from 2.0578s to 2.0012s (2.8%)
llvm-svn: 40822
2007-08-04 20:40:27 +00:00
Chris Lattner
840259c8d3
cache computation of #preds for a BB. This speeds up
...
mem2reg from 2.0742->2.0522s on PR1432.
llvm-svn: 40821
2007-08-04 20:24:50 +00:00
Chris Lattner
050bac4bed
reserve operand space for phi nodes when we insert them.
...
llvm-svn: 40820
2007-08-04 20:14:34 +00:00
Chris Lattner
9318785df5
use continue to avoid nesting, no functionality change.
...
llvm-svn: 40819
2007-08-04 20:07:06 +00:00
Chris Lattner
6b04ecbaf9
Promoting allocas with the 'single store' fastpath is
...
faster than with the 'local to a block' fastpath. This speeds
up PR1432 from 2.1232 to 2.0686s (2.6%)
llvm-svn: 40818
2007-08-04 20:03:23 +00:00
Chris Lattner
4a930f9444
When PromoteLocallyUsedAllocas promoted allocas, it didn't remember
...
to increment NumLocalPromoted, and didn't actually delete the
dead alloca, leading to an extra iteration of mem2reg.
llvm-svn: 40817
2007-08-04 20:01:43 +00:00
Chris Lattner
63c039780c
std::map -> DenseMap
...
llvm-svn: 40816
2007-08-04 19:52:20 +00:00
Chris Lattner
7d382f7680
fix a logic bug where we wouldn't promote single store allocas if the
...
stored value was a non-instruction value. Doh.
This increase the # single store allocas from 8982 to 9026, and
speeds up mem2reg on the testcase in PR1432 from 2.17 to 2.13s.
llvm-svn: 40813
2007-08-04 02:45:02 +00:00
Chris Lattner
1b215f0661
When we do the single-store optimization, delete both the store
...
and the alloca so they don't get reprocessed.
This speeds up PR1432 from 2.20s to 2.17s.
llvm-svn: 40812
2007-08-04 02:38:38 +00:00