Commit Graph

250 Commits

Author SHA1 Message Date
Gabor Greif 36f25dfd33 pass dereferenced iterator to dyn_cast
llvm-svn: 109098
2010-07-22 11:43:44 +00:00
Owen Anderson 13700ebb02 Remove unneeded check, and correct style.
llvm-svn: 108427
2010-07-15 16:38:22 +00:00
Owen Anderson 2cfe91379b Extend SimplifyCFG's common-destination folding heuristic to allow a single
"bonus" instruction to be speculatively executed.  Add a heuristic to
ensure we're not tripping up out-of-order execution by checking that this bonus
instruction only uses values that were already guaranteed to be available.

This allows us to eliminate the short circuit in (x&1)&&(x&2).

llvm-svn: 108351
2010-07-14 19:52:16 +00:00
Gabor Greif 8629f12bb8 cache dereferenced iterators
llvm-svn: 108133
2010-07-12 10:59:23 +00:00
Gabor Greif 329c4d8ed9 cache result of operator*
llvm-svn: 107974
2010-07-09 15:25:09 +00:00
Dan Gohman 39027c403c Fix a grammaro.
llvm-svn: 99917
2010-03-30 20:04:57 +00:00
Gabor Greif b469818279 fix two cases where the arguments were extracted from the wrong range out of the InvokeInst
spotted by baldrick -- thanks\!

llvm-svn: 99914
2010-03-30 19:20:53 +00:00
Bill Wendling ee84f27536 Make returns more consistent with others.
llvm-svn: 98490
2010-03-14 10:40:28 +00:00
Duncan Sands 19d0b47b1f There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy().  Convert most instances of the first form to the second form.
Requested by Chris.

llvm-svn: 96344
2010-02-16 11:11:14 +00:00
Duncan Sands 9dff9bec31 Uniformize the names of type predicates: rather than having isFloatTy and
isInteger, we now have isFloatTy and isIntegerTy.  Requested by Chris!

llvm-svn: 96223
2010-02-15 16:12:20 +00:00
Jakob Stoklund Olesen 916f48a054 Teach SimplifyCFG about magic pointer constants.
Weird code sometimes uses pointer constants other than null. This patch
teaches SimplifyCFG to build switch instructions in those cases.

Code like this:

void f(const char *x) {
  if (!x)
    puts("null");
  else if ((uintptr_t)x == 1)
    puts("one");
  else if (x == (char*)2 || x == (char*)3)
    puts("two");
  else if ((intptr_t)x == 4)
    puts("four");
  else
    puts(x);
}

Now becomes a switch:

define void @f(i8* %x) nounwind ssp {
entry:
  %magicptr23 = ptrtoint i8* %x to i64            ; <i64> [#uses=1]
  switch i64 %magicptr23, label %if.else16 [
    i64 0, label %if.then
    i64 1, label %if.then2
    i64 2, label %if.then9
    i64 3, label %if.then9
    i64 4, label %if.then14
  ]

Note that LLVM's own DenseMap uses magic pointers.

llvm-svn: 95439
2010-02-05 22:03:18 +00:00
Benjamin Kramer a81a6dff0d Convert a ton of simple integer type equality tests to the new predicate.
llvm-svn: 92760
2010-01-05 20:07:06 +00:00
Benjamin Kramer ccce8bae14 Avoid going through the LLVMContext for type equality where it's safe to dereference the type pointer.
llvm-svn: 92726
2010-01-05 13:12:22 +00:00
David Greene 725c7c3f2e Change errs() to dbgs().
llvm-svn: 92604
2010-01-05 01:26:52 +00:00
Devang Patel be94f23992 Remove dead debug info intrinsics.
Intrinsic::dbg_stoppoint
 Intrinsic::dbg_region_start 
 Intrinsic::dbg_region_end 
 Intrinsic::dbg_func_start
AutoUpgrade simply ignores these intrinsics now.

llvm-svn: 92557
2010-01-05 01:10:40 +00:00
Jim Grosbach d831ef4945 Move EliminateDuplicatePHINodes() from SimplifyCFG.cpp to Local.cpp
llvm-svn: 90324
2009-12-02 17:06:45 +00:00
Jim Grosbach cc69a1ba9a Make EliminateDuplicatePHINodes() available as a utility function
llvm-svn: 89297
2009-11-19 02:02:10 +00:00
Chris Lattner cbd18fc93d refactor TryToSimplifyUncondBranchFromEmptyBlock out of SimplifyCFG.
llvm-svn: 86666
2009-11-10 05:59:26 +00:00
Chris Lattner 46b5c642b9 remove a bunch of extraneous LLVMContext arguments
from various APIs, addressing PR5325.

llvm-svn: 86231
2009-11-06 04:27:31 +00:00
Dan Gohman 7f7d97eb73 Add a comment about a missed opportunity.
llvm-svn: 85635
2009-10-30 23:15:43 +00:00
Dan Gohman 1a95106602 Teach SimplifyCFG how to eliminate duplicate PHI nodes within a block.
This reduces codesize on a variety of codes by 1-2% on x86-64. It also
helps clean up after SSAUpdater.

llvm-svn: 85626
2009-10-30 22:39:04 +00:00
Chris Lattner 19788ca686 change simplifycfg to not duplicate 'unwind' instructions. Hopefully
this will increase the likelihood of common code getting sunk towards
the unwind.

llvm-svn: 83996
2009-10-13 18:13:05 +00:00
Nick Lewycky 42fb7452df Instruction::clone does not need to take an LLVMContext&. Remove that and
update all the callers.

llvm-svn: 82889
2009-09-27 07:38:41 +00:00
Dan Gohman c8a27f2a5c Rename Instruction::isIdenticalTo to Instruction::isIdenticalToWhenDefined,
and introduce a new Instruction::isIdenticalTo which tests for full
identity, including the SubclassOptionalData flags. Also, fix the
Instruction::clone implementations to preserve the SubclassOptionalData
flags. Finally, teach several optimizations how to handle
SubclassOptionalData correctly, given these changes.

This fixes the counterintuitive behavior of isIdenticalTo not comparing
the full value, and clone not returning an identical clone, as well as
some subtle bugs that could be caused by these.

Thanks to Nick Lewycky for reporting this, and for an initial patch!

llvm-svn: 80038
2009-08-25 22:11:20 +00:00
Daniel Dunbar 5e0a58bef4 Fix -Asserts warnings.
llvm-svn: 79849
2009-08-23 10:29:55 +00:00
Chris Lattner b25de3ff60 eliminate the "Value" printing methods that print to a std::ostream.
This required converting a bunch of stuff off DOUT and other cleanups.

llvm-svn: 79819
2009-08-23 04:37:46 +00:00
Eli Friedman d56fca4708 Fix for PR3016: detect the tricky case, where there are
unfoldable references to a PHI node in the block being folded, and disable
the transformation in that case.  The correct transformation of such PHI
nodes depends on whether BB dominates Succ, and dominance is expensive 
to compute here.  (Alternatively, it's possible to check whether any 
uses are live, but that's also essentially a dominance calculation. 
Another alternative is to use reg2mem, but it probably isn't a good idea to
use that in simplifycfg.)

Also, remove some incorrect code from CanPropagatePredecessorsForPHIs 
which is made unnecessary with this patch: it didn't consider the case 
where a PHI node in BB has multiple uses.

llvm-svn: 79174
2009-08-16 04:23:49 +00:00
Owen Anderson 55f1c09e31 Push LLVMContexts through the IntegerType APIs.
llvm-svn: 78948
2009-08-13 21:58:54 +00:00
Dan Gohman 5476cfdb15 Remove a bunch more now-unnecessary Context arguments.
llvm-svn: 78809
2009-08-12 16:23:25 +00:00
Owen Anderson b292b8ce70 Move more code back to 2.5 APIs.
llvm-svn: 77635
2009-07-30 23:03:37 +00:00
Daniel Dunbar 6115b39ffd Remove Value::getName{Start,End}, the last of the old Name APIs.
llvm-svn: 77152
2009-07-26 09:48:23 +00:00
Daniel Dunbar 0dd5e1ed39 More migration to raw_ostream, the water has dried up around the iostream hole.
- Some clients which used DOUT have moved to DEBUG. We are deprecating the
   "magic" DOUT behavior which avoided calling printing functions when the
   statement was disabled. In addition to being unnecessary magic, it had the
   downside of leaving code in -Asserts builds, and of hiding potentially
   unnecessary computations.

llvm-svn: 77019
2009-07-25 00:23:56 +00:00
Owen Anderson edb4a70325 Revert the ConstantInt constructors back to their 2.5 forms where possible, thanks to contexts-on-types. More to come.
llvm-svn: 77011
2009-07-24 23:12:02 +00:00
Owen Anderson 47db941fd3 Get rid of the Pass+Context magic.
llvm-svn: 76702
2009-07-22 00:24:57 +00:00
Eli Friedman b8f6a4fc8e Replace isTrapping with a new, similar method called
isSafeToSpeculativelyExecute. The new method is a bit closer to what 
the callers actually care about in that it rejects more things callers 
don't want.  It also adds more precise handling for integer 
division, and unifies code for analyzing the legality of a speculative 
load.

llvm-svn: 76150
2009-07-17 04:28:42 +00:00
Owen Anderson 542619e6d5 Move more functionality over to LLVMContext.
llvm-svn: 75497
2009-07-13 20:58:05 +00:00
Owen Anderson 1e5f00e7a7 This started as a small change, I swear. Unfortunately, lots of things call the [I|F]CmpInst constructors. Who knew!?
llvm-svn: 75200
2009-07-09 23:48:35 +00:00
Owen Anderson 38264b1554 "LLVMContext* " --> "LLVMContext *"
llvm-svn: 74878
2009-07-06 23:00:19 +00:00
Owen Anderson 39f00cc1d4 Thread LLVMContext through the constant folding APIs, which touches a lot of files.
llvm-svn: 74844
2009-07-06 18:42:36 +00:00
Owen Anderson e70b637033 More LLVMContext-ification.
llvm-svn: 74807
2009-07-05 22:41:43 +00:00
Dan Gohman c8ca49659a Teach LoopSimplify how to merge multiple loop exits into a single exit,
when one of them can be converted to a trivial icmp and conditional
branch.

This addresses what is essentially a phase ordering problem.
SimplifyCFG knows how to do this transformation, but it doesn't do so
if the primary block has any instructions in it other than an icmp and
a branch. In the given testcase, the block contains other instructions,
however they are loop-invariant and can be hoisted. SimplifyCFG doesn't
have LoopInfo though, so it can't hoist them. And, it's important that
the blocks be merged before LoopRotation, as it doesn't support
multiple-exit loops.

llvm-svn: 74396
2009-06-27 21:30:38 +00:00
Dale Johannesen 9df78ee1ae Fix the crash in this test. This is basically the same
problem addressed in 31284, but the patch there only
addressed the case where an invoke is the first thing in
a block.

llvm-svn: 73416
2009-06-15 20:59:27 +00:00
Dan Gohman a5b9645c4b Split the Add, Sub, and Mul instruction opcodes into separate
integer and floating-point opcodes, introducing
FAdd, FSub, and FMul.

For now, the AsmParser, BitcodeReader, and IRBuilder all preserve
backwards compatability, and the Core LLVM APIs preserve backwards
compatibility for IR producers. Most front-ends won't need to change
immediately.

This implements the first step of the plan outlined here:
http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt

llvm-svn: 72897
2009-06-04 22:49:04 +00:00
Dale Johannesen 1ac1969e09 Reuse existing getUnderlyingObject instead of
adding another copy.

llvm-svn: 71783
2009-05-14 18:41:18 +00:00
Dale Johannesen 3181652363 Handle some additonal cases of external weak globals.
llvm-svn: 71717
2009-05-13 20:55:30 +00:00
Dale Johannesen 69921959b4 Don't generate a select whose operand is load of a weak
external.  These may have address 0 and are not safe
to execute unconditionally.

llvm-svn: 71688
2009-05-13 18:25:07 +00:00
Dan Gohman 9a6fef0a52 Simplify code by using SmallVector's pop_back_val() instead of
separate back() and pop_back() calls.

llvm-svn: 71089
2009-05-06 17:22:41 +00:00
Dale Johannesen e4f361212b Fix comment typo.
llvm-svn: 67307
2009-03-19 17:23:29 +00:00
Dale Johannesen cecfa6e08d Fix one more place where debug info affected
codegen (speculative execution).

llvm-svn: 66859
2009-03-13 01:05:24 +00:00
Dale Johannesen ed6f5a8253 Previous debug info fix to this code wasn't quite
right; did the wrong thing when there are exactly 11
non-debug instructions, followed by debug info.
Remove a FIXME since it's apparently been fixed along the way.

llvm-svn: 66840
2009-03-12 23:18:09 +00:00