aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/GlobalMerge.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-01-27Make some headers self-contained, remove unused includes that violate layering.Benjamin Kramer1-1/+0
llvm-svn: 258937
2015-10-09CodeGen: Use range-based for in GlobalMerge, NFCDuncan P. N. Exon Smith1-16/+15
llvm-svn: 249876
2015-09-14[opaque pointer types] Switch a few cases of getElementType over, since I ↵David Blaikie1-5/+3
had them lying around anyway llvm-svn: 247610
2015-09-14Revert "[opaque pointer type] Pass GlobalAlias the actual pointer type ↵David Blaikie1-1/+2
rather than decomposing it into pointee type + address space" This was a flawed change - it just caused the getElementType call to be deferred until later, when we really need to remove it. Now that the IR for GlobalAliases has been updated, the root cause is addressed that way instead and this change is no longer needed (and in fact gets in the way - because we want to pass the pointee type directly down further). Follow up patches to push this through GlobalValue, bitcode format, etc, will come along soon. This reverts commit 236160. llvm-svn: 247585
2015-08-25Fix dropped conditional in cleanup in r245752David Blaikie1-3/+4
Code review feedback by Charlie Turner. llvm-svn: 245954
2015-08-21Range-for-ify some things in GlobalMergeDavid Blaikie1-19/+14
llvm-svn: 245752
2015-08-21[opaque pointer types] Fix a few easy places in GlobalMerge that were ↵David Blaikie1-10/+7
accessing value types through pointee types llvm-svn: 245746
2015-08-18use minSize wrapper; NFCISanjay Patel1-2/+1
These were missed when other uses were switched over: http://llvm.org/viewvc/llvm-project?view=revision&revision=243994 llvm-svn: 245311
2015-08-12[GlobalMerge] Only emit aliases for internal linkage variables for non-Mach-OJohn Brawn1-3/+10
On Mach-O emitting aliases for the variables that make up a MergedGlobals variable can cause problems when linking with dead stripping enabled so don't do that, except for external variables where we must emit an alias. llvm-svn: 244748
2015-08-11[GlobalMerge] Use private linkage for MergedGlobals variablesJohn Brawn1-25/+5
Other objects can never reference the MergedGlobals symbol so external linkage is never needed. Using private instead of internal linkage means the object is more similar to what it looks like when global merging is not enabled, with the only difference being that the merged variables are addressed indirectly relative to the start of the section they are in. Also add aliases for merged variables with internal linkage, as this also makes the object be more like what it is when they are not merged. Differential Revision: http://reviews.llvm.org/D11942 llvm-svn: 244615
2015-08-08Fix some comment typos.Benjamin Kramer1-1/+1
llvm-svn: 244402
2015-08-03[GlobalMerge] Allow targets to enable merging of extern variables, NFC.John Brawn1-8/+15
Adjust the GlobalMergeOnExternal option so that the default behaviour is to do whatever the Target thinks is best. Explicitly enabled or disabling the option will override this default. Differential Revision: http://reviews.llvm.org/D10965 llvm-svn: 243873
2015-07-07Redirect DataLayout from TargetMachine to Module in GlobalMergeMehdi Amini1-13/+16
Summary: This change is part of a series of commits dedicated to have a single DataLayout during compilation by using always the one owned by the module. Reviewers: echristo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10987 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 241615
2015-06-08Fix assertion failure in global-merge with unused ConstantExprOliver Stannard1-0/+2
The global-merge pass was crashing because it assumes that all ConstantExprs (reached via the global variables that they use) have at least one user. I haven't worked out a way to test this, as an unused ConstantExpr cannot be represented by serialised IR, and global-merge can only be run in llc, which does not run any passes which can make a ConstantExpr dead. This (reduced to the point of silliness) C code triggers this bug when compiled for arm-none-eabi at -O1: static a = 7; static volatile b[10] = {&a}; c; main() { c = 0; for (; c < 10;) printf(b[c]); } Differential Revision: http://reviews.llvm.org/D10314 llvm-svn: 239308
2015-06-04[GlobalMerge] Take into account minsize on Global users' parents.Ahmed Bougacha1-4/+18
Now that we can look at users, we can trivially do this: when we would have otherwise disabled GlobalMerge (currently -O<3), we can just run it for minsize functions, as it's usually a codesize win. Differential Revision: http://reviews.llvm.org/D10054 llvm-svn: 239087
2015-04-29[opaque pointer type] Pass GlobalAlias the actual pointer type rather than ↵David Blaikie1-2/+1
decomposing it into pointee type + address space Many of the callers already have the pointer type anyway, and for the couple of callers that don't it's pretty easy to call PointerType::get on the pointee type and address space. This avoids LLParser from using PointerType::getElementType when parsing GlobalAliases from IR. llvm-svn: 236160
2015-04-18[GlobalMerge] Look at uses to create smaller global sets.Ahmed Bougacha1-12/+240
Instead of merging everything together, look at the users of GlobalVariables, and try to group them by function, to create sets of globals used "together". Using that information, a less-aggressive alternative is to keep merging everything together *except* globals that are only ever used alone, that is, those for which it's clearly non-profitable to merge with others. In my testing, grouping by Function is too aggressive, but grouping by BasicBlock is too conservative. Anything in-between isn't trivially available, so stick with Function grouping for now. cl::opts are added for testing; both enabled by default. A few of the testcases aren't testing the merging proper, but just various edge cases when merging does occur. Update them to use the previous grouping behavior. Also, one of the tests is unrelated to GlobalMerge; change it accordingly. While there, switch to r234666' flags rather than the brutal -O3. Differential Revision: http://reviews.llvm.org/D8070 llvm-svn: 235249
2015-04-11[CodeGen] Split -enable-global-merge into ARM and AArch64 options.Ahmed Bougacha1-1/+2
Currently, there's a single flag, checked by the pass itself. It can't force-enable the pass (and is on by default), because it might not even have been created, as that's the targets decision. Instead, have separate explicit flags, so that the decision is consistently made in the target. Keep the flag as a last-resort "force-disable GlobalMerge" for now, for backwards compatibility. llvm-svn: 234666
2015-04-02[opaque pointer type] API migration for GEP constant factoriesDavid Blaikie1-1/+2
Require the pointee type to be passed explicitly and assert that it is correct. For now it's possible to pass nullptr here (and I've done so in a few places in this patch) but eventually that will be disallowed once all clients have been updated or removed. It'll be a long road to get all the way there... but if you have the cahnce to update your callers to pass the type explicitly without depending on a pointer's element type, that would be a good thing to do soon and a necessary thing to do eventually. llvm-svn: 233938
2015-02-23Rewrite the global merge pass to be subprogram agnostic for now.Eric Christopher1-19/+18
It was previously using the subtarget to get values for the global offset without actually checking each function as it was generating code. Go ahead and solidify the current behavior and make the existing FIXMEs more prominent. As a note the ARM backend previously had a thumb1 and non-thumb1 set of defaults. Only the former was tested so I've changed the behavior to only use that for now. llvm-svn: 230245
2015-02-20Grab the DataLayout off of the TargetMachine since that's whereEric Christopher1-2/+2
it's stored. llvm-svn: 230059
2015-01-14[cleanup] Re-sort all the #include lines in LLVM usingChandler Carruth1-1/+1
utils/sort_includes.py. I clearly haven't done this in a while, so more changed than usual. This even uncovered a missing include from the InstrProf library that I've added. No functionality changed here, just mechanical cleanup of the include order. llvm-svn: 225974
2014-08-04Remove the TargetMachine forwards for TargetSubtargetInfo basedEric Christopher1-2/+3
information and update all callers. No functional change. llvm-svn: 214781
2014-07-08Fix some Twine locals.Benjamin Kramer1-9/+7
Two of those are use after frees. Found by clang-tidy, fixed by me. llvm-svn: 212537
2014-06-13Move GlobalMerge from Transform to CodeGen.Jiangning Liu1-0/+363
This patch is to move GlobalMerge pass from Transform/Scalar to CodeGen, because GlobalMerge depends on TargetMachine. In the mean time, the macro INITIALIZE_TM_PASS is also moved to CodeGen/Passes.h. With this fix we can avoid making libScalarOpts depend on libCodeGen. llvm-svn: 210951