summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/GlobalOpt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Retain the name of the new internal global that's been shrunk.Bill Wendling2013-02-131-2/+5
| | | | | | | | | It's possible (e.g. after an LTO build) that an internal global may be used for debugging purposes. If that's the case appending a '.b' to it makes it hard to find that variable. Steal the name from the old GV before deleting it so that they can find that variable again. llvm-svn: 175104
* Remove some introspection functions.Bill Wendling2013-01-251-2/+3
| | | | | | | | The 'getSlot' function and its ilk allow introspection into the AttributeSet class. However, that class should be opaque. Allow access through accessor methods instead. llvm-svn: 173522
* Use the new 'getSlotIndex' method to retrieve the attribute's slot index.Bill Wendling2013-01-251-1/+1
| | | | llvm-svn: 173499
* Use the AttributeSet when removing multiple attributes. Use Attribute::AttrKindBill Wendling2013-01-231-2/+1
| | | | | | when removing one attribute. This further encapsulates the use of the attributes. llvm-svn: 173214
* GlobalOpt: Avoid jump on uninitialized value.Benjamin Kramer2013-01-121-1/+1
| | | | | | Found by valgrind. llvm-svn: 172318
* Fixed whitespace.Michael Gottesman2013-01-111-61/+61
| | | | llvm-svn: 172271
* Added debug messages to GlobalOpt.Michael Gottesman2013-01-111-17/+110
| | | | | | | | | Specifically: 1. Added a missing new line when we emit a debug message saying that we are marking a global variable as constant. 2. Added debug messages that describe what is occuring when GlobalOpt is evaluating a block/function. 3. Added a debug message that says what specific constructor is being evaluated. llvm-svn: 172247
* Fix TryToShrinkGlobalToBoolean in GlobalOpt, so that it does not discard ↵Joey Gouly2013-01-101-1/+2
| | | | | | address spaces. llvm-svn: 172051
* Move all of the header files which are involved in modelling the LLVM IRChandler Carruth2013-01-021-8/+8
| | | | | | | | | | | | | | | | | | | | | 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
* Rename the 'Attributes' class to 'Attribute'. It's going to represent a ↵Bill Wendling2012-12-191-3/+3
| | | | | | single attribute in the future. llvm-svn: 170502
* s/AttrListPtr/AttributeSet/g to better label what this class is going to be ↵Bill Wendling2012-12-071-1/+1
| | | | | | in the near future. llvm-svn: 169651
* Remove unused field.Jakub Staszak2012-12-061-6/+1
| | | | llvm-svn: 169551
* Remove trailing spaces.Jakub Staszak2012-12-061-25/+25
| | | | llvm-svn: 169550
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-9/+9
| | | | | | | | | | | | | | | | | 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
* Revert previous check in r168581, r169079 as they are still in code review ↵Zhou Sheng2012-12-011-22/+4
| | | | | | status. llvm-svn: 169083
* The patch is to improve the memory footprint of pass GlobalOpt. Zhou Sheng2012-12-011-4/+22
| | | | | | | | | | | | Also check in a case to repeat the issue, on which 'opt -globalopt' consumes 1.6GB memory. The big memory footprint cause is that current GlobalOpt one by one hoists and stores the leaf element constant into the global array, in each iteration, it recreates the global array initializer constant and leave the old initializer alone. This may result in many obsolete constants left. For example: we have global array @rom = global [16 x i32] zeroinitializer After the first element value is hoisted and installed: @rom = global [16 x i32] [ 1, 0, 0, ... ] After the second element value is installed: @rom = global [16 x 32] [ 1, 2, 0, 0, ... ] // here the previous initializer is obsolete ... When the transform is done, we have 15 obsolete initializers left useless. llvm-svn: 169079
* Make GlobalOpt be conservative with TLS variables (PR14309)Hans Wennborg2012-11-151-0/+9
| | | | | | | | | | | | | | For global variables that get the same value stored into them everywhere, GlobalOpt will replace them with a constant. The problem is that a thread-local GlobalVariable looks like one value (the address of the TLS var), but is different between threads. This patch introduces Constant::isThreadDependent() which returns true for thread-local variables and constants which depend on them (e.g. a GEP into a thread-local array), and teaches GlobalOpt not to track such values. llvm-svn: 168037
* Revert the series of commits starting with r166578 which introduced theChandler Carruth2012-11-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | getIntPtrType support for multiple address spaces via a pointer type, and also introduced a crasher bug in the constant folder reported in PR14233. These commits also contained several problems that should really be addressed before they are re-committed. I have avoided reverting various cleanups to the DataLayout APIs that are reasonable to have moving forward in order to reduce the amount of churn, and minimize the number of commits that were reverted. I've also manually updated merge conflicts and manually arranged for the getIntPtrType function to stay in DataLayout and to be defined in a plausible way after this revert. Thanks to Duncan for working through this exact strategy with me, and Nick Lewycky for tracking down the really annoying crasher this triggered. (Test case to follow in its own commit.) After discussing with Duncan extensively, and based on a note from Micah, I'm going to continue to back out some more of the more problematic patches in this series in order to ensure we go into the LLVM 3.2 branch with a reasonable story here. I'll send a note to llvmdev explaining what's going on and why. Summary of reverted revisions: r166634: Fix a compiler warning with an unused variable. r166607: Add some cleanup to the DataLayout changes requested by Chandler. r166596: Revert "Back out r166591, not sure why this made it through since I cancelled the command. Bleh, sorry about this! r166591: Delete a directory that wasn't supposed to be checked in yet. r166578: Add in support for getIntPtrType to get the pointer type based on the address space. llvm-svn: 167221
* Add in support for getIntPtrType to get the pointer type based on the ↵Micah Villmow2012-10-241-2/+2
| | | | | | | | | address space. This checkin also adds in some tests that utilize these paths and updates some of the clients. llvm-svn: 166578
* Use the Attributes::get method which takes an AttrVal value directly to ↵Bill Wendling2012-10-161-4/+2
| | | | | | simplify the code a bit. No functionality change. llvm-svn: 166009
* Move the Attributes::Builder outside of the Attributes class and into its ↵Bill Wendling2012-10-151-1/+1
| | | | | | own class named AttrBuilder. No functionality change. llvm-svn: 165960
* Attributes RewriteBill Wendling2012-10-151-1/+1
| | | | | | | | | | Convert the internal representation of the Attributes class into a pointer to an opaque object that's uniqued by and stored in the LLVMContext object. The Attributes class then becomes a thin wrapper around this opaque object. Eventually, the internal representation will be expanded to include attributes that represent code generation options, etc. llvm-svn: 165917
* Remove the bitwise NOT operator from the Attributes class. Replace it with ↵Bill Wendling2012-10-141-4/+4
| | | | | | the equivalent from the builder class. llvm-svn: 165892
* Remove the final bits of Attributes being declared in the AttributeBill Wendling2012-10-101-2/+5
| | | | | | | namespace. Use the attribute's enum value instead. No functionality change intended. llvm-svn: 165610
* Create enums for the different attributes.Bill Wendling2012-10-091-1/+1
| | | | | | | We use the enums to query whether an Attributes object has that attribute. The opaque layer is responsible for knowing where that specific attribute is stored. llvm-svn: 165488
* Move TargetData to DataLayout.Micah Villmow2012-10-081-18/+18
| | | | llvm-svn: 165402
* Use method to query for attributes.Bill Wendling2012-10-041-1/+1
| | | | llvm-svn: 165209
* GlobalOpt: non-constexpr bitcasts or GEPs can occur even if the global value ↵Benjamin Kramer2012-09-281-1/+3
| | | | | | | | is only stored once. Fixes PR13968. llvm-svn: 164815
* Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. ↵Sylvestre Ledru2012-09-271-1/+1
| | | | | | See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164767 llvm-svn: 164768
* Fix a typo 'iff' => 'if'Sylvestre Ledru2012-09-271-1/+1
| | | | llvm-svn: 164767
* Make MemoryBuiltins aware of TargetLibraryInfo.Benjamin Kramer2012-08-291-15/+18
| | | | | | | | | | | | | | | | This disables malloc-specific optimization when -fno-builtin (or -ffreestanding) is specified. This has been a problem for a long time but became more severe with the recent memory builtin improvements. Since the memory builtin functions are used everywhere, this required passing TLI in many places. This means that functions that now have an optional TLI argument, like RecursivelyDeleteTriviallyDeadFunctions, won't remove dead mallocs anymore if the TLI argument is missing. I've updated most passes to do the right thing. Fixes PR13694 and probably others. llvm-svn: 162841
* It's not safe to blindly remove invoke instructions. This happens when weNick Lewycky2012-07-251-1/+2
| | | | | | | encounter an invoke of an allocation function. This should fix the dragonegg bootstrap. Testcase to follow, later. llvm-svn: 160757
* Don't delete one more instruction than we're allowed to. This should fix theNick Lewycky2012-07-241-1/+3
| | | | | | | Darwin bootstrap. Testcase exists but isn't fully reduced, I expect to commit the testcase this evening. llvm-svn: 160693
* Teach globalopt to not nuke all stores to globals. Keep them around of theyNick Lewycky2012-07-241-8/+177
| | | | | | | | | might be deliberate "one time" leaks, so that leak checkers can find them. This is a reapply of r160602 with the fix that this time I'm committing the code I thought I was committing last time; the I->eraseFromParent() goes *after* the break out of the loop. llvm-svn: 160664
* Revert r160602.Nick Lewycky2012-07-211-177/+8
| | | | llvm-svn: 160603
* Teach globalopt to play nice with leak checkers. This is a reapplication ofNick Lewycky2012-07-211-8/+177
| | | | | | | | r160529 that was subsequently reverted. The fix was to not call GV->eraseFromParent() right before the caller does the same. The existing testcases already caught this bug if run under valgrind. llvm-svn: 160602
* Revert r160529 due to crashes.Nick Lewycky2012-07-191-171/+8
| | | | llvm-svn: 160532
* Don't wipe out global variables that are probably storing pointers to heapNick Lewycky2012-07-191-8/+171
| | | | | | memory. This makes clang play nice with leak checkers. llvm-svn: 160529
* GlobalOpt forgot to handle bitcast when analyzing globals. Found by inspection.Duncan Sands2012-07-021-0/+2
| | | | llvm-svn: 159546
* Revert r159136 due to PR13124.Matt Beaumont-Gay2012-06-271-11/+0
| | | | | | | | | | | Original commit message: If a constant or a function has linkonce_odr linkage and unnamed_addr, mark it 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: 159272
* If a constant or a function has linkonce_odr linkage and unnamed_addr, mark itRafael Espindola2012-06-251-0/+11
| | | | | | | | 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: 159136
* Tab to spaces. No functionality change.Nick Lewycky2012-06-241-1/+1
| | | | llvm-svn: 159104
* Extend the IL for selecting TLS models (PR9788)Hans Wennborg2012-06-231-7/+7
| | | | | | | | | | | | | | | This allows the user/front-end to specify a model that is better than what LLVM would choose by default. For example, a variable might be declared as @x = thread_local(initialexec) global i32 42 if it will not be used in a shared library that is dlopen'ed. If the specified model isn't supported by the target, or if LLVM can make a better choice, a different model may be used. llvm-svn: 159077
* fix whitespace in my last commit.Nuno Lopes2012-06-221-1/+1
| | | | | | sorry for the churn :S enough for today; going to sleep. llvm-svn: 158953
* remove extractMallocCallFromBitCast, since it was tailor maded for its sole ↵Nuno Lopes2012-06-221-2/+4
| | | | | | user. Update GlobalOpt accordingly. llvm-svn: 158952
* Some optimizations done by globalopt are safe only for internal linkage, notRafael Espindola2012-06-151-0/+3
| | | | | | | | linkonce linkage. For example, it is not valid to add unnamed_addr. This also fixes a crash in g++.dg/opt/static5.C. llvm-svn: 158528
* Implement the isSafeToDiscardIfUnused predicate and use it in globalopt andRafael Espindola2012-06-141-1/+1
| | | | | | | globaldce. Globaldce was already removing linkonce globals, but globalopt was not. llvm-svn: 158476
* Teach Function::hasAddressTaken that BlockAddress doesn't really takeJay Foad2012-05-121-0/+4
| | | | | | the address of a function. llvm-svn: 156703
* GlobalOpt: If we have an inbounds GEP from a ConstantAggregateZero global ↵Benjamin Kramer2012-03-281-0/+6
| | | | | | that we just determined to be constant, replace all loads from it with a zero value. llvm-svn: 153576
* Teach globalopt how to evaluate an invoke with a non-void return type.Dan Gohman2012-03-131-5/+6
| | | | llvm-svn: 152634
OpenPOWER on IntegriCloud