summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Attributes.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert r301697 "[IR] Make add/remove Attributes use AttrBuilder instead of ↵Hans Wennborg2017-04-281-17/+26
| | | | | | | | | | | | | | | | | | AttributeList" This broke the Clang build. (Clang-side patch missing?) Original commit message: > [IR] Make add/remove Attributes use AttrBuilder instead of > AttributeList > > This change cleans up call sites and avoids creating temporary > AttributeList objects. > > NFC llvm-svn: 301712
* [IR] Make add/remove Attributes use AttrBuilder instead of AttributeListReid Kleckner2017-04-281-26/+17
| | | | | | | | | This change cleans up call sites and avoids creating temporary AttributeList objects. NFC llvm-svn: 301697
* Make getParamAlignment use argument numbersReid Kleckner2017-04-281-2/+6
| | | | | | | | | | | | | | | | | | The method is called "get *Param* Alignment", and is only used for return values exactly once, so it should take argument indices, not attribute indices. Avoids confusing code like: IsSwiftError = CS->paramHasAttr(ArgIdx, Attribute::SwiftError); Alignment = CS->getParamAlignment(ArgIdx + 1); Add getRetAlignment to handle the one case in Value.cpp that wants the return value alignment. This is a potentially breaking change for out-of-tree backends that do their own call lowering. llvm-svn: 301682
* Add speculatable function attributeMatt Arsenault2017-04-281-0/+2
| | | | | | | | This attribute tells the optimizer that the function may be speculated. Patch by Tom Stellard llvm-svn: 301680
* Use Argument::hasAttribute and AttributeList::ReturnIndex moreReid Kleckner2017-04-281-23/+6
| | | | | | | | | | | This eliminates many extra 'Idx' induction variables in loops over arguments in CodeGen/ and Target/. It also reduces the number of places where we assume that ReturnIndex is 0 and that we should add one to argument numbers to get the corresponding attribute list index. NFC llvm-svn: 301666
* Make getSlotAttributes return an AttributeSet instead of a wrapper listReid Kleckner2017-04-241-18/+12
| | | | | | | | Remove the temporary, poorly named getSlotSet method which did the same thing. Also remove getSlotNode, which is a hold-over from when we were dealing with AttributeSetNode* instead of AttributeSet. llvm-svn: 301267
* [Bitcode] Refactor attribute group writing to avoid getSlotAttributesReid Kleckner2017-04-241-0/+6
| | | | | | | | | | | | | | | | | Summary: That API creates a temporary AttributeList to carry an index and a single AttributeSet. We need to carry the index in addition to the set, because that is how attribute groups are currently encoded. NFC Reviewers: pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32262 llvm-svn: 301245
* Remove duplicate AttributeList::removeAttributes implementationReid Kleckner2017-04-201-63/+12
| | | | | | | | | | | | | | | Have the AttributeList overload delegate to the AttrBuilder one. Simplify the AttrBuilder overload by avoiding getSlotAttributes, which creates temporary AttributeLists. Simplify `AttrBuilder::removeAttributes(AttributeList, unsigned)` by using getAttributes instead of manually iterating over slots. Extracted from https://reviews.llvm.org/D32262 NFC llvm-svn: 300863
* Remove buggy 'addAttributes(unsigned, AttrBuilder)' overloadReid Kleckner2017-04-191-21/+15
| | | | | | | | | | The 'addAttributes(unsigned, AttrBuilder)' overload delegated to 'get' instead of 'addAttributes'. Since we can implicitly construct an AttrBuilder from an AttributeSet, just standardize on AttrBuilder. llvm-svn: 300651
* Fix crash in AttributeList::addAttributes, add testReid Kleckner2017-04-181-0/+3
| | | | llvm-svn: 300614
* [IR] Make getParamAttributes take argument numbers, not ArgNo+1Reid Kleckner2017-04-131-2/+7
| | | | | | | | | | | | 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
* [IR] Take func, ret, and arg attrs separately in AttributeList::getReid Kleckner2017-04-131-11/+11
| | | | | | | | | | | | | This seems like a much more natural API, based on Derek Schuff's comments on r300015. It further hides the implementation detail of AttributeList that function attributes come last and appear at index ~0U, which is easy for the user to screw up. git diff says it saves code as well: 97 insertions(+), 137 deletions(-) This also makes it easier to change the implementation, which I want to do next. llvm-svn: 300153
* Fix compiler error in Attributes.cppKonstantin Zhuravlyov2017-04-121-1/+2
| | | | | | | | | | | | | | | | | ``` Compiling Attributes.cpp ... ../../../Attributes.cpp: In member function 'std::__1::pair<unsigned int, llvm::Optional<unsigned int> > llvm::AttributeSet::getAllocSizeArgs() const': ../../../Attributes.cpp:542:69: error: operands to ?: have different types 'std::__1::pair<unsigned int, llvm::Optional<unsigned int> >' and 'std::__1::pair<int, int>' return SetNode ? SetNode->getAllocSizeArgs() : std::make_pair(0, 0); ^ ../../../Attributes.cpp:543:1: error: control reaches end of non-void function [-Werror=return-type] } ^ ``` Differential Revision: https://reviews.llvm.org/D31981 llvm-svn: 300143
* [IR] Assert that we never create an empty AttributeListImpl, NFCReid Kleckner2017-04-121-13/+12
| | | | | | Delete following conditional that is always true as a result. llvm-svn: 300117
* [IR] Add AttributeSet to hide AttributeSetNode* again, NFCReid Kleckner2017-04-121-78/+127
| | | | | | | | | | | | | | | | | Summary: For now, it just wraps AttributeSetNode*. Eventually, it will hold AvailableAttrs as an inline bitset, and adding and removing enum attributes will be super cheap. This sinks AttributeSetNode back down to lib/IR/AttributeImpl.h. Reviewers: pete, chandlerc Subscribers: llvm-commits, jfb Differential Revision: https://reviews.llvm.org/D31940 llvm-svn: 300014
* [IR] Sink some AttributeListImpl methods out of headers NFCReid Kleckner2017-04-111-0/+46
| | | | llvm-svn: 299906
* Remove AttributeSetNode::get(AttributeList, unsigned) and sink constructorReid Kleckner2017-04-101-0/+14
| | | | | | | | | | | The getter was equivalent to AttributeList::getAttributes(unsigned), which seems like a better way to express getting the AttributeSet for a given index. This static helper was only used in one place anyway. The constructor doesn't benefit from inlining and doesn't need to be in a header. llvm-svn: 299900
* Reland "[IR] Make AttributeSetNode public, avoid temporary AttributeList copies"Reid Kleckner2017-04-101-110/+159
| | | | | | | | | | | | | | | | | | | | | | | | | This re-lands r299875. I introduced a bug in Clang code responsible for replacing K&R, no prototype declarations with a real function definition with a prototype. The bug was here: // Collect any return attributes from the call. - if (oldAttrs.hasAttributes(llvm::AttributeList::ReturnIndex)) - newAttrs.push_back(llvm::AttributeList::get(newFn->getContext(), - oldAttrs.getRetAttributes())); + newAttrs.push_back(oldAttrs.getRetAttributes()); Previously getRetAttributes() carried AttributeList::ReturnIndex in its AttributeList. Now that we return the AttributeSetNode* directly, it no longer carries that index, and we call this overload with a single node: AttributeList::get(LLVMContext&, ArrayRef<AttributeSetNode*>) That aborted with an assertion on x86_32 targets. I added an explicit triple to the test and added CHECKs to help find issues like this in the future sooner. llvm-svn: 299899
* Revert "[IR] Make AttributeSetNode public, avoid temporary AttributeList copies"Reid Kleckner2017-04-101-159/+110
| | | | | | | This reverts r299875. A Linux bot came back with a test failure: http://bb.pgr.jp/builders/test-clang-i686-linux-RA/builds/741/steps/test_clang/logs/Clang%20%3A%3A%20CodeGen__2006-05-19-SingleEltReturn.c llvm-svn: 299878
* [IR] Make AttributeSetNode public, avoid temporary AttributeList copiesReid Kleckner2017-04-101-110/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: AttributeList::get(Fn|Ret|Param)Attributes no longer creates a temporary AttributeList just to hide the AttributeSetNode type. I've also added a factory method to create AttributeLists from a parallel array of AttributeSetNodes. I think this simplifies construction of AttributeLists when rewriting function prototypes. Previously we would test if a particular index had attributes, and conditionally add a temporary attribute list to a vector. Now the attribute set vector is parallel to the argument vector already that these passes already construct. My long term vision is to wrap AttributeSetNode* inside an AttributeSet type that holds the enum attributes, but that will come in a follow up change. I haven't done any performance measurements for this change because profiling hasn't shown that any of the affected code is hot. Reviewers: pete, chandlerc, sanjoy, hfinkel Reviewed By: pete Subscribers: jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D31198 llvm-svn: 299875
* Rename AttributeSet to AttributeListReid Kleckner2017-03-211-152/+161
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use const-ref in range-loop for to avoid copying pairs of std::stringSean Silva2017-02-221-1/+1
| | | | | | | | | | No reason to create temporaries. Differential Revision: https://reviews.llvm.org/D29871 Patch by sergio.martins! llvm-svn: 295807
* [IR] Fix some Clang-tidy modernize and Include What You Use warnings; other ↵Eugene Zelenko2017-02-171-22/+38
| | | | | | minor fixes (NFC). llvm-svn: 295383
* Cleanup dump() functions.Matthias Braun2017-01-281-0/+4
| | | | | | | | | | | | | | | | | | We had various variants of defining dump() functions in LLVM. Normalize them (this should just consistently implement the things discussed in http://lists.llvm.org/pipermail/cfe-dev/2014-January/034323.html For reference: - Public headers should just declare the dump() method but not use LLVM_DUMP_METHOD or #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) - The definition of a dump method should look like this: #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void MyClass::dump() { // print stuff to dbgs()... } #endif llvm-svn: 293359
* Kill deprecated attribute APIAmaury Sechet2016-11-061-134/+0
| | | | | | | | | | | | | | | Summary: This kill various depreacated API related to attribute : - The deprecated C API attribute based on LLVMAttribute enum. - The Raw attribute set format (planned to be removed in 4.0). Reviewers: bkramer, echristo, mehdi_amini, void Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D23039 llvm-svn: 286062
* Rationalise the attribute getter/setter methods on Function and CallSite.Amaury Sechet2016-09-091-0/+4
| | | | | | | | | | | | | | | | | | | Summary: While woring on mapping attributes in the C API, it clearly appeared that the recent changes in the API on the C++ side left Function and Call/Invoke with an attribute API that grew in an ad hoc manner. This makes it difficult to work with it, because one doesn't know which overloads exists and which do not. Make sure that getter/setter function exists for both enum and string version. Remove inconsistent getter/setter, unless they have many callsites. This should make it easier to work with attributes in the future. This doesn't change how attribute works. Reviewers: bkramer, whitequark, mehdi_amini, void Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D21514 llvm-svn: 281019
* [IR] Properly handle escape characters in Attribute::getAsString()Honggyu Kim2016-09-011-4/+12
| | | | | | | | | | | | | | | | | | | | | If an attribute name has special characters such as '\01', it is not properly printed in LLVM assembly language format. Since the format expects the special characters are printed as it is, it has to contain escape characters to make it printable. Before: attributes #0 = { ... "counting-function"="^A__gnu_mcount_nc" ... After: attributes #0 = { ... "counting-function"="\01__gnu_mcount_nc" ... Reviewers: hfinkel, rengolin, rjmccall, compnerd Subscribers: nemanjai, mcrosier, hans, shenhan, majnemer, llvm-commits Differential Revision: https://reviews.llvm.org/D23792 llvm-svn: 280357
* Make some LLVM_CONSTEXPR variables const. NFC.George Burgess IV2016-08-251-1/+1
| | | | | | | | | | This patch changes LLVM_CONSTEXPR variable declarations to const variable declarations, since LLVM_CONSTEXPR expands to nothing if the current compiler doesn't support constexpr. In all of the changed cases, it looks like the code intended the variable to be const instead of sometimes-constexpr sometimes-not. llvm-svn: 279696
* Use range algorithms instead of unpacking begin/endDavid Majnemer2016-08-111-11/+10
| | | | | | No functionality change is intended. llvm-svn: 278417
* Fix -Wreturn-type with gcc 4.8 and libc++Matt Arsenault2016-07-181-1/+1
| | | | llvm-svn: 275922
* Add getReturnedArgOperand to Call/InvokeInst, CallSiteHal Finkel2016-07-101-2/+5
| | | | | | | | | | | | | | | In order to make the optimizer smarter about using the 'returned' argument attribute (generally, but motivated by my llvm.noalias intrinsic work), add a utility function to Call/InvokeInst, and CallSite, to make it easy to get the returned call argument (when one exists). P.S. There is already an unfortunate amount of code duplication between CallInst and InvokeInst, and this adds to it. We should probably clean that up separately. Differential Revision: http://reviews.llvm.org/D22204 llvm-svn: 275031
* Add writeonly IR attributeNicolai Haehnle2016-07-041-0/+3
| | | | | | | | | | | | | | | | | Summary: This complements the earlier addition of IntrWriteMem and IntrWriteArgMem LLVM intrinsic properties, see D18291. Also start using the attribute for memset, memcpy, and memmove intrinsics, and remove their special-casing in BasicAliasAnalysis. Reviewers: reames, joker.eph Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D18714 llvm-svn: 274485
* Apply clang-tidy's modernize-loop-convert to most of lib/IR.Benjamin Kramer2016-06-261-23/+23
| | | | | | Only minor manual fixes. No functionality change intended. llvm-svn: 273813
* Add support for string attributes in the C API.Amaury Sechet2016-06-151-0/+14
| | | | | | | | | | | | 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
* Rename AttributeSetImpl::NumAttrs and AttributeSetImpl::getNumAttributes to ↵Amaury Sechet2016-06-141-15/+15
| | | | | | | | | | | | reflect that they work on slots rather than attributes. NFC Summary: The current naming not only doesn't convey the meaning of what this does, but worse, it convey the wrong meaning. This was a major source of confusion understanding the code, so I'm applying the boy scout rule here and making it better after I leave. Reviewers: void, bkramer, whitequark Differential Revision: http://reviews.llvm.org/D21264 llvm-svn: 272725
* Make sure attribute kind and attributes are named respectively Kind and Attr ↵Amaury Sechet2016-06-141-15/+8
| | | | | | consistently. Historically they used to be the same the terminology is very confused in the codebase. NFC. llvm-svn: 272704
* Use 'auto' to avoid implicit copies.Benjamin Kramer2016-06-121-1/+1
| | | | | | | | | | | | | td_type is std::pair<std::string, std::string>, but the map returns elements of std::pair<const std::string, std::string>. In well-designed languages like C++ that yields an implicit copy perfectly hidden by constref's lifetime extension. Just use auto, the typedef obscured the real type anyways. Found with a little help from clang-tidy's performance-implicit-cast-in-loop. llvm-svn: 272519
* Attempt to make buildbot happier with r266032.George Burgess IV2016-04-121-2/+1
| | | | | | | Apparently std::numeric_limits<unsigned>::max() isn't constexpr everywhere yet. llvm-svn: 266034
* Add the allocsize attribute to LLVM.George Burgess IV2016-04-121-5/+128
| | | | | | | | | | | | | | | | `allocsize` is a function attribute that allows users to request that LLVM treat arbitrary functions as allocation functions. This patch makes LLVM accept the `allocsize` attribute, and makes `@llvm.objectsize` recognize said attribute. The review for this was split into two patches for ease of reviewing: D18974 and D14933. As promised on the revisions, I'm landing both patches as a single commit. Differential Revision: http://reviews.llvm.org/D14933 llvm-svn: 266032
* [safestack] Add canary to unsafe stack framesEvgeniy Stepanov2016-04-111-7/+1
| | | | | | | | Add StackProtector to SafeStack. This adds limited protection against data corruption in the caller frame. Current implementation treats all stack protector levels as -fstack-protector-all. llvm-svn: 266004
* Fix non-determinism in order of LLVM attributesReid Kleckner2016-04-041-2/+6
| | | | | | | | | | | | | | | | | | We were using array_pod_sort on an array of type 'Attribute', which wraps a pointer to AttributeImpl. For the most part this didn't matter because the printing code prints enum attributes in a defined order, but integer attributes such as 'align' and 'dereferenceable' were not ordered. Furthermore, AttributeImpl::operator< was broken for integer attributes. An integer attribute is a kind and an integer value, and both pieces need to be compared. By fixing the comparison operator, we can go back to std::sort, and things look good now. This should fix clang arm-swiftcall.c test failures on Windows. llvm-svn: 265361
* Swift Calling Convention: add swifterror attribute.Manman Ren2016-04-011-0/+3
| | | | | | | | | | | | 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
* Swift Calling Convention: add swiftself attribute.Manman Ren2016-03-291-0/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D17866 llvm-svn: 264754
* AttributeSetImpl: Summarize existing function attributes in a bitset.Matthias Braun2016-01-291-0/+4
| | | | | | | | | | | The majority of attribute queries checks for the existence of an enum attribute in the FunctionIndex slot. We only have 48 of those and can therefore summarize them in an uint64_t bitset which measurably improves compile time. Differential Revision: http://reviews.llvm.org/D16618 llvm-svn: 259252
* AttributeSetNode: Summarize existing attributes in a bitset.Matthias Braun2016-01-291-10/+5
| | | | | | | | | | | The majority of queries just checks for the existince of an enum attribute. We only have 48 of those and can summaryiz them in an uint64_t bitfield so we can avoid searching the list. This improves "opt" compile time by 1-4% in my measurements. Differential Revision: http://reviews.llvm.org/D16617 llvm-svn: 259251
* Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren2016-01-291-2/+2
| | | | | | | | r259192 post commit comment. clang part in r259232, this is the LLVM part of the patch. llvm-svn: 259240
* Remove duplicate documentation in Attributes.cpp. NFC.Manuel Jacob2016-01-231-10/+0
| | | | | | The documentation for these methods is already present in the header. llvm-svn: 258648
* Use std::is_sorted and std::none_of instead of manual loops. NFCCraig Topper2016-01-031-8/+9
| | | | llvm-svn: 256719
* Provide a way to specify inliner's attribute compatibility and merging.Akira Hatanaka2015-12-221-0/+78
| | | | | | | | | | | | | | | | | | | | | This reapplies r256277 with two changes: - In emitFnAttrCompatCheck, change FuncName's type to std::string to fix a use-after-free bug. - Remove an unnecessary install-local target in lib/IR/Makefile. Original commit message for r252949: Provide a way to specify inliner's attribute compatibility and merging rules using table-gen. NFC. This commit adds new classes CompatRule and MergeRule to Attributes.td, which are used to generate code to check attribute compatibility and merge attributes of the caller and callee. rdar://problem/19836465 llvm-svn: 256304
* Revert r256277 and r256279.Akira Hatanaka2015-12-221-78/+0
| | | | | | Some of the bots failed again. llvm-svn: 256280
OpenPOWER on IntegriCloud