File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ class IR_API alignas(8) Operation final
277277 const uint32_t num_operands_ = 0 ;
278278 const uint32_t num_regions_ = 0 ;
279279 const uint32_t num_successors_ = 0 ;
280- const uint64_t id_ = 0 ;
280+ const uint64_t id_;
281281
282282 detail::BlockOperandImpl *block_operands_{nullptr };
283283 Region *regions_{nullptr };
Original file line number Diff line number Diff line change 3131
3232namespace pir {
3333bool Value::operator ==(const Value &other) const {
34- return impl_ == other.impl_ ;
34+ return impl_ == other.impl_ &&
35+ (impl_ == nullptr || impl_->id () == other.impl_ ->id ());
3536}
3637
3738bool Value::operator !=(const Value &other) const {
38- return impl_ != other. impl_ ;
39+ return !( operator ==( other)) ;
3940}
4041
4142bool Value::operator !() const { return impl_ == nullptr ; }
Original file line number Diff line number Diff line change 1313// limitations under the License.
1414#include " paddle/pir/core/value_impl.h"
1515
16+ namespace {
17+ uint64_t GenerateId () {
18+ static std::atomic<std::uint64_t > uid{0 };
19+ return ++uid;
20+ }
21+ } // namespace
1622namespace pir {
1723
1824namespace detail {
@@ -40,7 +46,7 @@ std::string ValueImpl::PrintUdChain() {
4046 result << " nullptr" ;
4147 return result.str ();
4248}
43- ValueImpl::ValueImpl (Type type, uint32_t kind) {
49+ ValueImpl::ValueImpl (Type type, uint32_t kind) : id_(GenerateId()) {
4450 if (kind > BLOCK_ARG_IDX) {
4551 LOG (FATAL) << " The kind of value_impl(" << kind
4652 << " ), is bigger than BLOCK_ARG_IDX(7)" ;
Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ class alignas(8) ValueImpl {
7171 return T::classof (*this );
7272 }
7373
74+ uint64_t id () const { return id_; }
75+
7476 protected:
7577 // /
7678 // / \brief Only can be constructed by derived classes such as OpResultImpl.
@@ -92,6 +94,8 @@ class alignas(8) ValueImpl {
9294 // / outline output(OpOutlineResultImpl); (3) index = 7 is reserved.
9395 // /
9496 OpOperandImpl *first_use_offseted_by_kind_ = nullptr ;
97+
98+ const uint64_t id_ = 0 ;
9599};
96100
97101} // namespace detail
You can’t perform that action at this time.
0 commit comments