summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/GlobalOpt.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Handle InvokeInst in EvaluateBlock. Don't try to support exceptions, it's justNick Lewycky2012-02-121-9/+14
| | | | | | that no optz'ns have run yet to convert invokes to calls. llvm-svn: 150326
* false is totally null!Nick Lewycky2012-02-121-1/+1
| | | | llvm-svn: 150324
* Remove redundant getAnalysis<> calls in GlobalOpt. Add a few Itanium ABI callsNick Lewycky2012-02-121-10/+8
| | | | | | to TargetLibraryInfo and use one of them in GlobalOpt. llvm-svn: 150323
* Pass TargetData and TargetLibraryInfo through to the constant folder. Fixes aNick Lewycky2012-02-121-25/+37
| | | | | | few fixme's when TLI was added. llvm-svn: 150322
* Fix function name in comment to match actual name. Fix comments that are usingNick Lewycky2012-02-121-15/+15
| | | | | | doxy-style on local variables to not do so. Fix one 80-col violation. llvm-svn: 150320
* Don't traverse the PHI nodes twice. No functionality change!Nick Lewycky2012-02-121-7/+6
| | | | llvm-svn: 150319
* Tweak comment readability and grammar.Benjamin Kramer2012-02-091-2/+2
| | | | llvm-svn: 150183
* GlobalOpt: Be more aggressive about elminating side-effect free static dtors.Benjamin Kramer2012-02-091-4/+5
| | | | | | | | | GlobalOpt runs early in the pipeline (before inlining) and complex class hierarchies often introduce bitcasts or GEPs which weren't optimized away. Teach it to ignore side-effect free instructions instead of depending on other passes to remove them. llvm-svn: 150174
* Split part of EvaluateFunction into a new EvaluateBlock method. No functionalityNick Lewycky2012-02-061-57/+95
| | | | | | change. llvm-svn: 149861
* Teach GlobalOpt to handle atomic accesses to globals.Nick Lewycky2012-02-051-13/+40
| | | | | | | | | | | | | | | | | | | * Most of the transforms come through intact by having each transformed load or store copy the ordering and synchronization scope of the original. * The transform that turns a global only accessed in main() into an alloca (since main is non-recursive) with a store of the initial value uses an unordered store, since it's guaranteed to be the first thing to happen in main. (Threads may have started before main (!) but they can't have the address of a function local before the point in the entry block we insert our code.) * The heap-SRoA transforms are disabled in the face of atomic operations. This can probably be improved; it seems odd to have atomic accesses to an alloca that doesn't have its address taken. AnalyzeGlobal keeps track of the strongest ordering found in any use of the global. This is more information than we need right now, but it's cheap to compute and likely to be useful. llvm-svn: 149847
* Clean up some whitespace and comments. No functionality change.Nick Lewycky2012-02-051-13/+13
| | | | llvm-svn: 149845
* SwitchInst refactoring.Stepan Dyatkovskiy2012-02-011-1/+2
| | | | | | | | | | | | | | | | | The purpose of refactoring is to hide operand roles from SwitchInst user (programmer). If you want to play with operands directly, probably you will need lower level methods than SwitchInst ones (TerminatorInst or may be User). After this patch we can reorganize SwitchInst operands and successors as we want. What was done: 1. Changed semantics of index inside the getCaseValue method: getCaseValue(0) means "get first case", not a condition. Use getCondition() if you want to resolve the condition. I propose don't mix SwitchInst case indexing with low level indexing (TI successors indexing, User's operands indexing), since it may be dangerous. 2. By the same reason findCaseValue(ConstantInt*) returns actual number of case value. 0 means first case, not default. If there is no case with given value, ErrorIndex will returned. 3. Added getCaseSuccessor method. I propose to avoid usage of TerminatorInst::getSuccessor if you want to resolve case successor BB. Use getCaseSuccessor instead, since internal SwitchInst organization of operands/successors is hidden and may be changed in any moment. 4. Added resolveSuccessorIndex and resolveCaseIndex. The main purpose of these methods is to see how case successors are really mapped in TerminatorInst. 4.1 "resolveSuccessorIndex" was created if you need to level down from SwitchInst to TerminatorInst. It returns TerminatorInst's successor index for given case successor. 4.2 "resolveCaseIndex" converts low level successors index to case index that curresponds to the given successor. Note: There are also related compatability fix patches for dragonegg, klee, llvm-gcc-4.0, llvm-gcc-4.2, safecode, clang. llvm-svn: 149481
* continue making the world safe for ConstantDataVector. At this point,Chris Lattner2012-01-271-1/+1
| | | | | | | we should (theoretically optimize and codegen ConstantDataVector as well as ConstantVector. llvm-svn: 149116
* Continue improving support for ConstantDataAggregate, and use theChris Lattner2012-01-261-28/+5
| | | | | | new methods recently added to (sometimes greatly!) simplify code. llvm-svn: 149024
* use Constant::getAggregateElement to simplify a bunch of code.Chris Lattner2012-01-251-36/+2
| | | | llvm-svn: 148934
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-1/+0
| | | | llvm-svn: 148578
* PR11705, part 2: globalopt shouldn't put inttoptr/ptrtoint operations into ↵Eli Friedman2012-01-051-10/+20
| | | | | | global initializers if there's an implied extension or truncation. llvm-svn: 147625
* Fix a few more places where TargetData/TargetLibraryInfo is not being passed.Chad Rosier2011-12-021-2/+5
| | | | | | Add FIXMEs to places that are non-trivial to fix. llvm-svn: 145661
* Last bit of TargetLibraryInfo propagation. Also fixed a case for TargetDataChad Rosier2011-12-011-9/+17
| | | | | | | where it appeared beneficial to pass. More of rdar://10500969 llvm-svn: 145630
* Refactor code from inlining and globalopt that checks whether a function ↵Eli Friedman2011-10-201-1/+1
| | | | | | definition is unused, and enhance it so it can tell that functions which are only used by a blockaddress are in fact dead. This probably doesn't happen much on most code, but the Linux kernel's _THIS_IP_ can trigger this issue with blockaddress. (GlobalDCE can also handle the given tescase, but we only run that at -O3.) Found while looking at PR11180. llvm-svn: 142572
* Stop emitting instructions with the name "tmp" they eat up memory and have ↵Benjamin Kramer2011-09-271-2/+1
| | | | | | | | to be uniqued, without any benefit. If someone prefers %tmp42 to %42, run instnamer. llvm-svn: 140634
* Minor comment fixes.Eli Friedman2011-08-161-4/+6
| | | | llvm-svn: 137693
* Update inter-procedural optimizations for atomic load/store.Eli Friedman2011-08-151-4/+4
| | | | llvm-svn: 137667
* Add the 'resume' instruction for the new EH rewrite.Bill Wendling2011-07-311-1/+1
| | | | | | | | | This adds the 'resume' instruction class, IR parsing, and bitcode reading and writing. The 'resume' instruction resumes propagation of an existing (in-flight) exception whose unwinding was interrupted with a 'landingpad' instruction (to be added later). llvm-svn: 136589
* Revert r136253, r136263, r136269, r136313, r136325, r136326, r136329, r136338,Bill Wendling2011-07-301-1/+1
| | | | | | | r136339, r136341, r136369, r136387, r136392, r136396, r136429, r136430, r136444, r136445, r136446, r136253 pending review. llvm-svn: 136556
* Merge the contents from exception-handling-rewrite to the mainline.Bill Wendling2011-07-271-1/+1
| | | | | | This adds the new instructions 'landingpad' and 'resume'. llvm-svn: 136253
* Convert GetElementPtrInst to use ArrayRef.Jay Foad2011-07-251-3/+2
| | | | llvm-svn: 135904
* Fix more MSVC warnings caused by a cases I missed when convertingJay Foad2011-07-221-1/+1
| | | | | | ConstantExpr::getGetElementPtr to use ArrayRef. llvm-svn: 135762
* Make better use of ConstantExpr::getGetElementPtr's InBounds parameter.Jay Foad2011-07-211-3/+3
| | | | llvm-svn: 135676
* Convert ConstantExpr::getGetElementPtr andJay Foad2011-07-211-6/+4
| | | | | | ConstantExpr::getInBoundsGetElementPtr to use ArrayRef. llvm-svn: 135673
* move tier out of an anonymous namespace, it doesn't make senseChris Lattner2011-07-211-5/+3
| | | | | | | | to for it to be an an anon namespace and be in a header. Eliminate some extraenous uses of tie. llvm-svn: 135669
* Use ArrayRef in ConstantFoldInstOperands and ConstantFoldCall.Jay Foad2011-07-191-2/+1
| | | | llvm-svn: 135477
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-181-40/+40
| | | | llvm-svn: 135375
* Revamp the "ConstantStruct::get" methods. Previously, these were scatteredChris Lattner2011-06-201-39/+39
| | | | | | | | | | | | | | | all over the place in different styles and variants. Standardize on two preferred entrypoints: one that takes a StructType and ArrayRef, and one that takes StructType and varargs. In cases where there isn't a struct type convenient, we now add a ConstantStruct::getAnon method (whose name will make more sense after a few more patches land). It would be "really really nice" if the ConstantStruct::get and ConstantVector::get methods didn't make temporary std::vectors. llvm-svn: 133412
* Don't crash owhen ComputeLoadResult can't compute the result of the load.Nick Lewycky2011-05-291-1/+1
| | | | llvm-svn: 132290
* Obey the isVolatile bit on memory intrinsics when analyzing uses of a globalNick Lewycky2011-05-291-5/+19
| | | | | | | | | variable. Noticed by inspection. Simulate memset in EvaluateFunction where the target of the memset and the value we're setting are both the null value. Fixes PR10047! llvm-svn: 132288
* fix PR9856, an incorrectly conservative assertion: a global can beChris Lattner2011-05-221-3/+3
| | | | | | "stored once" even if its address is compared. llvm-svn: 131849
* Just because a GlobalVariable's initializer is [N x { i32, void ()* }] doesn'tNick Lewycky2011-04-111-7/+10
| | | | | | | | | | | | mean that it has to be ConstantArray of ConstantStruct. We might have ConstantAggregateZero, at either level, so don't crash on that. Also, semi-deprecate the sentinal value. The linker isn't aware of sentinals so we end up with the two lists appended, each with their "sentinals" on them. Different parts of LLVM treated sentinals differently, so make them all just ignore the single entry and continue on with the rest of the list. llvm-svn: 129307
* Don't include Operator.h from InstrTypes.h.Jay Foad2011-04-111-0/+1
| | | | llvm-svn: 129271
* Add back a couple checks removed by r129128; the fact that an intitializerEli Friedman2011-04-091-4/+6
| | | | | | | is an array of structures doesn't imply it's a ConstantArray of ConstantStruct. llvm-svn: 129207
* llvm.global_[cd]tor is defined to be either external, or appending with an arrayNick Lewycky2011-04-081-20/+5
| | | | | | | of { i32, void ()* }. Teach the verifier to verify that, deleting copies of checks strewn about. llvm-svn: 129128
* Remove PHINode::reserveOperandSpace(). Instead, add a parameter toJay Foad2011-03-301-1/+1
| | | | | | PHINode::Create() giving the (known or expected) number of operands. llvm-svn: 128537
* (Almost) always call reserveOperandSpace() on newly created PHINodes.Jay Foad2011-03-301-1/+3
| | | | llvm-svn: 128535
* Handle another case that Frits suggested.Anders Carlsson2011-03-221-2/+4
| | | | llvm-svn: 128068
* More cleanups to the OptimizeEmptyGlobalCXXDtors GlobalOpt function.Anders Carlsson2011-03-211-15/+9
| | | | llvm-svn: 127997
* As suggested by Nick Lewycky, ignore debugging intrinsics when trying to ↵Anders Carlsson2011-03-211-0/+7
| | | | | | decide whether a destructor is empty or not. llvm-svn: 127985
* Fix commentsNick Lewycky2011-03-211-2/+2
| | | | llvm-svn: 127984
* Don't try to eliminate invokes to __cxa_atexit.Anders Carlsson2011-03-201-0/+6
| | | | llvm-svn: 127976
* Don't segfault on mutual recursion, as pointed out by Frits.Anders Carlsson2011-03-201-4/+6
| | | | llvm-svn: 127975
* Address comments from Frits van Bommel.Anders Carlsson2011-03-201-7/+16
| | | | llvm-svn: 127974
OpenPOWER on IntegriCloud