summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/GlobalOpt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Use unique_ptr to handle GlobalOpt's Evaluator membersDavid Blaikie2014-04-211-17/+10
| | | | llvm-svn: 206790
* Simplify expression that was explicitly naming an operator overload in a call.David Blaikie2014-04-211-1/+1
| | | | llvm-svn: 206788
* Revert r204076 for now - it caused significant regressions in a number ofLang Hames2014-03-231-47/+78
| | | | | | | | benchmarks. <rdar://problem/16368461> llvm-svn: 204558
* Use range metadata instead of introducing selects.Dan Gohman2014-03-171-78/+47
| | | | | | | | | | | | | | | | When GlobalOpt has determined that a GlobalVariable only ever has two values, it would convert the GlobalVariable to a boolean, and introduce SelectInsts at every load, to choose between the two possible values. These SelectInsts introduce overhead and other unpleasantness. This patch makes GlobalOpt just add range metadata to loads from such GlobalVariables instead. This enables the same main optimization (as seen in test/Transforms/GlobalOpt/integer-bool.ll), without introducing selects. The main downside is that it doesn't get the memory savings of shrinking such GlobalVariables, but this is expected to be negligible. llvm-svn: 204076
* [C++11] Add range based accessors for the Use-Def chain of a Value.Chandler Carruth2014-03-091-67/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This requires a number of steps. 1) Move value_use_iterator into the Value class as an implementation detail 2) Change it to actually be a *Use* iterator rather than a *User* iterator. 3) Add an adaptor which is a User iterator that always looks through the Use to the User. 4) Wrap these in Value::use_iterator and Value::user_iterator typedefs. 5) Add the range adaptors as Value::uses() and Value::users(). 6) Update *all* of the callers to correctly distinguish between whether they wanted a use_iterator (and to explicitly dig out the User when needed), or a user_iterator which makes the Use itself totally opaque. Because #6 requires churning essentially everything that walked the Use-Def chains, I went ahead and added all of the range adaptors and switched them to range-based loops where appropriate. Also because the renaming requires at least churning every line of code, it didn't make any sense to split these up into multiple commits -- all of which would touch all of the same lies of code. The result is still not quite optimal. The Value::use_iterator is a nice regular iterator, but Value::user_iterator is an iterator over User*s rather than over the User objects themselves. As a consequence, it fits a bit awkwardly into the range-based world and it has the weird extra-dereferencing 'operator->' that so many of our iterators have. I think this could be fixed by providing something which transforms a range of T&s into a range of T*s, but that *can* be separated into another patch, and it isn't yet 100% clear whether this is the right move. However, this change gets us most of the benefit and cleans up a substantial amount of code around Use and User. =] llvm-svn: 203364
* [C++11] Revert uses of lambdas with array_pod_sort.Benjamin Kramer2014-03-071-4/+5
| | | | | | Looks like GCC implements the lambda->function pointer conversion differently. llvm-svn: 203294
* [C++11] Convert sort predicates into lambdas.Benjamin Kramer2014-03-071-5/+4
| | | | | | No functionality change. llvm-svn: 203288
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-051-2/+2
| | | | | | class. llvm-svn: 202953
* [Modules] Move ValueHandle into the IR library where Value itself lives.Chandler Carruth2014-03-041-1/+1
| | | | | | | | | | | Move the test for this class into the IR unittests as well. This uncovers that ValueMap too is in the IR library. Ironically, the unittest for ValueMap is useless in the Support library (honestly, so was the ValueHandle test) and so it already lives in the IR unittests. Mmmm, tasty layering. llvm-svn: 202821
* [Modules] Move CallSite into the IR library where it belogs. It isChandler Carruth2014-03-041-1/+1
| | | | | | | abstracting between a CallInst and an InvokeInst, both of which are IR concepts. llvm-svn: 202816
* [Modules] Move GetElementPtrTypeIterator into the IR library. As itsChandler Carruth2014-03-041-1/+1
| | | | | | | | | name might indicate, it is an iterator over the types in an instruction in the IR.... You see where this is going. Another step of modularizing the support library. llvm-svn: 202815
* [C++11] Replace llvm::next and llvm::prior with std::next and std::prev.Benjamin Kramer2014-03-021-1/+1
| | | | | | Remove the old functions. llvm-svn: 202636
* Reflow isProfitableToMakeFastCCReid Kleckner2014-02-281-1/+2
| | | | llvm-svn: 202555
* GlobalOpt: Apply fastcc to internal x86_thiscallcc functionsReid Kleckner2014-02-261-5/+14
| | | | | | | | | | We should apply fastcc whenever profitable. We can expand this list, but there are lots of conventions with performance implications that we don't want to change. Differential Revision: http://llvm-reviews.chandlerc.com/D2705 llvm-svn: 202293
* Make DataLayout a plain object, not a pass.Rafael Espindola2014-02-251-3/+6
| | | | | | | Instead, have a DataLayoutPass that holds one. This will allow parts of LLVM don't don't handle passes to also use DataLayout. llvm-svn: 202168
* Make some DataLayout pointers const.Rafael Espindola2014-02-241-9/+11
| | | | | | No functionality change. Just reduces the noise of an upcoming patch. llvm-svn: 202087
* Rename many DataLayout variables from TD to DL.Rafael Espindola2014-02-211-68/+68
| | | | | | | | | I am really sorry for the noise, but the current state where some parts of the code use TD (from the old name: TargetData) and other parts use DL makes it hard to write a patch that changes where those variables come from and how they are passed along. llvm-svn: 201827
* GlobalOpt: Aliases don't have sections, don't copy them when replacingReid Kleckner2014-02-131-1/+2
| | | | | | | | | | | | | | | | | | | | | As defined in LangRef, aliases do not have sections. However, LLVM's GlobalAlias class inherits from GlobalValue, which means we can read and set its section. We should probably ban that as a separate change, since it doesn't make much sense for an alias to have a section that differs from its aliasee. Fixes PR18757, where the section was being lost on the global in code from Clang like: extern "C" { __attribute__((used, section("CUSTOM"))) static int in_custom_section; } Reviewers: rafael.espindola Differential Revision: http://llvm-reviews.chandlerc.com/D2758 llvm-svn: 201286
* Re-sort all of the includes with ./utils/sort_includes.py so thatChandler Carruth2014-01-071-1/+1
| | | | | | | | | | subsequent changes are easier to review. About to fix some layering issues, and wanted to separate out the necessary churn. Also comment and sink the include of "Windows.h" in three .inc files to match the usage in Memory.inc. llvm-svn: 198685
* Delete unread globals through addrspacecastMatt Arsenault2014-01-021-2/+3
| | | | llvm-svn: 198346
* Fix addrspacecast with metadata globalsMatt Arsenault2014-01-021-3/+5
| | | | llvm-svn: 198345
* Fix a use-after-free error in GlobalOpt CleanupConstantGlobalUsersHal Finkel2013-12-121-2/+11
| | | | | | | | | | | | GlobalOpt's CleanupConstantGlobalUsers function uses a worklist array to manage constant users to be visited. The pointers in this array need to be weak handles because when we delete a constant array, we may also be holding a pointer to one of its elements (or an element of one of its elements if we're dealing with an array of arrays) in the worklist. Fixes PR17347. llvm-svn: 197178
* Correct word hyphenationsAlp Toker2013-12-051-2/+2
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities and contractions in nearby lines. llvm-svn: 196471
* Remove dead codeShuxin Yang2013-11-041-6/+0
| | | | llvm-svn: 194017
* Revert r193251 : Use address-taken to disambiguate global variable and ↵Shuxin Yang2013-10-271-1/+0
| | | | | | indirect memops. llvm-svn: 193489
* Use address-taken to disambiguate global variable and indirect memops.Shuxin Yang2013-10-231-0/+1
| | | | | | | | | | Major steps include: 1). introduces a not-addr-taken bit-field in GlobalVariable 2). GlobalOpt pass sets "not-address-taken" if it proves a global varirable dosen't have its address taken. 3). AA use this info for disambiguation. llvm-svn: 193251
* Use more type helper functionsMatt Arsenault2013-10-211-4/+2
| | | | llvm-svn: 193109
* Optimize more linkonce_odr values during LTO.Rafael Espindola2013-10-211-208/+2
| | | | | | | | | | | When a linkonce_odr value that is on the dso list is not unnamed_addr we can still look to see if anything is actually using its address. If not, it is safe to hide it. This patch implements that by moving GlobalStatus to Transforms/Utils and using it in Internalize. llvm-svn: 193090
* Rename fields of GlobalStatus to match the coding style.Rafael Espindola2013-10-171-43/+41
| | | | llvm-svn: 192910
* rename SafeToDestroyConstant to isSafeToDestroyConstant and clang-format.Rafael Espindola2013-10-171-10/+12
| | | | llvm-svn: 192907
* Simplify the interface of AnalyzeGlobal a bit and rename to analyzeGlobal.Rafael Espindola2013-10-171-14/+22
| | | | | | No functionality change. llvm-svn: 192906
* Revert r191834 until we measure the effect of this benchmarks and maybe find ↵Alexey Samsonov2013-10-071-3/+56
| | | | | | a better way to fix it llvm-svn: 192121
* Remove "localize global" optimizationAlexey Samsonov2013-10-021-56/+3
| | | | | | | | | | | | | | | | Summary: As discussed in http://llvm-reviews.chandlerc.com/D1754, this optimization isn't really valid for C, and fires too rarely anyway. Reviewers: rafael, nicholas Reviewed By: nicholas CC: rnk, llvm-commits, nicholas Differential Revision: http://llvm-reviews.chandlerc.com/D1769 llvm-svn: 191834
* Provide basic type safety for array_pod_sort comparators.Benjamin Kramer2013-09-221-8/+2
| | | | | | | | This makes using array_pod_sort significantly safer. The implementation relies on function pointer casting but that should be safe as we're dealing with void* here. llvm-svn: 191175
* Use type form of getIntPtrTypeMatt Arsenault2013-09-111-2/+2
| | | | | | | This doesn't change anything since malloc always returns address space 0. llvm-svn: 190498
* Don't shrink atomic ops to bool in GlobalOpt.Eli Friedman2013-09-091-4/+7
| | | | | | | | | LLVM IR doesn't currently allow atomic bool load/store operations, and the transformation is dubious anyway because it isn't profitable on all platforms. PR17163. llvm-svn: 190357
* Remove unused argument.Rafael Espindola2013-09-051-3/+1
| | | | llvm-svn: 190090
* Revert "Add r159136 back now that pr13124 has been fixed."Rafael Espindola2013-09-041-11/+0
| | | | | | | | | | | | | | | | | | | This reverts commit r189886. I found a corner case where this optimization is not valid: Say we have a "linkonce_odr unnamed_addr" in two translation units: * In TU 1 this optimization kicks in and makes it hidden. * In TU 2 it gets const merged with a constant that is *not* unnamed_addr, resulting in a non unnamed_addr constant with default visibility. * The static linker rules for combining visibility them produce a hidden symbol, which is incorrect from the point of view of the non unnamed_addr constant. The one place we can do this is when we know that the symbol is not used from another TU in the same shared object, i.e., during LTO. I will move it there. llvm-svn: 189954
* Add r159136 back now that pr13124 has been fixed.Rafael Espindola2013-09-031-0/+11
| | | | | | | | | | Original message: If a constant or a function has linkonce_odr linkage and unnamed_addr, mark hidden. Being linkonce_odr guarantees that it is available in every dso that needs it. Being a constant/function with unnamed_addr guarantees that the copies don't have to be merged. llvm-svn: 189886
* Respect llvm.used in Internalize.Rafael Espindola2013-07-251-21/+3
| | | | | | | | | | | | | | | The language reference says that: "If a symbol appears in the @llvm.used list, then the compiler, assembler, and linker are required to treat the symbol as if there is a reference to the symbol that it cannot see" Since even the linker cannot see the reference, we must assume that the reference can be using the symbol table. For example, a user can add __attribute__((used)) to a debug helper function like dump and use it from a debugger. llvm-svn: 187103
* Check that TD isn't NULL before dereferencing it down this path.Nick Lewycky2013-07-251-1/+1
| | | | llvm-svn: 187099
* Make these methods const correct.Rafael Espindola2013-07-251-2/+2
| | | | | | Thanks to Nick Lewycky for noticing it. llvm-svn: 187098
* Don't crash when llvm.compiler.used becomes empty.Rafael Espindola2013-07-201-0/+5
| | | | | | | | GlobalOpt simplifies llvm.compiler.used by removing any members that are also in the more strict llvm.used. Handle the special case where llvm.compiler.used becomes empty. llvm-svn: 186778
* s/compiler_used/compiler.used/.Rafael Espindola2013-07-191-7/+7
| | | | | | | We were incorrectly using compiler_used instead of compiler.used. Unfortunately the passes using the broken name had tests also using the broken name. llvm-svn: 186705
* Fix commentEli Bendersky2013-07-081-3/+2
| | | | llvm-svn: 185888
* Always remove an alias when we rename the target.Rafael Espindola2013-06-121-3/+1
| | | | | | Should fix the dragonegg build bots. llvm-svn: 183845
* Change how globalopt handles aliases in llvm.used.Rafael Espindola2013-06-111-100/+156
| | | | | | | | | | | | | | | | | | | | | | | | Instead of a custom implementation of replaceAllUsesWith, we just call replaceAllUsesWith and recreate llvm.used and llvm.compiler-used. This change is particularity interesting because it makes llvm see through what clang is doing with static used functions in extern "C" contexts. With this change, running clang -O2 in extern "C" { __attribute__((used)) static void foo() {} } produces @llvm.used = appending global [1 x i8*] [i8* bitcast (void ()* @foo to i8*)], section "llvm.metadata" define internal void @foo() #0 { entry: ret void } llvm-svn: 183756
* GlobalOpt: fix an issue where CXAAtExitFn points to a deleted function.Manman Ren2013-05-141-3/+3
| | | | | | | | | | | CXAAtExitFn was set outside a loop and before optimizations where functions can be deleted. This patch will set CXAAtExitFn inside the loop and after optimizations. Seg fault when running LTO because of accesses to a deleted function. rdar://problem/13838828 llvm-svn: 181838
* Don't replace an alias in llvm.used with its target.Rafael Espindola2013-05-091-2/+102
| | | | | | | When we replace an internal alias with its target, be careful not to replace the entry in llvm.used (and llvm.compiler_used). llvm-svn: 181524
* Use a worklist to avoid a sneaky iterator invalidation.Bill Wendling2013-04-021-3/+3
| | | | | | | | | | | | | The iterator could be invalidated when it's recursively deleting a whole bunch of constant expressions in a constant initializer. Note: This was only reproducible if `opt' was run on a `.bc' file. If `opt' was run on a `.ll' file, it wouldn't crash. This is why the test first pushes the `.ll' file through `llvm-as' before feeding it to `opt'. PR15440 llvm-svn: 178531
OpenPOWER on IntegriCloud