forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the 'initializes' attribute langref and support (llvm#84803)
We propose adding a new LLVM attribute, `initializes((Lo1,Hi1),(Lo2,Hi2),...)`, which expresses the notion of memory space (i.e., intervals, in bytes) that the argument pointing to is initialized in the function. Will commit the attribute inferring in the follow-up PRs. https://discourse.llvm.org/t/rfc-llvm-new-initialized-parameter-attribute-for-improved-interprocedural-dse/77337
- Loading branch information
1 parent
a9da344
commit 9932968
Showing
23 changed files
with
730 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#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) { | ||
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(); } | ||
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; } | ||
|
||
/// Return the number of ranges in this ConstantRangeList. | ||
size_t size() const { return Ranges.size(); } | ||
|
||
/// 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; | ||
#endif | ||
}; | ||
|
||
} // end namespace llvm | ||
|
||
#endif // LLVM_IR_CONSTANTRANGELIST_H |
This file contains 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 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.