summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2015-12-02 06:58:49 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2015-12-02 06:58:49 +0000
commit237916b537fc159740b75f5338c4f5f664ab9a84 (patch)
treee5e1639ed16e4f078de2fc83666f5b3321224e81 /llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
parentf419a1f69a10697be7e398b5fe27005d05a2a7ae (diff)
downloadbcm5719-llvm-237916b537fc159740b75f5338c4f5f664ab9a84.tar.gz
bcm5719-llvm-237916b537fc159740b75f5338c4f5f664ab9a84.zip
[AttributeSet] Overload AttributeSet::addAttribute to reduce compile
time. The new overloaded function is used when an attribute is added to a large number of slots of an AttributeSet (for example, to function parameters). This is much faster than calling AttributeSet::addAttribute once per slot, because AttributeSet::getImpl (which calls FoldingSet::FIndNodeOrInsertPos) is called only once per function instead of once per slot. With this commit, clang compiles a file which used to take over 22 minutes in just 13 seconds. rdar://problem/23581000 Differential Revision: http://reviews.llvm.org/D15085 llvm-svn: 254491
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 26088bbe018..d2341c8c05d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1942,20 +1942,27 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
// Mark any parameters that are known to be non-null with the nonnull
// attribute. This is helpful for inlining calls to functions with null
// checks on their arguments.
+ SmallVector<unsigned, 4> Indices;
unsigned ArgNo = 0;
+
for (Value *V : CS.args()) {
if (V->getType()->isPointerTy() && !CS.paramHasAttr(ArgNo+1, Attribute::NonNull) &&
- isKnownNonNullAt(V, CS.getInstruction(), DT, TLI)) {
- AttributeSet AS = CS.getAttributes();
- AS = AS.addAttribute(CS.getInstruction()->getContext(), ArgNo+1,
- Attribute::NonNull);
- CS.setAttributes(AS);
- Changed = true;
- }
+ isKnownNonNullAt(V, CS.getInstruction(), DT, TLI))
+ Indices.push_back(ArgNo + 1);
ArgNo++;
}
+
assert(ArgNo == CS.arg_size() && "sanity check");
+ if (!Indices.empty()) {
+ AttributeSet AS = CS.getAttributes();
+ LLVMContext &Ctx = CS.getInstruction()->getContext();
+ AS = AS.addAttribute(Ctx, Indices,
+ Attribute::get(Ctx, Attribute::NonNull));
+ CS.setAttributes(AS);
+ Changed = true;
+ }
+
// If the callee is a pointer to a function, attempt to move any casts to the
// arguments of the call/invoke.
Value *Callee = CS.getCalledValue();
OpenPOWER on IntegriCloud