summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "[Constant Hoisting] Extend coverage of the constant hoisting pass."Juergen Ributzka2014-03-201-391/+259
| | | | | | I will break this up into smaller pieces for review and recommit. llvm-svn: 204393
* [Constant Hoisting] Extend coverage of the constant hoisting pass.Juergen Ributzka2014-03-201-259/+391
| | | | | | | | | This commit extends the coverage of the constant hoisting pass, adds additonal debug output and updates the function names according to the style guide. Related to <rdar://problem/16381500> llvm-svn: 204389
* Remove LowerInvoke's obsolete "-enable-correct-eh-support" optionMark Seaborn2014-03-201-507/+8
| | | | | | | | | | | | | | | This option caused LowerInvoke to generate code using SJLJ-based exception handling, but there is no code left that interprets the jmp_buf stack that the resulting code maintained (llvm.sjljeh.jblist). This option has been obsolete for a while, and replaced by SjLjEHPrepare. This leaves the default behaviour of LowerInvoke, which is to convert invokes to calls. Differential Revision: http://llvm-reviews.chandlerc.com/D3136 llvm-svn: 204388
* [ASan] Do not instrument globals from the llvm.metadata section.Alexander Potapenko2014-03-201-0/+2
| | | | | | Fixes https://code.google.com/p/address-sanitizer/issues/detail?id=279. llvm-svn: 204331
* Set debug info for instructions inserted in SplitBlockAndInsertIfThen.Evgeniy Stepanov2014-03-192-2/+6
| | | | llvm-svn: 204230
* Fix use_iterator crash in ObjCArc from r203364Duncan P. N. Exon Smith2014-03-181-2/+3
| | | | | | | | | | The use_iterator redesign in r203364 introduced an increment past the end of a range in -objc-arc-contract. Added an explicit check for the end of the range. <rdar://problem/16333235> llvm-svn: 204195
* [LV] While I'm here, use range based for loops which are so much cleanerChandler Carruth2014-03-181-7/+7
| | | | | | for this kind of walk. llvm-svn: 204188
* [LV] The actual change I intended to commit in r204148. Sorry for theChandler Carruth2014-03-181-8/+1
| | | | | | | | | | | | | noise. Original commit log: Replace some dead code with an assert. When I first ported this pass from a loop pass to a function pass I did so in the naive, recursive way. It doesn't actually work, we need a worklist instead. When I switched to the worklist I didn't delete the naive recursion. That recursion was also buggy because it was dead and never really exercised. llvm-svn: 204187
* [LV] Replace some dead code with an assert. When I first ported thisChandler Carruth2014-03-181-2/+2
| | | | | | | | | | pass from a loop pass to a function pass I did so in the naive, recursive way. It doesn't actually work, we need a worklist instead. When I switched to the worklist I didn't delete the naive recursion. That recursion was also buggy because it was dead and never really exercised. llvm-svn: 204184
* [msan] Origin tracking with history.Evgeniy Stepanov2014-03-181-10/+20
| | | | | | | | LLVM part of MSan implementation of advanced origin tracking, when we record not only creation point, but all locations where an uninitialized value was stored to memory, too. llvm-svn: 204151
* Tolerate unmangled names in sample profiles.Diego Novillo2014-03-181-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The compiler does not always generate linkage names. If a function has been inlined and its body elided, its linkage name may not be generated. When the binary executes, the profiler will use its unmangled name when attributing samples. This results in unmangled names in the input profile. We are currently failing hard when this happens. However, in this case all that happens is that we fail to attribute samples to the inlined function. While this means fewer optimization opportunities, it should not cause a compilation failure. This patch accepts all valid function names, regardless of whether they were mangled or not. Reviewers: chandlerc CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3087 llvm-svn: 204142
* [msan] Kill -msan-store-clean-origin flag.Evgeniy Stepanov2014-03-181-5/+1
| | | | | | | Not only is it slower than the alternative, but also subtly broken. This commit does not change the default behavior. llvm-svn: 204131
* [C++11] Change DebugInfoFinder to use range-based loopsAlon Mishne2014-03-183-20/+8
| | | | | | Also changes the iterators to return actual DI type over MDNode. llvm-svn: 204130
* [msan] Remove unused code.Evgeniy Stepanov2014-03-181-5/+0
| | | | llvm-svn: 204125
* 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
* Consistent use of the noduplicate attribute.Eli Bendersky2014-03-171-1/+1
| | | | | | | | | The "noduplicate" attribute of call instructions is sometimes queried directly and sometimes through the cannotDuplicate() predicate. This patch streamlines all queries to use the cannotDuplicate() predicate. It also adds this predicate to InvokeInst, to mirror what CallInst has. llvm-svn: 204049
* Remove named Twine.David Blaikie2014-03-161-4/+2
| | | | | | | While technically correct, we generally disallow any instance of named Twines due to their subtlety. llvm-svn: 204016
* Remove some dead assignements found by scan-buildArnaud A. de Grandmaison2014-03-151-1/+1
| | | | llvm-svn: 204013
* LSR: Compress a pair (and get rid of the DenseMapInfo for it).Benjamin Kramer2014-03-151-33/+6
| | | | | | | Also convert a horrible hash function to use our hashing infrastructure. No functionality change. llvm-svn: 204008
* SampleProfile.cpp: Fix take #2. The issue was abuse of StringRef here.NAKAMURA Takumi2014-03-151-2/+4
| | | | llvm-svn: 203996
* SampleProfile.cpp: Quick fix to r203976 about abuse of Twine. The life of ↵NAKAMURA Takumi2014-03-151-5/+3
| | | | | | | Twine was too short. FIXME: DiagnosticInfoSampleProfile should not hold Twine&. llvm-svn: 203990
* Re-format SampleProfile.cpp with clang-format. No functional changes.Diego Novillo2014-03-141-2/+2
| | | | llvm-svn: 203977
* Use DiagnosticInfo facility.Diego Novillo2014-03-141-14/+46
| | | | | | | | | | | | | | | | | | Summary: The sample profiler pass emits several error messages. Instead of just aborting the compiler with report_fatal_error, we can emit better messages using DiagnosticInfo. This adds a new sub-class of DiagnosticInfo to handle the sample profiler. Reviewers: chandlerc, qcolombet CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3086 llvm-svn: 203976
* [ASan] Fix https://code.google.com/p/address-sanitizer/issues/detail?id=274Alexander Potapenko2014-03-141-3/+9
| | | | | | | by ignoring globals from __TEXT,__cstring,cstring_literals during instrumenation. Add a regression test. llvm-svn: 203916
* MergeFunctions, cmpType: fixed variable names from XXTy1 and XXTy2 to XXTyL ↵Stepan Dyatkovskiy2014-03-141-29/+29
| | | | | | and XXTyR. llvm-svn: 203907
* MergeFunctions, cmpType: Fixed comments wrapping.Stepan Dyatkovskiy2014-03-141-1/+2
| | | | llvm-svn: 203905
* Fix a bug in InstCombine where we would incorrectly attempt to construct aOwen Anderson2014-03-131-0/+7
| | | | | | | bitcast between pointers of two different address spaces if they happened to have the same pointer size. llvm-svn: 203862
* [msan] Fix handling of byval arguments in VarArg calls.Evgeniy Stepanov2014-03-131-21/+34
| | | | llvm-svn: 203794
* First patch of patch series that improves MergeFunctions performance time ↵Stepan Dyatkovskiy2014-03-131-39/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from O(N*N) to O(N*log(N)). The idea is to introduce total ordering among functions set. That allows to build binary tree and perform function look-up procedure in O(log(N)) time. This patch description: Introduced total ordering among Type instances. Actually it is improvement for existing isEquivalentType. 0. Coerce pointer of 0 address space to integer. 1. If left and right types are equal (the same Type* value), return 0 (means equal). 2. If types are of different kind (different type IDs). Return result of type IDs comparison, treating them as numbers. 3. If types are vectors or integers, return result of its pointers comparison (casted to numbers). 4. Check whether type ID belongs to the next group: * Void * Float * Double * X86_FP80 * FP128 * PPC_FP128 * Label * Metadata If so, return 0. 5. If left and right are pointers, return result of address space comparison (numbers comparison). 6. If types are complex. Then both LEFT and RIGHT will be expanded and their element types will be checked with the same way. If we get Res != 0 on some stage, return it. Otherwise return 0. 7. For all other cases put llvm_unreachable. llvm-svn: 203788
* Fix typo in comment: "inwoke" -> "invoke"Mark Seaborn2014-03-131-1/+1
| | | | llvm-svn: 203739
* Resubmit "[SLPV] Recognize vectorizable intrinsics during SLP vectorization ..."Raul E. Silvera2014-03-121-0/+83
| | | | | | | This reverts commit 86cb795388643710dab34941ddcb5a9470ac39d8. The problems previously found have been resolved through other CLs. llvm-svn: 203707
* Allow switch-to-lookup table for tables with holes by adding bitmask checkHans Wennborg2014-03-121-5/+61
| | | | | | | | | | | | | | | | | | | | | | | | This allows us to generate table lookups for code such as: unsigned test(unsigned x) { switch (x) { case 100: return 0; case 101: return 1; case 103: return 2; case 105: return 3; case 107: return 4; case 109: return 5; case 110: return 6; default: return f(x); } } Since cases 102, 104, etc. are not constants, the lookup table has holes in those positions. We therefore guard the table lookup with a bitmask check. Patch by Jasper Neumann! llvm-svn: 203694
* Revert r203488 and r203520.Evan Cheng2014-03-121-67/+62
| | | | llvm-svn: 203687
* Revive SizeOptLevel-explaining comments that were dropped in r203669Eli Bendersky2014-03-121-2/+2
| | | | llvm-svn: 203675
* Move duplicated code into a helper function (exposed through overload).Eli Bendersky2014-03-121-0/+17
| | | | | | | | | | | | | | | | | There's a bit of duplicated "magic" code in opt.cpp and Clang's CodeGen that computes the inliner threshold from opt level and size opt level. This patch moves the code to a function that lives alongside the inliner itself, providing a convenient overload to the inliner creation. A separate patch can be committed to Clang to use this once it's committed to LLVM. Standalone tools that use the inlining pass can also avoid duplicating this code and fearing it will go out of sync. Note: this patch also restructures the conditinal logic of the computation to be cleaner. llvm-svn: 203669
* Cloning a function now also clones its debug metadata if ↵Alon Mishne2014-03-121-0/+58
| | | | | | 'ModuleLevelChanges' is true. llvm-svn: 203662
* Fix crash in PRE.Erik Verbruggen2014-03-111-0/+2
| | | | | | | | | | After r203553 overflow intrinsics and their non-intrinsic (normal) instruction get hashed to the same value. This patch prevents PRE from moving an instruction into a predecessor block, and trying to add a phi node that gets two different types (the intrinsic result and the non-intrinsic result), resulting in a failing assert. llvm-svn: 203574
* IR: add a second ordering operand to cmpxhg for failureTim Northover2014-03-113-19/+7
| | | | | | | | | | | | | | | The syntax for "cmpxchg" should now look something like: cmpxchg i32* %addr, i32 42, i32 3 acquire monotonic where the second ordering argument gives the required semantics in the case that no exchange takes place. It should be no stronger than the first ordering constraint and cannot be either "release" or "acq_rel" (since no store will have taken place). rdar://problem/15996804 llvm-svn: 203559
* GVN: fix hashing of extractvalue.Erik Verbruggen2014-03-111-0/+4
| | | | | | | My last commit did not add the indexes to the hashed value for extractvalue. Adding that back in. llvm-svn: 203558
* GVN: merge overflow intrinsics with non-overflow instructions.Erik Verbruggen2014-03-111-58/+118
| | | | | | | | | | | | | | | | | | | When an overflow intrinsic is followed by a non-overflow instruction, replace the latter with an extract. For example: %sadd = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b) %sadd3 = add i32 %a, %b Here the add statement will be replaced by an extract. When an overflow intrinsic follows a non-overflow instruction, a clone of the intrinsic is inserted before the normal instruction, which makes it the same as the previous case. Subsequent runs of GVN can then clean up the duplicate instructions and insert the extract. This fixes PR8817. llvm-svn: 203553
* Cleanup whitespaceDuncan P. N. Exon Smith2014-03-111-9/+9
| | | | llvm-svn: 203529
* Follow up to r203488. Code clean up to eliminate a lot of copy+paste.Evan Cheng2014-03-111-215/+35
| | | | llvm-svn: 203520
* Use discriminator information in sample profiles.Diego Novillo2014-03-101-40/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When the sample profiles include discriminator information, use the discriminator values to distinguish instruction weights in different basic blocks. This modifies the BodySamples mapping to map <line, discriminator> pairs to weights. Instructions on the same line but different blocks, will use different discriminator values. This, in turn, means that the blocks may have different weights. Other changes in this patch: - Add tests for positive values of line offset, discriminator and samples. - Change data types from uint32_t to unsigned and int and do additional validation. Reviewers: chandlerc CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2857 llvm-svn: 203508
* MemCpyOpt: When merging memsets also merge the trivial case of two memsets ↵Benjamin Kramer2014-03-101-0/+7
| | | | | | | | with the same destination. The testcase is from PR19092, but I think the bug described there is actually a clang issue. llvm-svn: 203489
* For functions with ARM target specific calling convention, when simplify-libcallEvan Cheng2014-03-101-48/+233
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | optimize a call to a llvm intrinsic to something that invovles a call to a C library call, make sure it sets the right calling convention on the call. e.g. extern double pow(double, double); double t(double x) { return pow(10, x); } Compiles to something like this for AAPCS-VFP: define arm_aapcs_vfpcc double @t(double %x) #0 { entry: %0 = call double @llvm.pow.f64(double 1.000000e+01, double %x) ret double %0 } declare double @llvm.pow.f64(double, double) #1 Simplify libcall (part of instcombine) will turn the above into: define arm_aapcs_vfpcc double @t(double %x) #0 { entry: %__exp10 = call double @__exp10(double %x) #1 ret double %__exp10 } declare double @__exp10(double) The pre-instcombine code works because calls to LLVM builtins are special. Instruction selection will chose the right calling convention for the call. However, the code after instcombine is wrong. The call to __exp10 will use the C calling convention. I can think of 3 options to fix this. 1. Make "C" calling convention just work since the target should know what CC is being used. This doesn't work because each function can use different CC with the "pcs" attribute. 2. Have Clang add the right CC keyword on the calls to LLVM builtin. This will work but it doesn't match the LLVM IR specification which states these are "Standard C Library Intrinsics". 3. Fix simplify libcall so the resulting calls to the C routines will have the proper CC keyword. e.g. %__exp10 = call arm_aapcs_vfpcc double @__exp10(double %x) #1 This works and is the solution I implemented here. Both solutions #2 and #3 would work. After carefully considering the pros and cons, I decided to implement #3 for the following reasons. 1. It doesn't change the "spec" of the intrinsics. 2. It's a self-contained fix. There are a couple of potential downsides. 1. There could be other places in the optimizer that is broken in the same way that's not addressed by this. 2. There could be other calling conventions that need to be propagated by simplify-libcall that's not handled. But for now, this is the fix that I'm most comfortable with. llvm-svn: 203488
* SimplifyCFG: Simplify the weight scaling algorithm.Benjamin Kramer2014-03-091-15/+6
| | | | | | No change in functionality. llvm-svn: 203413
* Fix build break.Ahmed Charles2014-03-091-0/+2
| | | | llvm-svn: 203366
* [C++11] Add range based accessors for the Use-Def chain of a Value.Chandler Carruth2014-03-0957-783/+629
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-072-18/+12
| | | | | | No functionality change. llvm-svn: 203288
OpenPOWER on IntegriCloud