Eli Friedman
f99e7e6643
PR7853: fix a silly mistake introduced in r101899, and add a test to make sure
...
it doesn't regress again.
llvm-svn: 110597
2010-08-09 20:49:43 +00:00
Dan Gohman
35e8a6209d
Use unary + instead of a separate local variable for working
...
around std::min vs static const friction.
llvm-svn: 110112
2010-08-03 16:15:50 +00:00
Dan Gohman
d566d2c7b5
Move MaximumAlignment to be a member of the Value class.
...
llvm-svn: 109891
2010-07-30 21:07:05 +00:00
Dan Gohman
a7e5a24093
Define a maximum supported alignment value for load, store, and
...
alloca instructions (constrained by their internal encoding),
and add error checking for it. Fix an instcombine bug which
generated huge alignment values (null is infinitely aligned).
This fixes undefined behavior noticed by John Regehr.
llvm-svn: 109643
2010-07-28 20:12:04 +00:00
Dan Gohman
9cd20bf792
When user code intentionally dereferences null, the alignment of the
...
dereference is theoretically infinite. Put a cap on the computed
alignment to avoid overflow, noticed by John Regehr.
llvm-svn: 109596
2010-07-28 17:14:23 +00:00
Gabor Greif
3e44ea1917
undo 80 column trespassing I caused
...
llvm-svn: 109092
2010-07-22 10:37:47 +00:00
Gabor Greif
6d673953e3
eliminate CallInst::ArgOffset
...
llvm-svn: 108522
2010-07-16 09:38:02 +00:00
Gabor Greif
3abd881bea
use getArgOperand (corrected by CallInst::ArgOffset) instead of getOperand
...
llvm-svn: 107275
2010-06-30 12:38:26 +00:00
Gabor Greif
5b1370ee80
use ArgOperand API
...
llvm-svn: 107017
2010-06-28 16:50:57 +00:00
Gabor Greif
5f3e656a1b
use ArgOperand API (some hunks I could split)
...
llvm-svn: 106824
2010-06-25 07:57:14 +00:00
Gabor Greif
a6d75e2cf7
use (even more, still) ArgOperand API
...
llvm-svn: 106750
2010-06-24 15:51:11 +00:00
Gabor Greif
0a136c9b53
use (even more) ArgOperand API
...
llvm-svn: 106744
2010-06-24 13:54:33 +00:00
Gabor Greif
590d95ed18
use ArgOperand API
...
llvm-svn: 106743
2010-06-24 13:42:49 +00:00
Gabor Greif
589a0b950a
use ArgOperand API
...
llvm-svn: 106740
2010-06-24 12:58:35 +00:00
Duncan Sands
f162eace49
Teach instCombine to remove malloc+free if malloc's only uses are comparisons
...
to null. Patch by Matti Niemenmaa.
llvm-svn: 104871
2010-05-27 19:09:06 +00:00
Chris Lattner
4bd85e47bf
further clarify alignment of globals, fix instcombine
...
to not increase the alignment of globals with an assigned
alignment and section.
llvm-svn: 102476
2010-04-28 00:31:12 +00:00
Gabor Greif
27b3d55194
use abstract accessors to CallInst
...
llvm-svn: 101899
2010-04-20 13:13:04 +00:00
Eric Christopher
7258dcd77f
Revert 101465, it broke internal OpenGL testing.
...
Probably the best way to know that all getOperand() calls have been handled
is to replace that API instead of updating.
llvm-svn: 101579
2010-04-16 23:37:20 +00:00
Gabor Greif
f375520f7b
reapply r101434
...
with a fix for self-hosting
rotate CallInst operands, i.e. move callee to the back
of the operand array
the motivation for this patch are laid out in my mail to llvm-commits:
more efficient access to operands and callee, faster callgraph-construction,
smaller compiler binary
llvm-svn: 101465
2010-04-16 15:33:14 +00:00
Gabor Greif
403e9694f9
back out r101423 and r101397, they break llvm-gcc self-host on darwin10
...
llvm-svn: 101434
2010-04-16 01:16:20 +00:00
Gabor Greif
33ae80bff7
reapply r101364, which has been backed out in r101368
...
with a fix
rotate CallInst operands, i.e. move callee to the back
of the operand array
the motivation for this patch are laid out in my mail to llvm-commits:
more efficient access to operands and callee, faster callgraph-construction,
smaller compiler binary
llvm-svn: 101397
2010-04-15 20:51:13 +00:00
Gabor Greif
9fd00c7d25
back out r101364, as it trips the linux nightlybot on some clang C++ tests
...
llvm-svn: 101368
2010-04-15 12:46:56 +00:00
Gabor Greif
aafd209632
rotate CallInst operands, i.e. move callee to the back
...
of the operand array
the motivation for this patch are laid out in my mail to llvm-commits:
more efficient access to operands and callee, faster callgraph-construction,
smaller compiler binary
llvm-svn: 101364
2010-04-15 10:49:53 +00:00
Mon P Wang
c576ee9040
Reapply address space patch after fixing an issue in MemCopyOptimizer.
...
Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset,
e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
llvm-svn: 100304
2010-04-04 03:10:48 +00:00
Mon P Wang
999c1b927b
Revert r100191 since it breaks objc in clang
...
llvm-svn: 100199
2010-04-02 18:43:02 +00:00
Mon P Wang
a972ab8564
Reapply address space patch after fixing an issue in MemCopyOptimizer.
...
Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset,
e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
llvm-svn: 100191
2010-04-02 18:04:15 +00:00
Bob Wilson
6f7fd28824
Revert Mon Ping's change 99928, since it broke all the llvm-gcc buildbots.
...
llvm-svn: 99948
2010-03-30 22:27:04 +00:00
Mon P Wang
7460571381
Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset,
...
e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
A update of langref will occur in a subsequent checkin.
llvm-svn: 99928
2010-03-30 20:55:56 +00:00
Evan Cheng
3f7842232e
Fix an incorrect logic causing instcombine to miss some _chk -> non-chk transformations.
...
llvm-svn: 99263
2010-03-23 06:06:09 +00:00
Gabor Greif
febf6ab718
Add a setCalledFunction member to InvokeInst (like in CallInst)
...
and use this (as well as getCalledValue) to access the callee,
instead of {g|s}etOperand(0).
llvm-svn: 99084
2010-03-20 21:00:25 +00:00
Benjamin Kramer
7b88a49f3e
Factor checked library call optimization into a common helper class and use it
...
to unify the almost identical code in CodeGenPrepare and InstCombineCalls.
llvm-svn: 98338
2010-03-12 09:27:41 +00:00
Benjamin Kramer
2fc395659c
stpcpy is so similar to strcpy, it doesn't deserve a complete copy of the __strcpy_chk -> strcpy code.
...
llvm-svn: 98284
2010-03-11 20:45:13 +00:00
Eric Christopher
607de1de53
Lower stpcpy_chk when possible.
...
llvm-svn: 98274
2010-03-11 19:24:34 +00:00
Eric Christopher
43dc11c525
Add strncpy libcall creator. Use it when it should be used.
...
llvm-svn: 98219
2010-03-11 01:25:07 +00:00
Evan Cheng
4f2fd2d2be
Re-commit 97860 with fix. getMallocAllocatedType may return null.
...
llvm-svn: 98000
2010-03-08 22:54:36 +00:00
Eric Christopher
1810d77cb4
Let the fallthrough handle whether or not we've changed anything
...
before we try to optimize.
llvm-svn: 97876
2010-03-06 10:59:25 +00:00
Eric Christopher
a7fb58f5f5
Migrate _chk call lowering from SimplifyLibCalls to InstCombine. Stub
...
out the remainder of the calls that we should lower in some way and
move the tests to the new correct directory. Fix up tests that are now
optimized more than they were before by -instcombine.
llvm-svn: 97875
2010-03-06 10:50:38 +00:00
Eric Christopher
d8b43d0e59
Temporarily revert:
...
Log:
Transform @llvm.objectsize to integer if the argument is a result of malloc of known size.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/trunk/test/Transforms/InstCombine/objsize.ll
It appears to be causing swb and nightly test failures.
llvm-svn: 97866
2010-03-06 03:11:35 +00:00
Evan Cheng
afdc7d3aab
Transform @llvm.objectsize to integer if the argument is a result of malloc of known size.
...
llvm-svn: 97860
2010-03-06 01:01:42 +00:00
Evan Cheng
fffdad58ac
Instcombine should turn llvm.objectsize of a alloca with static size to an integer.
...
llvm-svn: 97827
2010-03-05 20:47:23 +00:00
Evan Cheng
43d6ff7701
Add missing break for Intrinsic::objectsize case. It was falling through to the following Intrinsic::bswap code. I have no idea why it wasn't breaking stuff.
...
llvm-svn: 97774
2010-03-05 01:22:47 +00:00
Evan Cheng
3688b8fa68
Instcombine constant folding can normalize gep with negative index to index with large offset. When instcombine objsize checking transformation sees these geps where the offset seemingly point out of bound, it should just return "i don't know" rather than asserting.
...
llvm-svn: 96825
2010-02-22 23:34:00 +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
Eric Christopher
843a4cc43c
Fix a problem where we had bitcasted operands that gave us
...
odd offsets since the bitcasted pointer size and the offset pointer
size are going to be different types for the GEP vs base object.
llvm-svn: 96134
2010-02-13 23:38:01 +00:00
Eric Christopher
cccdc13662
Make sure that ConstantExpr offsets also aren't off of extern
...
symbols.
Thanks to Duncan Sands for the testcase!
llvm-svn: 95877
2010-02-11 17:44:04 +00:00
Eric Christopher
531ea566a6
Add ConstantExpr handling to Intrinsic::objectsize lowering.
...
Update testcase accordingly now that we can optimize another
section.
llvm-svn: 95846
2010-02-11 01:48:54 +00:00
Eric Christopher
7b7028fd24
Move Intrinsic::objectsize lowering back to InstCombineCalls and
...
enable constant 0 offset lowering.
llvm-svn: 95691
2010-02-09 21:24:27 +00:00
Eric Christopher
04371b4f12
Remove this code for now. I have a better idea and will rewrite with
...
that in mind.
llvm-svn: 95402
2010-02-05 19:04:06 +00:00
Eric Christopher
107a1fbf61
Temporarily revert this since it appears to have caused a build
...
failure.
llvm-svn: 95294
2010-02-04 06:41:27 +00:00
Eric Christopher
42fa84a880
Rework constant expr and array handling for objectsize instcombining.
...
Fix bugs where we would compute out of bounds as in bounds, and where
we couldn't know that the linker could override the size of an array.
Add a few new testcases, change existing testcase to use a private
global array instead of extern.
llvm-svn: 95283
2010-02-04 02:55:34 +00:00
Eric Christopher
f12e18db21
If we're dealing with a zero-length array, don't lower to any
...
particular size, we just don't know what the length is yet.
llvm-svn: 95266
2010-02-03 23:56:07 +00:00
Eric Christopher
d86233c118
Recommit this, looks like it wasn't the cause.
...
llvm-svn: 95165
2010-02-03 00:21:58 +00:00
Eric Christopher
e67d01a9a8
Hopefully temporarily revert this.
...
llvm-svn: 95154
2010-02-02 23:01:31 +00:00
Eric Christopher
f9553572b7
Reformat my last patch slightly.
...
llvm-svn: 95147
2010-02-02 22:29:26 +00:00
Eric Christopher
4264e7e46f
Re-add strcmp and known size object size checking optimization.
...
Passed bootstrap and nightly test run here.
llvm-svn: 95145
2010-02-02 22:10:43 +00:00
Chris Lattner
846a52e228
fix rdar://7590304, a miscompilation of objc apps on arm. The caller
...
of objc message send was getting marked arm_apcscc, but the prototype
isn't. This is fine at runtime because objcmsgsend is implemented in
assembly. Only turn a mismatched caller and callee into 'unreachable'
if the callee is a definition.
llvm-svn: 94986
2010-02-01 18:11:34 +00:00
Chris Lattner
2cecedf081
fix rdar://7590304, an infinite loop in instcombine. In the invoke
...
case, instcombine can't zap the invoke for fear of changing the CFG.
However, we have to do something to prevent the next iteration of
instcombine from inserting another store -> undef before the invoke
thereby getting into infinite iteration between dead store elim and
store insertion.
Just zap the callee to null, which will prevent the next iteration
from doing anything.
llvm-svn: 94985
2010-02-01 18:04:58 +00:00
Eric Christopher
5a0e174863
Revert my last couple of patches. They appear to have broken bison.
...
llvm-svn: 94841
2010-01-29 21:16:24 +00:00
Eric Christopher
997f7ca8c5
Add constant support to object size handling and remove default
...
lowering. We'll either figure it out, or not and be lowered by
SelectionDAGBuild.
Add test.
llvm-svn: 94775
2010-01-29 01:09:57 +00:00
Eric Christopher
4a1d7e1506
Remove unnecessary dyn_cast and add a comment. Part of a WIP.
...
llvm-svn: 93026
2010-01-08 21:37:11 +00:00
Eric Christopher
2cdb806fd8
Move the object size intrinsic optimization to inst-combine and make
...
it work for any integer size return type.
llvm-svn: 92853
2010-01-06 20:04:44 +00:00
Benjamin Kramer
d2564e3afb
Move remaining stuff to the isInteger predicate.
...
llvm-svn: 92771
2010-01-05 21:05:54 +00:00
Chris Lattner
7a9e47ac4b
split call handling out to InstCombineCalls.cpp
...
llvm-svn: 92707
2010-01-05 07:32:13 +00:00