Commit Graph

8607 Commits

Author SHA1 Message Date
Stepan Dyatkovskiy
24473120a2 SwitchInst refactoring.
The purpose of refactoring is to hide operand roles from SwitchInst user (programmer). If you want to play with operands directly, probably you will need lower level methods than SwitchInst ones (TerminatorInst or may be User). After this patch we can reorganize SwitchInst operands and successors as we want.

What was done:

1. Changed semantics of index inside the getCaseValue method:
getCaseValue(0) means "get first case", not a condition. Use getCondition() if you want to resolve the condition. I propose don't mix SwitchInst case indexing with low level indexing (TI successors indexing, User's operands indexing), since it may be dangerous.
2. By the same reason findCaseValue(ConstantInt*) returns actual number of case value. 0 means first case, not default. If there is no case with given value, ErrorIndex will returned.
3. Added getCaseSuccessor method. I propose to avoid usage of TerminatorInst::getSuccessor if you want to resolve case successor BB. Use getCaseSuccessor instead, since internal SwitchInst organization of operands/successors is hidden and may be changed in any moment.
4. Added resolveSuccessorIndex and resolveCaseIndex. The main purpose of these methods is to see how case successors are really mapped in TerminatorInst.
4.1 "resolveSuccessorIndex" was created if you need to level down from SwitchInst to TerminatorInst. It returns TerminatorInst's successor index for given case successor.
4.2 "resolveCaseIndex" converts low level successors index to case index that curresponds to the given successor.

Note: There are also related compatability fix patches for dragonegg, klee, llvm-gcc-4.0, llvm-gcc-4.2, safecode, clang.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149481 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 07:49:51 +00:00
NAKAMURA Takumi
478eed85f9 BBVectorize.cpp: Try to fix MSVC build. map::iterator and multimap::iterator are incompatible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149475 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 06:11:58 +00:00
Hal Finkel
7e004d177f A few of the changes suggested in code review (by Nick Lewycky)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149472 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 05:51:45 +00:00
Argyrios Kyrtzidis
91766fe066 Revert Chris' commits up to r149348 that started causing VMCoreTests unit test to fail.
These are:

r149348
r149351
r149352
r149354
r149356
r149357
r149361
r149362
r149364
r149365

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149470 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 04:51:17 +00:00
Hal Finkel
de5e5ec304 Add a basic-block autovectorization pass.
This is the initial checkin of the basic-block autovectorization pass along with some supporting vectorization infrastructure.
Special thanks to everyone who helped review this code over the last several months (especially Tobias Grosser).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149468 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 03:51:43 +00:00
Jim Grosbach
d0e277d272 Disable InstCombine unsafe folding bitcasts of calls w/ varargs.
Changing arguments from being passed as fixed to varargs is unsafe, as
the ABI may require they be handled differently (stack vs. register, for
example).

Remove two tests which rely on the bitcast being folded into the direct
call, which is exactly the transformation that's unsafe.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149457 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 00:08:17 +00:00
Lenny Maiorani
e0c7cfa723 bz11794 : EarlyCSE stack overflow on long functions.
Make the EarlyCSE optimizer not use recursion to do a depth first iteration.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149445 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 23:14:41 +00:00
Bill Wendling
b319f12727 Increase the initial vector size to be equivalent to the size of the Deps
vector. This potentially saves a resizing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149369 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 07:04:52 +00:00
Bill Wendling
5d8ab0f02b Cache the size of the vector instead of calling .size() all over the place.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149368 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 06:57:53 +00:00
Chris Lattner
6a89228fac eliminate the "string" form of ConstantArray::get, using
ConstantDataArray::getString instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149365 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 06:18:43 +00:00
Chris Lattner
2cf07eccff eliminate the last uses of GetConstantStringInfo from this file, I didn't realize I was that close...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149354 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 04:54:27 +00:00
Chris Lattner
90f1d8a5da start moving SimplifyLibcalls over to getConstantStringInfo, which is
dramatically more efficient than GetConstantStringInfo.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149352 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 04:43:11 +00:00
Chris Lattner
c8d75c78ec enhance logic to support ConstantDataArray.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149340 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 02:55:06 +00:00
Bill Wendling
13b1c31412 s/getInnerUnwindDest/getInnerResumeDest/g
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149328 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 01:48:40 +00:00
Bill Wendling
08d01462d1 Remove ivar which is identical to another ivar.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149323 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 01:25:54 +00:00
Bill Wendling
4dbd9b8ebf Remove unused ivars and s/getOuterUnwindDest/getOuterResumeDest/g.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149322 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 01:22:03 +00:00
Bill Wendling
6e69442416 Remove more dead functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149318 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 01:18:21 +00:00
Bill Wendling
fd3adbb31a s/getInnerUnwindDestNewEH/getInnerUnwindDest/g
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149317 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 01:15:59 +00:00
Bill Wendling
9e9a34c568 Remove some unused, old-EH methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149316 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 01:14:49 +00:00
Bill Wendling
675f638869 Get rid of references to dead intrinsics.
The eh.selector and eh.resume intrinsics aren't used anymore. Get rid of some
calls to them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149314 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 01:05:20 +00:00
Bill Wendling
06881e8734 Formatting cleanups. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149312 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 01:01:16 +00:00
Bill Wendling
27b5658aff Remove no-longer-useful dyn_casts and pals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149307 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 00:56:53 +00:00
Kostya Serebryany
a1a8a323f4 [asan] fix the ObjC support (asan Issue #33)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149300 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-30 23:50:10 +00:00
Chad Rosier
0cf6b99b96 Typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149289 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-30 22:44:13 +00:00
Chad Rosier
431985a421 Typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149275 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-30 21:13:22 +00:00
Alexander Potapenko
8375bc9236 Fix compilation of ASan tests on OS X Lion (see http://code.google.com/p/address-sanitizer/issues/detail?id=32)
The redzones emitted by AddressSanitizer for CFString instances confuse the linker and are of little use, so we shouldn't add them. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149243 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-30 10:40:22 +00:00
Nick Lewycky
5fef01db01 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149185 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-28 23:33:44 +00:00
Kostya Serebryany
f1639abf1a [asan] correctly use ConstantExpr::getGetElementPtr. Catch by NAKAMURA Takumi
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149172 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-28 04:27:16 +00:00
Chris Lattner
a78fa8cc2d continue making the world safe for ConstantDataVector. At this point,
we should (theoretically optimize and codegen ConstantDataVector as well
as ConstantVector.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149116 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-27 03:08:05 +00:00
Chris Lattner
d59ae907ee Continue improving support for ConstantDataAggregate, and use the
new methods recently added to (sometimes greatly!) simplify code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149024 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-26 02:32:04 +00:00
Chris Lattner
230cdab220 some general cleanup, using new methods and tidying up old code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149006 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-26 00:42:34 +00:00
Nick Lewycky
6c00c6a181 Gracefully degrade precision in branch probability numbers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148946 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-25 09:43:14 +00:00
Chris Lattner
a1f00f4d48 use Constant::getAggregateElement to simplify a bunch of code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148934 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-25 06:48:06 +00:00
Chris Lattner
4ca829e895 use ConstantVector::getSplat in a few places.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148929 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-25 06:02:56 +00:00
Kostya Serebryany
0307b9a885 [asan] enable asan only for the functions that have Attribute::AddressSafety
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148846 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-24 19:34:43 +00:00
Chris Lattner
bec2d03c4d basic instcombine support for CDS.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148806 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-24 14:31:22 +00:00
Alexander Potapenko
2587804203 Implemented AddressSanitizer::getPassName()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148697 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-23 11:22:43 +00:00
David Blaikie
4d6ccb5f68 More dead code removal (using -Wunreachable-code)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148578 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-20 21:51:11 +00:00
Andrew Trick
0041d4d447 Handle a corner case with IV chain collection with bailout instead of assert.
Fixes PR11783: bad cast to AddRecExpr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148572 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-20 21:23:40 +00:00
Kostya Serebryany
164b86b439 Extend Attributes to 64 bits
Problem: LLVM needs more function attributes than currently available (32 bits).
One such proposed attribute is "address_safety", which shows that a function is being checked for address safety (by AddressSanitizer, SAFECode, etc).

Solution:
- extend the Attributes from 32 bits to 64-bits
- wrap the object into a class so that unsigned is never erroneously used instead
- change "unsigned" to "Attributes" throughout the code, including one place in clang.
- the class has no "operator uint64 ()", but it has "uint64_t Raw() " to support packing/unpacking.
- the class has "safe operator bool()" to support the common idiom:  if (Attributes attr = getAttrs()) useAttrs(attr);
- The CTOR from uint64_t is marked explicit, so I had to add a few explicit CTOR calls
- Add the new attribute "address_safety". Doing it in the same commit to check that attributes beyond first 32 bits actually work.
- Some of the functions from the Attribute namespace are worth moving inside the class, but I'd prefer to have it as a separate commit.

Tested:
"make check" on Linux (32-bit and 64-bit) and Mac (10.6)
built/run spec CPU 2006 on Linux with clang -O2.


This change will break clang build in lib/CodeGen/CGCall.cpp.
The following patch will fix it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148553 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-20 17:56:17 +00:00
Andrew Trick
b5c26ef9da SCEVExpander fixes. Affects LSR and indvars.
LSR has gradually been improved to more aggressively reuse existing code, particularly existing phi cycles. This exposed problems with the SCEVExpander's sloppy treatment of its insertion point. I applied some rigor to the insertion point problem that will hopefully avoid an endless bug cycle in this area. Changes:

- Always used properlyDominates to check safe code hoisting.

- The insertion point provided to SCEV is now considered a lower bound. This is usually a block terminator or the use itself. Under no cirumstance may SCEVExpander insert below this point.

- LSR is reponsible for finding a "canonical" insertion point across expansion of different expressions.

- Robust logic to determine whether IV increments are in "expanded" form and/or can be safely hoisted above some insertion point.

Fixes PR11783: SCEVExpander assert.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148535 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-20 07:41:13 +00:00
Dan Gohman
0cdece4389 Set the "tail" flag on pattern-matched objc_storeStrong calls.
rdar://10531041.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148490 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-19 19:14:36 +00:00
Nick Lewycky
f460bf8cd8 Actually, this code handles wrapped sets just fine. Noticed by inspection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148487 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-19 18:19:42 +00:00
Dan Gohman
2f77bbd1bf Add a depth limit to avoid runaway recursion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148419 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-18 21:24:45 +00:00
Dan Gohman
1dae3e965c Use llvm.global_ctors to locate global constructors instead
of recognizing them by name.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148416 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-18 21:19:38 +00:00
Jakub Staszak
785a7a97da Remove trailing spaces and unneeded includes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148415 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-18 21:16:33 +00:00
Dan Gohman
2f6263c96a Add a new ObjC ARC optimization pass to eliminate unneeded
autorelease push+pop pairs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148330 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-17 20:52:24 +00:00
Dan Gohman
7d4c87ef6e Add a new PassManagerBuilder customization point,
EP_ModuleOptimizerEarly, to allow passes to be added before the
main ModulePass optimizers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148329 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-17 20:51:32 +00:00
Andrew Trick
0f080913d1 LSR fix: broaden the check for loop preheaders.
It's becoming clear that LoopSimplify needs to unconditionally create loop preheaders. But that is a bigger fix. For now, continuing to hack LSR.
Fixes rdar://10701050 "Cannot split an edge from an IndirectBrInst" assert.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148288 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-17 06:45:52 +00:00
David Blaikie
fdebc38523 Remove unreachable code. (replace with llvm_unreachable to help GCC where necessary)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148284 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-17 04:43:56 +00:00