aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/GlobalMerge.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-04-23Use llvm::stable_sortFangrui Song1-10/+10
While touching the code, simplify if feasible. llvm-svn: 358996
2019-04-04[IR] Refactor attribute methods in Function class (NFC)Evandro Menezes1-1/+1
Rename the functions that query the optimization kind attributes. Differential revision: https://reviews.llvm.org/D60287 llvm-svn: 357731
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-08-30[GlobalMerge] Fix GlobalMerge on bss external global variables.Huihui Zhang1-1/+1
Summary: Global variables that are external and zero initialized are supposed to be merged with global variables in the bss section rather than the data section. Reviewers: efriedma, rengolin, t.p.northover, javed.absar, asl, john.brawn, pcc Reviewed By: efriedma Subscribers: dmgreen, llvm-commits Differential Revision: https://reviews.llvm.org/D51379 llvm-svn: 341008
2018-08-29[NFC] Make getPreferredAlignment honor section markings.Eli Friedman1-10/+1
This should more accurately reflect what the AsmPrinter will actually do. This is NFC, as far as I can tell; all the places that might be affected already have an extra check to avoid using the result of getPreferredAlignment in this situation. Differential Revision: https://reviews.llvm.org/D51377 llvm-svn: 340999
2018-08-02[GlobalMerge] Allow merging globals with explicit section markings.Eli Friedman1-10/+22
At least on ELF, it's impossible to tell from the object file whether two globals with the same section marking were merged: the merged global uses "private" linkage to hide its symbol, and the aliases look like regular symbols. I can't think of any other reason to disallow it. (Of course, we can only merge globals in the same section.) The weird alignment handling matches AsmPrinter; our alignment handling for global variables should probably be refactored. Differential Revision: https://reviews.llvm.org/D49822 llvm-svn: 338791
2018-07-30Remove trailing spaceFangrui Song1-1/+1
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338293
2018-07-25[GlobalMerge] Handle llvm.compiler.used correctly.Eli Friedman1-4/+5
Reuse the handling for llvm.used, and don't transform such globals. Fixes a failure on the asan buildbot caused by my previous commit. llvm-svn: 337973
2018-07-25[GlobalMerge] Allow merging globals with arbitrary alignment.Eli Friedman1-18/+26
Instead of depending on implicit padding from the structure layout code, use a packed struct and emit the padding explicitly. Differential Revision: https://reviews.llvm.org/D49710 llvm-svn: 337961
2018-06-06[GlobalMerge] Set the alignment on merged global structsDavid Green1-0/+5
If no alignment is set, the abi/preferred alignment of structs will be used which may be higher than required. This can lead to extra padding and in the end an increase in data size. Differential Revision: https://reviews.llvm.org/D47633 llvm-svn: 334099
2018-05-19[GlobalMerge] Exit early if only one global is to be mergedHaicheng Wu1-1/+9
To save some compilation time and prevent some unnecessary changes. Differential Revision: https://reviews.llvm.org/D46640 llvm-svn: 332813
2018-05-14Rename DEBUG macro to LLVM_DEBUG.Nicola Zaghen1-2/+2
The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM - Manual change to APInt - Manually chage DOCS as regex doesn't match it. In the transition period the DEBUG() macro is still present and aliased to the LLVM_DEBUG() one. Differential Revision: https://reviews.llvm.org/D43624 llvm-svn: 332240
2018-05-01Remove \brief commands from doxygen comments.Adrian Prantl1-2/+2
We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46290 llvm-svn: 331272
2018-04-26[GlobalMerge] Fix a typoHaicheng Wu1-1/+1
now => know llvm-svn: 330965
2018-03-23Move TargetLoweringObjectFile from CodeGen to Target to fix layeringDavid Blaikie1-1/+1
It's implemented in Target & include from other Target headers, so the header should be in Target. llvm-svn: 328392
2018-02-12[GlobalMerge] Allow merging of dllexported variablesMartin Storsjo1-3/+6
If merging them, the dllexport attribute needs to be brought along to the new GlobalAlias. Differential Revision: https://reviews.llvm.org/D43192 llvm-svn: 324937
2018-01-24[GlobalMerge] Don't merge dllexport globalsMartin Storsjo1-1/+2
Merging such globals loses the dllexport attribute. Add a test to check that normal globals still are merged. Differential Revision: https://reviews.llvm.org/D42127 llvm-svn: 323307
2017-11-17Fix a bunch more layering of CodeGen headers that are in TargetDavid Blaikie1-2/+2
All these headers already depend on CodeGen headers so moving them into CodeGen fixes the layering (since CodeGen depends on Target, not the other way around). llvm-svn: 318490
2017-11-09[GlobalMerge] Stable sort GlobalSets to fix non-deterministic sort orderMandeep Singh Grang1-1/+1
Summary: This fixes failure in CodeGen/AArch64/global-merge-group-by-use.ll uncovered by D39245. Reviewers: ab, asl Reviewed By: ab Subscribers: aemerson, llvm-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D39635 llvm-svn: 317817
2017-09-22[CodeGen] Fix some Clang-tidy modernize-use-default-member-init and Include ↵Eugene Zelenko1-15/+38
What You Use warnings; other minor fixes (NFC). llvm-svn: 314046
2017-06-05Add support for #pragma clang sectionJaved Absar1-1/+2
This patch provides a means to specify section-names for global variables, functions and static variables, using #pragma directives. This feature is only defined to work sensibly for ELF targets. One can specify section names as: #pragma clang section bss="myBSS" data="myData" rodata="myRodata" text="myText" One can "unspecify" a section name with empty string e.g. #pragma clang section bss="" data="" text="" rodata="" Reviewers: Roger Ferrer, Jonathan Roelofs, Reid Kleckner Differential Revision: https://reviews.llvm.org/D33413 llvm-svn: 304704
2017-06-02[GlobalMerge] Don't merge globals that may be preemptedJohn Brawn1-0/+4
When a global may be preempted it needs to be accessed directly, instead of indirectly through a MergedGlobals symbol, for the preemption to work. This fixes PR33136. Differential Revision: https://reviews.llvm.org/D33727 llvm-svn: 304537
2017-05-25CodeGen: Rename DEBUG_TYPE to match passnamesMatthias Braun1-4/+1
Rename the DEBUG_TYPE to match the names of corresponding passes where it makes sense. Also establish the pattern of simply referencing DEBUG_TYPE instead of repeating the passname where possible. llvm-svn: 303921
2016-11-11Simplify code and address review comments (NFC)Adrian Prantl1-4/+3
llvm-svn: 286644
2016-11-11Fix a reference-to-temporary introduced in r286607.Adrian Prantl1-8/+10
llvm-svn: 286640
2016-11-11Revert "Use private linkage for MergedGlobals variables" on Darwin.Adrian Prantl1-3/+25
This is a partial revert of r244615 (http://reviews.llvm.org/D11942), which caused a major regression in debug info quality. Turning the artificial __MergedGlobal symbols into private symbols (l__MergedGlobal) means that the linker will not include them in the symbol table of the final executable. Without a symbol table entry dsymutil is not be able to process the debug info for any of the merged globals and thus drops the debug info for all of them. This patch is enabling the old behavior for all MachO targets while leaving all other targets unaffected. rdar://problem/29160481 https://reviews.llvm.org/D26531 llvm-svn: 286607
2016-10-19[GlobalMerge] Handle non-landingpad EH padsReid Kleckner1-14/+10
This code crashed on funclet-style EH instructions such as catchpad, catchswitch, and cleanuppad. Just treat all EH pad instructions equivalently and avoid merging the globals they reference through any use. llvm-svn: 284633
2016-10-01Use StringRef in Pass/PassManager APIs (NFC)Mehdi Amini1-3/+1
llvm-svn: 283004
2016-09-13DebugInfo: New metadata representation for global variables.Peter Collingbourne1-0/+6
This patch reverses the edge from DIGlobalVariable to GlobalVariable. This will allow us to more easily preserve debug info metadata when manipulating global variables. Fixes PR30362. A program for upgrading test cases is attached to that bug. Differential Revision: http://reviews.llvm.org/D20147 llvm-svn: 281284
2016-05-19CodeGen: Make the global-merge pass independently testable, and add a test.Peter Collingbourne1-7/+20
llvm-svn: 270023
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