-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Add the 'initializes' attribute langref and support #84803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
2554c82
Add 'initialized' attribute langref
haopliu a9256bf
Update the LangRef
haopliu 9150ece
Refactor the argument uses collecting to a function
haopliu 206b707
Add 'initialized' attribute support and undo the FunctionAttrs refact…
haopliu eaf5ca0
Update the LangRef (round 2)
haopliu 52cc649
Update FoldingSet.h
haopliu f7fddb0
Change the attribute type to ConstantRangeList
haopliu 3b5955a
Rename attr to initializes
haopliu 6a1df7a
Update CRL about accessing the range of an EmptySet/FullSet
haopliu fe2e0a5
Change CRL.insert to be ordered and no overlapping
haopliu f73df04
Optimize CRL::insert for common cases
haopliu 63c45f6
Update ConstantRangeList
haopliu dcc2b38
Add unit tests for BitcodeReader/Verifier/Assembler
haopliu 9723322
Add a space after commas
haopliu e70988d
Update CRL and unit tests
haopliu 9782c31
Update CRL to merge consecutive ranges
haopliu a924dd3
Handle a common case in CRL::insert and add CRL::dump
haopliu 45cdc34
Nit: change dbgs() to llvm::dbgs()
haopliu 4eeba08
Change the attr impl to TrailingObjects<ConstantRange>
haopliu 502e062
Update LLVMContextImpl.h
haopliu fac03b8
Merge branch 'llvm:main' into dse-commit
haopliu ea3e7c5
Rebase to the latest main
haopliu 7630510
Change getInitializes() to return ArrayRef<ConstantRange>
haopliu a604b4f
Remove llvm::
haopliu f941b24
Update LangRef and ConstantRangeList
haopliu e52fd9d
Update BitCodeReader/Writer
haopliu 8e64fa9
Encode bitwidth once for ConstantRangeList kind attr
haopliu 9ae0fca
Use SpecificBumpPtrAllocator to allocate mem and make sure to call de…
haopliu d4809ab
Refactor readConstantRange and update BitcodeReader
haopliu 99d36cc
Merge branch 'main' into dse-commit
haopliu 96191cd
Change the attr imple back to ConstantRangeList
haopliu 645f577
Add getConstantRangeList unittest
haopliu 2a8ea9a
Add Bitwidth in FoldingSetNodeId
haopliu 37edecd
Merge branch 'main' into dse-commit
haopliu 80306d7
Clean up a redundant check in BitcodeReader
haopliu 67445fe
Change attr impl to normal Alloc w/ a vector and call dtor for each a…
haopliu 68643a5
nit: use uninitialized_copy in the ConstantRangeListAttributeImpl ctor
haopliu 46e8d87
Remove redundant BitWidth in the attr Profile as APInt::Profile alrea…
haopliu 714d02f
Use ConstantRange::contains() in ConstantRangeList::insert()
haopliu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
//===- ConstantRangeList.h - A list of constant ranges ----------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Represent a list of signed ConstantRange and do NOT support wrap around the | ||
// end of the numeric range. Ranges in the list are ordered and not overlapping. | ||
// Ranges should have the same bitwidth. Each range's lower should be less than | ||
// its upper. | ||
nikic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_IR_CONSTANTRANGELIST_H | ||
#define LLVM_IR_CONSTANTRANGELIST_H | ||
|
||
#include "llvm/ADT/APInt.h" | ||
#include "llvm/IR/ConstantRange.h" | ||
#include "llvm/Support/Debug.h" | ||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
namespace llvm { | ||
|
||
class raw_ostream; | ||
|
||
/// This class represents a list of constant ranges. | ||
class [[nodiscard]] ConstantRangeList { | ||
SmallVector<ConstantRange, 2> Ranges; | ||
|
||
public: | ||
ConstantRangeList() = default; | ||
ConstantRangeList(ArrayRef<ConstantRange> RangesRef) { | ||
assert(isOrderedRanges(RangesRef)); | ||
for (const ConstantRange &R : RangesRef) { | ||
nikic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert(R.getBitWidth() == getBitWidth()); | ||
Ranges.push_back(R); | ||
} | ||
} | ||
|
||
// Return true if the ranges are non-overlapping and increasing. | ||
static bool isOrderedRanges(ArrayRef<ConstantRange> RangesRef); | ||
static std::optional<ConstantRangeList> | ||
getConstantRangeList(ArrayRef<ConstantRange> RangesRef); | ||
|
||
ArrayRef<ConstantRange> rangesRef() const { return Ranges; } | ||
SmallVectorImpl<ConstantRange>::iterator begin() { return Ranges.begin(); } | ||
aeubanks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SmallVectorImpl<ConstantRange>::iterator end() { return Ranges.end(); } | ||
SmallVectorImpl<ConstantRange>::const_iterator begin() const { | ||
return Ranges.begin(); | ||
} | ||
SmallVectorImpl<ConstantRange>::const_iterator end() const { | ||
return Ranges.end(); | ||
} | ||
ConstantRange getRange(unsigned i) const { return Ranges[i]; } | ||
|
||
/// Return true if this list contains no members. | ||
bool empty() const { return Ranges.empty(); } | ||
|
||
/// Get the bit width of this ConstantRangeList. | ||
uint32_t getBitWidth() const { return 64; } | ||
nikic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Return the number of ranges in this ConstantRangeList. | ||
size_t size() const { return Ranges.size(); } | ||
aeubanks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Insert a new range to Ranges and keep the list ordered. | ||
void insert(const ConstantRange &NewRange); | ||
void insert(int64_t Lower, int64_t Upper) { | ||
insert(ConstantRange(APInt(64, Lower, /*isSigned=*/true), | ||
APInt(64, Upper, /*isSigned=*/true))); | ||
} | ||
|
||
/// Return true if this range list is equal to another range list. | ||
bool operator==(const ConstantRangeList &CRL) const { | ||
return Ranges == CRL.Ranges; | ||
} | ||
bool operator!=(const ConstantRangeList &CRL) const { | ||
return !operator==(CRL); | ||
} | ||
|
||
/// Print out the ranges to a stream. | ||
void print(raw_ostream &OS) const; | ||
|
||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||
void dump() const; | ||
nikic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#endif | ||
}; | ||
|
||
} // end namespace llvm | ||
|
||
#endif // LLVM_IR_CONSTANTRANGELIST_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.