summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/MergeFunctions.cpp
Commit message (Collapse)AuthorAge
* Merging r195769:Bill Wendling2013-11-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r195769 | dyatkovskiy | 2013-11-26 08:11:03 -0800 (Tue, 26 Nov 2013) | 27 lines PR17925 bugfix. Short description. This issue is about case of treating pointers as integers. We treat pointers as different if they references different address space. At the same time, we treat pointers equal to integers (with machine address width). It was a point of false-positive. Consider next case on 32bit machine: void foo0(i32 addrespace(1)* %p) void foo1(i32 addrespace(2)* %p) void foo2(i32 %p) foo0 != foo1, while foo1 == foo2 and foo0 == foo2. As you can see it breaks transitivity. That means that result depends on order of how functions are presented in module. Next order causes merging of foo0 and foo1: foo2, foo0, foo1 First foo0 will be merged with foo2, foo0 will be erased. Second foo1 will be merged with foo2. Depending on order, things could be merged we don't expect to. The fix: Forbid to treat any pointer as integer, except for those, who belong to address space 0. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195810 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach MergeFunctions about address spacesMatt Arsenault2013-11-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194342 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't merge tiny functions.Matt Arsenault2013-10-01
| | | | | | | | | | | | | | | | | | | | | It's silly to merge functions like these: define void @foo(i32 %x) { ret void } define void @bar(i32 %x) { ret void } to get define void @bar(i32) { tail call void @foo(i32 %0) ret void } git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191786 91177308-0d34-0410-b5e6-96231b3b80d8
* Bugfix for PR17099:Stepan Dyatkovskiy2013-09-17
| | | | | | | | | | | | | Wrong cast operation. MergeFunctions emits Bitcast instead of pointer-to-integer operation. Patch fixes MergeFunctions::writeThunk function. It replaces unconditional Bitcast creation with "Value* createCast(...)" method, that checks operand types and selects proper instruction. See unit-test as example. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190859 91177308-0d34-0410-b5e6-96231b3b80d8
* MergeFunc: Make pointer and integer types generate the same hash.Benjamin Kramer2013-04-19
| | | | | | | | | The logic that actually compares the types considers pointers and integers the same if they are of the same size. This created a strange mismatch between hash and reality and made the test case for this fail on some platforms (yay, test cases). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179905 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement a better fix for PR15185.Bill Wendling2013-04-18
| | | | | | | | If the return type is a pointer and the call returns an integer, then do the inttoptr convertions. And vice versa. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179817 91177308-0d34-0410-b5e6-96231b3b80d8
* We are not able to bitcast a pointer to an integral value.Bill Wendling2013-04-15
| | | | | | | | | Two return types are not equivalent if one is a pointer and the other is an integral. This is because we cannot bitcast a pointer to an integral value. PR15185 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179569 91177308-0d34-0410-b5e6-96231b3b80d8
* Move all of the header files which are involved in modelling the LLVM IRChandler Carruth2013-01-02
| | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171366 91177308-0d34-0410-b5e6-96231b3b80d8
* convert a bunch of callers from DataLayout::getIndexedOffset() to ↵Nuno Lopes2012-12-30
| | | | | | | | | GEP::accumulateConstantOffset(). The later API is nicer than the former, and is correct regarding wrap-around offsets (if anyone cares). There are a few more places left with duplicated code, which I'll remove soon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171259 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-03
| | | | | | | | | | | | | | | | | 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. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert the series of commits starting with r166578 which introduced theChandler Carruth2012-11-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167221 91177308-0d34-0410-b5e6-96231b3b80d8
* Add in support for getIntPtrType to get the pointer type based on the ↵Micah Villmow2012-10-24
| | | | | | | | | | address space. This checkin also adds in some tests that utilize these paths and updates some of the clients. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166578 91177308-0d34-0410-b5e6-96231b3b80d8
* Move TargetData to DataLayout.Micah Villmow2012-10-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165402 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove tabs.Bill Wendling2012-07-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160477 91177308-0d34-0410-b5e6-96231b3b80d8
* Move llvm/Support/IRBuilder.h -> llvm/IRBuilder.hChandler Carruth2012-06-29
| | | | | | | | | | | | | | | | | This was always part of the VMCore library out of necessity -- it deals entirely in the IR. The .cpp file in fact was already part of the VMCore library. This is just a mechanical move. I've tried to go through and re-apply the coding standard's preferred header sort, but at 40-ish files, I may have gotten some wrong. Please let me know if so. I'll be committing the corresponding updates to Clang and Polly, and Duncan has DragonEgg. Thanks to Bill and Eric for giving the green light for this bit of cleanup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159421 91177308-0d34-0410-b5e6-96231b3b80d8
* Update inter-procedural optimizations for atomic load/store.Eli Friedman2011-08-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137667 91177308-0d34-0410-b5e6-96231b3b80d8
* Misc optimizer+codegen work for 'cmpxchg' and 'atomicrmw'. They appear to beEli Friedman2011-07-29
| | | | | | | | | | | working on x86 (at least for trivial testcases); other architectures will need more work so that they actually emit the appropriate instructions for orderings stricter than 'monotonic'. (As far as I can tell, the ARM, PPC, Mips, and Alpha backends need such changes.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136457 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert TargetData::getIndexedOffset to use ArrayRef.Jay Foad2011-07-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135478 91177308-0d34-0410-b5e6-96231b3b80d8
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert CallInst and InvokeInst APIs to use ArrayRef.Jay Foad2011-07-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135265 91177308-0d34-0410-b5e6-96231b3b80d8
* Land the long talked about "type system rewrite" patch. ThisChris Lattner2011-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | patch brings numerous advantages to LLVM. One way to look at it is through diffstat: 109 files changed, 3005 insertions(+), 5906 deletions(-) Removing almost 3K lines of code is a good thing. Other advantages include: 1. Value::getType() is a simple load that can be CSE'd, not a mutating union-find operation. 2. Types a uniqued and never move once created, defining away PATypeHolder. 3. Structs can be "named" now, and their name is part of the identity that uniques them. This means that the compiler doesn't merge them structurally which makes the IR much less confusing. 4. Now that there is no way to get a cycle in a type graph without a named struct type, "upreferences" go away. 5. Type refinement is completely gone, which should make LTO much MUCH faster in some common cases with C++ code. 6. Types are now generally immutable, so we can use "Type *" instead "const Type *" everywhere. Downsides of this patch are that it removes some functions from the C API, so people using those will have to upgrade to (not yet added) new API. "LLVM 3.0" is the right time to do this. There are still some cleanups pending after this, this patch is large enough as-is. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134829 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't include Operator.h from InstrTypes.h.Jay Foad2011-04-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129271 91177308-0d34-0410-b5e6-96231b3b80d8
* No functionality change, just adjust some whitespace for coding style ↵Nick Lewycky2011-03-25
| | | | | | compliance. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128257 91177308-0d34-0410-b5e6-96231b3b80d8
* Instead of keeping two Value*->id# mappings, keep one Value->Value mapping andNick Lewycky2011-02-20
| | | | | | | | one Value set. This is faster because we only need to use the set when there isn't already an entry in the map. No functionality change! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126076 91177308-0d34-0410-b5e6-96231b3b80d8
* When removing a function from the function set and adding it to deferred, weNick Lewycky2011-02-09
| | | | | | | | | | | | | | could end up removing a different function than we intended because it was functionally equivalent, then end up with a comparison of a function against itself in the next round of comparisons (the one in the function set and the one on the deferred list). To fix this, I introduce a choice in the form of comparison for ComparableFunctions, either normal or "pointer only" used to find exact Function*'s in lookups. Also add some debugging statements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125180 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify away redundant test, and document what's going on.Nick Lewycky2011-02-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124977 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove specialized comparison of InlineAsm objects. They're uniqued on creationNick Lewycky2011-02-06
| | | | | | | now, and this wasn't comparing some of their relevant bits anyhow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124976 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove wasteful caching. This isn't needed for correctness because any functionNick Lewycky2011-02-02
| | | | | | | | | that might have changed been affected by a merge elsewhere will have been removed from the function set, and it isn't needed for performance because we call grow() ahead of time to prevent reallocations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124717 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename functions to follow coding standard. Also rejiggers comments. NoNick Lewycky2011-01-28
| | | | | | | functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124482 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a doxygen comment for this class.Nick Lewycky2011-01-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124480 91177308-0d34-0410-b5e6-96231b3b80d8
* Reorder for readability. (Chris, is this what you meant?)Nick Lewycky2011-01-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124479 91177308-0d34-0410-b5e6-96231b3b80d8
* Reduce the number of functions we look at in the first pass, and preallocateNick Lewycky2011-01-28
| | | | | | | the function equality set. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124475 91177308-0d34-0410-b5e6-96231b3b80d8
* Unbreak the build.Benjamin Kramer2011-01-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124426 91177308-0d34-0410-b5e6-96231b3b80d8
* Expound upon this comparison!Nick Lewycky2011-01-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124406 91177308-0d34-0410-b5e6-96231b3b80d8
* Use dyn_cast instead of isa+cast.Nick Lewycky2011-01-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124404 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix surprising missed optimization in mergefunc where we forgot to considerNick Lewycky2011-01-27
| | | | | | | that relationships like "i8* null" is equivalent to "i32* null". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124368 91177308-0d34-0410-b5e6-96231b3b80d8
* AttrListPtr has an overloaded operator== which does this for us, we should useNick Lewycky2011-01-26
| | | | | | | it. No functionality change! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124286 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach mergefunc that intptr_t is the same width as a pointer. We still can'tNick Lewycky2011-01-26
| | | | | | | | merge vector<intptr_t>::push_back() and vector<void*>::push_back() because Enumerate() doesn't realize that "i64* null" and "i8** null" are equivalent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124285 91177308-0d34-0410-b5e6-96231b3b80d8
* There are no vectors of pointer or arrays, so we don't need to check vectorNick Lewycky2011-01-26
| | | | | | | elements for type equivalence. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124284 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach mergefunc how to emit aliases safely again -- but keep it turned it offNick Lewycky2011-01-25
| | | | | | | | for now. It's controlled by the HasGlobalAliases variable which is not attached to any flag yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124182 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a cache that protects mergefunc's internals from more surprises in DenseSet.Nick Lewycky2011-01-15
| | | | | | | Also, replace tabs with spaces. Yes, it's 2011. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123535 91177308-0d34-0410-b5e6-96231b3b80d8
* Also remove functions that use complex constant expressions in terms ofNick Lewycky2011-01-02
| | | | | | | another function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122705 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove functions from the FnSet when one of their callee's is being merged. ThisNick Lewycky2011-01-02
| | | | | | | | | | | | maintains the guarantee that the DenseSet expects two elements it contains to not go from inequal to equal under its nose. As a side-effect, this also lets us switch from iterating to a fixed-point to actually maintaining a work queue of functions to look at again, and we don't add thunks to our work queue so we don't need to detect and ignore them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122677 91177308-0d34-0410-b5e6-96231b3b80d8
* RetOp is not actually used for anything useful (thoughDuncan Sands2010-10-21
| | | | | | | | it looks like maybe it was supposed to be used in the test...), so zap it (gcc-4.6 warning). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117023 91177308-0d34-0410-b5e6-96231b3b80d8
* Get rid of static constructors for pass registration. Instead, every pass ↵Owen Anderson2010-10-19
| | | | | | | | | | | | | | | | | | exposes an initializeMyPassFunction(), which must be called in the pass's constructor. This function uses static dependency declarations to recursively initialize the pass's dependencies. Clients that only create passes through the createFooPass() APIs will require no changes. Clients that want to use the CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h before parsing commandline arguments. I have tested this with all standard configurations of clang and llvm-gcc on Darwin. It is possible that there are problems with the static dependencies that will only be visible with non-standard options. If you encounter any crash in pass registration/creation, please send the testcase to me directly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116820 91177308-0d34-0410-b5e6-96231b3b80d8
* Now with fewer extraneous semicolons!Owen Anderson2010-10-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115996 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix major bug in thunk detection. Also verify the calling convention.Nick Lewycky2010-09-07
| | | | | | | | | | Switch from isWeakForLinker to mayBeOverridden which is more accurate. Add more statistics and debugging info. Add comments. Move static function outside anonymous namespace. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113190 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch FnSet to containing the ComparableFunction instead of a pointer to one.Nick Lewycky2010-09-05
| | | | | | | This reduces malloc traffic (yay!) and removes MergeFunctionsEqualityInfo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113105 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix many bugs when merging weak-strong and weak-weak pairs. We now merge allNick Lewycky2010-09-05
| | | | | | | | strong functions first to make sure they're the canonical definitions and then do a second pass looking only for weak functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113104 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix an infinite loop; merging two functions will create a new function (if theNick Lewycky2010-08-31
| | | | | | | | | | two are weak, we make them thunks to a new strong function) so don't iterate through the function list as we're modifying it. Also add back the outermost loop which got removed during the cleanups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112595 91177308-0d34-0410-b5e6-96231b3b80d8