aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-04-13[IR] Make getParamAttributes take argument numbers, not ArgNo+1Reid Kleckner1-13/+9
Add hasParamAttribute() and use it instead of hasAttribute(ArgNo+1, Kind) everywhere. The fact that the AttributeList index for an argument is ArgNo+1 should be a hidden implementation detail. NFC llvm-svn: 300272
2017-03-21Rename AttributeSet to AttributeListReid Kleckner1-19/+19
Summary: This class is a list of AttributeSetNodes corresponding the function prototype of a call or function declaration. This class used to be called ParamAttrListPtr, then AttrListPtr, then AttributeSet. It is typically accessed by parameter and return value index, so "AttributeList" seems like a more intuitive name. Rename AttributeSetImpl to AttributeListImpl to follow suit. It's useful to rename this class so that we can rename AttributeSetNode to AttributeSet later. AttributeSet is the set of attributes that apply to a single function, argument, or return value. Reviewers: sanjoy, javed.absar, chandlerc, pete Reviewed By: pete Subscribers: pete, jholewinski, arsenm, dschuff, mehdi_amini, jfb, nhaehnle, sbc100, void, llvm-commits Differential Revision: https://reviews.llvm.org/D31102 llvm-svn: 298393
2017-03-17Store Arguments in a flat array instead of an iplistReid Kleckner1-14/+46
This saves two pointers from Argument and eliminates some extra allocations. Arguments cannot be inserted or removed from a Function because that would require changing its Type, which LLVM does not allow. Instead, passes that change prototypes, like DeadArgElim, create a new Function and copy over argument names and attributes. The primary benefit of iplist is O(1) random insertion and removal. We just don't need that for arguments, so don't use it. Reviewed By: chandlerc Subscribers: dlj, inglorion, llvm-commits Differential Revision: https://reviews.llvm.org/D31058 llvm-svn: 298105
2017-03-16Remove dead F parameter from Argument constructorReid Kleckner1-7/+3
When Function creates its argument list, it does the ilist push_back itself. No other caller passes in a parent function, so this is dead, and it uses the soon-to-be-deleted getArgumentList accessor. llvm-svn: 298009
2017-03-16Make Argument::getArgNo() constant time, not O(#args)Reid Kleckner1-15/+4
getArgNo is actually hot in LLVM, because its how we check for attributes on arguments: bool Argument::hasNonNullAttr() const { if (!getType()->isPointerTy()) return false; if (getParent()->getAttributes(). hasAttribute(getArgNo()+1, Attribute::NonNull)) return true; It actually shows up as the 23rd hottest leaf function in a 13s sample of LTO of llc. This grows Argument by four bytes, but I have another pending patch to shrink it by removing its ilist_node base. Reviewed By: chandlerc Subscribers: inglorion, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D31057 llvm-svn: 298003
2017-03-16[IR] Inline some Function accessorsReid Kleckner1-29/+0
I checked that all of these out-of-line methods previously compiled to simple loads and bittests, so they are pretty good candidates for inlining. In particular, arg_size() and arg_empty() are popular and are just two loads, so they seem worth inlining. llvm-svn: 297963
2017-02-28Add function importing info from samplepgo profile to the module summary.Dehao Chen1-2/+15
Summary: For SamplePGO, the profile may contain cross-module inline stacks. As we need to make sure the profile annotation happens when all the hot inline stacks are expanded, we need to pass this info to the module importer so that it can import proper functions if necessary. This patch implemented this feature by emitting cross-module targets as part of function entry metadata. In the module-summary phase, the metadata is used to build call edges that points to functions need to be imported. Reviewers: mehdi_amini, tejohnson Reviewed By: tejohnson Subscribers: davidxl, llvm-commits Differential Revision: https://reviews.llvm.org/D30053 llvm-svn: 296498
2017-02-15Implement intrinsic mangling for literal struct types.Daniel Berlin1-4/+12
Fixes PR 31921 Summary: Predicateinfo requires an ugly workaround to try to avoid literal struct types due to the intrinsic mangling not being implemented. This workaround actually does not work in all cases (you can hit the assert by bootstrapping with -print-predicateinfo), and can't be made to work without DFS'ing the type (IE copying getMangledStr and using a version that detects if it would crash). Rather than do that, i just implemented the mangling. It seems simple, since they are unified structurally. Looking at the overloaded-mangling testcase we have, it actually turns out the gc intrinsics will *also* crash if you try to use a literal struct. Thus, the testcase added fails before this patch, and works after, without needing to resort to predicateinfo. Reviewers: chandlerc, davide Subscribers: llvm-commits, sanjoy Differential Revision: https://reviews.llvm.org/D29925 llvm-svn: 295253
2017-02-14fix documentation comments for Argument; NFCSanjay Patel1-28/+0
llvm-svn: 295068
2016-12-28Speed up Function::isIntrinsic() by adding a bit to GlobalValue. NFCJustin Lebar1-3/+6
Summary: Previously isIntrinsic() called getName(). This involves a hashtable lookup, so is nontrivially expensive. And isIntrinsic() is called frequently, particularly by dyn_cast<IntrinsicInstr>. This patch steals a bit of IntID and uses that to store whether or not getName() starts with "llvm." Reviewers: bogner, arsenm, joker-eph Subscribers: sanjoy, llvm-commits Differential Revision: https://reviews.llvm.org/D22949 llvm-svn: 290691
2016-11-03Expandload and Compressstore intrinsicsElena Demikhovsky1-5/+29
2 new intrinsics covering AVX-512 compress/expand functionality. This implementation includes syntax, DAG builder, operation lowering and tests. Does not include: handling of illegal data types, codegen prepare pass and the cost model. llvm-svn: 285876
2016-10-25IR: Deduplicate getParent() functions on derived classes of GlobalValue into ↵Peter Collingbourne1-4/+0
the base class. NFCI. llvm-svn: 285050
2016-10-18Use profile info to set function section prefix to group hot/cold functions.Dehao Chen1-0/+17
Summary: The original implementation is in r261607, which was reverted in r269726 to accomendate the ProfileSummaryInfo analysis pass. The new implementation: 1. add a new metadata for function section prefix 2. query against ProfileSummaryInfo in CGP to set the correct section prefix for each function 3. output the section prefix set by CGP Reviewers: davidxl, eraman Subscribers: vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D24989 llvm-svn: 284533
2016-09-17Don't create a SymbolTable in Function when the LLVMContext discards value ↵Mehdi Amini1-2/+4
names (NFC) The ValueSymbolTable is used to detect name conflict and rename instructions automatically. This is not needed when the value names are automatically discarded by the LLVMContext. No functional change intended, just saving a little bit of memory. This is a recommit of r281806 after fixing the accessor to return a pointer instead of a reference and updating all the call-sites. llvm-svn: 281813
2016-09-17Revert "Don't create a SymbolTable in Function when the LLVMContext discards ↵Mehdi Amini1-4/+2
value names (NFC)" This reverts commit r281806. It introduces undefined behavior as an API is returning a reference to the Symtab llvm-svn: 281808
2016-09-17Don't create a SymbolTable in Function when the LLVMContext discards value ↵Mehdi Amini1-2/+4
names (NFC) The ValueSymbolTable is used to detect name conflict and rename instructions automatically. This is not needed when the value names are automatically discarded by the LLVMContext. No functional change intended, just saving a little bit of memory. llvm-svn: 281806
2016-08-22Add comments and an assert to follow-up on r279113. NFC.Pete Cooper1-0/+2
Philip commented on r279113 to ask for better comments as to when to use the different versions of getName. Its also possible to assert in the simple case that we aren't an overloaded intrinsic as those have to use the more capable version of getName. Thanks for the comments Philip. llvm-svn: 279466
2016-08-18Add a version of Intrinsic::getName which is more efficient when there are ↵Pete Cooper1-0/+5
no overloads. When running 'opt -O2 verify-uselistorder-nodbg.lto.bc', there are 33m allocations. 8.2m come from std::string allocations in Intrinsic::getName(). Turns out this method only returns a std::string because it needs to handle overloads, but that is not the common case. This adds an overload of getName which just returns a StringRef when there are no overloads and so saves on the allocations. llvm-svn: 279113
2016-08-17Replace a few more "fall through" comments with LLVM_FALLTHROUGHJustin Bogner1-3/+3
Follow up to r278902. I had missed "fall through", with a space. llvm-svn: 278970
2016-08-09[IR] Remove some unused #includes (NFC)Vedant Kumar1-4/+0
I needed a reader-writer lock for a downstream project and noticed that llvm has one. Function.cpp is the only file in-tree that refers to it. To anyone reading this: are you using RWMutex in out-of-tree code? Maybe it's not worth keeping around any more... Since we're not actually using RWMutex *here*, remove the #include (and a few other stale headers while we're at it). llvm-svn: 278178
2016-08-05[AutoFDO] Fix handling of empty profilesDavid Callahan1-1/+4
Summary: If a profile has no samples for a function, then the function "entry count" is set to the value 0. Several places in the code test that if the Function::getEntryCount is defined at all. Here we change to treat a 0 entry count the same as undefined. In particular, this fixes a problem in getLayoutSuccessorProbThreshold in MachineBlockPlacement.cpp where we use a different and inferior heuristic for laying out basic blocks. Reviewers: danielcdh, dnovillo Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23082 llvm-svn: 277849
2016-07-29CodeGen: add new "intrinsic" MachineOperand kind.Tim Northover1-4/+2
This will be used during GlobalISel, where we need a more robust and readable way to write tests than a simple immediate ID. llvm-svn: 277209
2016-07-28Revert "Don't invoke getName() from Function::isIntrinsic().", rL276942.Justin Lebar1-3/+6
This broke some out-of-tree AMDGPU tests that relied on the old behavior wherein isIntrinsic() would return true for any function that starts with "llvm.". And in general that change will not play nicely with out-of-tree backends. llvm-svn: 277087
2016-07-27Don't invoke getName() from Function::isIntrinsic().Justin Lebar1-6/+3
Summary: getName() involves a hashtable lookup, so is expensive given how frequently isIntrinsic() is called. (In particular, many users cast to IntrinsicInstr or one of its subclasses before calling getIntrinsicID().) This has an incidental functional change: Before, isIntrinsic() would return true for any function whose name started with "llvm.", even if it wasn't properly an intrinsic. The new behavior seems more correct to me, because it's strange to say that isIntrinsic() is true, but getIntrinsicId() returns "not an intrinsic". Some callers want the old behavior -- they want to know whether the caller is a recognized intrinsic, or might be one in some other version of LLVM. For them, we added Function::hasLLVMReservedName(), which checks whether the name starts with "llvm.". This change is good for a 1.5% e2e speedup compiling a large Eigen benchmark. Reviewers: bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D22065 llvm-svn: 276942
2016-07-15IR: Sort generic intrinsics before target specific onesJustin Bogner1-5/+33
This splits out the intrinsic table such that generic intrinsics come first and target specific intrinsics are grouped by target. From here we can find out which target an intrinsic is for or differentiate between generic and target intrinsics. The motivation here is to make it easier to move target specific intrinsic handling out of generic code. llvm-svn: 275575
2016-06-26Apply clang-tidy's modernize-loop-convert to most of lib/IR.Benjamin Kramer1-6/+4
Only minor manual fixes. No functionality change intended. llvm-svn: 273813
2016-06-24Remangle intrinsics names when types are renamedArtur Pilipenko1-0/+34
This is a resubmittion of previously reverted rL273568. This is a fix for the problem mentioned in "LTO and intrinsics mangling" llvm-dev mail thread: http://lists.llvm.org/pipermail/llvm-dev/2016-April/098387.html Reviewers: mehdi_amini, reames Differential Revision: http://reviews.llvm.org/D19373 llvm-svn: 273686
2016-06-24NFC. Move verifyIntrinsicIsVarArg from verifier to ↵Artur Pilipenko1-0/+20
Intrinsic::matchIntrinsicVarArg since it will be reused for intrinsic remangling code llvm-svn: 273685
2016-06-23Revert r273568 "Remangle intrinsics names when types are renamed"Hans Wennborg1-31/+0
It broke 2008-07-15-Bswap.ll and 2009-09-01-PostRAProlog.ll llvm-svn: 273574
2016-06-23Remangle intrinsics names when types are renamedArtur Pilipenko1-0/+31
This is a fix for the problem mentioned in "LTO and intrinsics mangling" llvm-dev mail thread: http://lists.llvm.org/pipermail/llvm-dev/2016-April/098387.html Reviewers: mehdi_amini, reames Differential Revision: http://reviews.llvm.org/D19373 llvm-svn: 273568
2016-06-22NFC. Move Verifier::verifyIntrinsicType to Intrinsics.hArtur Pilipenko1-0/+138
Move Verifier::verifyIntrinsicType to Intrinsics::matchIntrinsicsType. Will be used to accumulate overloaded types of a given intrinsic by the upcoming patch to fix intrinsics names when overloaded types are renamed. Reviewed By: reames Differential Revision: http://reviews.llvm.org/D19372 llvm-svn: 273424
2016-06-15Add support for string attributes in the C API.Amaury Sechet1-0/+6
Summary: As per title. This completes the C API Attribute support. Reviewers: Wallbraker, whitequark, echristo, rafael, jyknight Subscribers: mehdi_amini Differential Revision: http://reviews.llvm.org/D21365 llvm-svn: 272811
2016-06-14Make sure attribute kind and attributes are named respectively Kind and Attr ↵Amaury Sechet1-8/+8
consistently. Historically they used to be the same the terminology is very confused in the codebase. NFC. llvm-svn: 272704
2016-06-12Make sure we have a Add/Remove/Has function for various thing that can have ↵Amaury Sechet1-0/+6
attribute. Summary: This also deprecated the get attribute function familly. Reviewers: Wallbraker, whitequark, joker.eph, echristo, rafael, jyknight Subscribers: axw, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D19181 llvm-svn: 272504
2016-05-31Add support for metadata attachments for global variables.Peter Collingbourne1-2/+4
This patch adds an IR, assembly and bitcode representation for metadata attachments for globals. Future patches will port existing features to use these new attachments. Differential Revision: http://reviews.llvm.org/D20074 llvm-svn: 271348
2016-05-29Remove some 'const' specifiers that do nothing but prevent moving the argument.Benjamin Kramer1-1/+1
Found by clang-tidy's misc-move-const-arg. While there drop some obsolete c_str() calls. llvm-svn: 271181
2016-04-18[NFC] Header cleanupMehdi Amini1-1/+0
Removed some unused headers, replaced some headers with forward class declarations. Found using simple scripts like this one: clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap' Patch by Eugene Kosov <claprix@yandex.ru> Differential Revision: http://reviews.llvm.org/D19219 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266595
2016-04-06IRMover: Steal arguments when moving functions, NFCDuncan P. N. Exon Smith1-0/+22
Instead of copying arguments from the source function to the destination, steal them. This has a few advantages. - The ValueMap doesn't need to be seeded with (or cleared of) Arguments. - Often the destination function won't have created any arguments yet, so this avoids malloc traffic. - Argument names don't need to be copied. Because argument lists are lazy, this required a new Function::stealArgumentListFrom helper. llvm-svn: 265519
2016-04-01Swift Calling Convention: add swifterror attribute.Manman Ren1-0/+5
A ``swifterror`` attribute can be applied to a function parameter or an AllocaInst. This commit does not include any target-specific change. The target-specific optimization will come as a follow-up patch. Differential Revision: http://reviews.llvm.org/D18092 llvm-svn: 265189
2016-03-29Swift Calling Convention: add swiftself attribute.Manman Ren1-0/+5
Differential Revision: http://reviews.llvm.org/D17866 llvm-svn: 264754
2016-03-15Move global ID computation from Function to GlobalValue (NFC)Teresa Johnson1-24/+0
Since the static getGlobalIdentifier and getGUID methods are now called for global values other than functions, reflect that by moving these methods to the GlobalValue class. llvm-svn: 263524
2016-03-14Add facility to add/remove/check attribute on function and arguments.Amaury Sechet1-18/+20
Summary: This comes from work to make attribute manipulable via the C API. Reviewers: gottesmm, hfinkel, baldrick, echristo, tejohnson Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18128 llvm-svn: 263404
2016-02-18Remove uses of builtin comma operator.Richard Trieu1-4/+10
Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. llvm-svn: 261270
2016-02-09Refactor PGO function naming and MD5 hashing support out of ProfileDataTeresa Johnson1-0/+24
Summary: Move the function renaming logic into the Function class, and the MD5Hash routine into the MD5 header. This will enable these routines to be shared with ThinLTO, which will be changed to store the MD5 hash instead of full function name in the combined index for significant size reductions. And using the same function naming for locals in the function index facilitates future integration with indirect call value profiles. Reviewers: davidxl Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17006 llvm-svn: 260197
2016-01-26Handle more edge cases in intrinsic name binary searchReid Kleckner1-40/+1
I tried to make the AMDGPU intrinsic info table use this instead of another StringMatcher, and some issues arose. llvm-svn: 258871
2016-01-26Use binary search for intrinsic ID lookupsReid Kleckner1-14/+60
This improves compile time of Function.cpp from 57s to 37s for me locally. Intrinsic IDs are cached on the Function object, so this shouldn't regress performance. llvm-svn: 258774
2016-01-15[opaque pointer types] Remove an unnecessary extra explicit value type in ↵David Blaikie1-3/+4
Function Now that this is up in GlobalValue, just use the value there. llvm-svn: 257949
2016-01-08Remove static global GCNames from Function.cpp and move it to the ContextMehdi Amini1-35/+9
This remove the need for locking when deleting a function. Differential Revision: http://reviews.llvm.org/D15988 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 257139
2015-12-23[Function] Properly remove use when clearing personalityKeno Fischer1-9/+10
Summary: We need to actually remove the use of the personality function, otherwise we can run into trouble if we want to e.g. delete the personality function because ther's no way to get rid of its uses. Do this by resetting to ConstantPointerNull value that the operands are set to when first allocated. Reviewers: vsk, dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15752 llvm-svn: 256345
2015-12-19Re-reapply "[IR] Move optional data in llvm::Function into a hungoff uselist"Vedant Kumar1-76/+55
Make personality functions, prefix data, and prologue data hungoff operands of Function. This is based on the email thread "[RFC] Clean up the way we store optional Function data" on llvm-dev. Thanks to sanjoyd, majnemer, rnk, loladiro, and dexonsmith for feedback! Includes a fix to scrub value subclass data in dropAllReferences. Does not use binary literals. Differential Revision: http://reviews.llvm.org/D13829 llvm-svn: 256095