From 8ef823b70da7f320791dcbac170ad4201fbf68d8 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Fri, 1 Nov 2024 00:38:49 +0800 Subject: [PATCH] minor cleanup --- include/luisa/xir/ilist.h | 1 - include/luisa/xir/instructions/branch.h | 4 ++-- include/luisa/xir/instructions/outline.h | 4 ++-- include/luisa/xir/instructions/unreachable.h | 2 +- include/luisa/xir/metadata.h | 4 ++-- include/luisa/xir/use.h | 2 +- src/xir/basic_block.cpp | 5 ++++- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/luisa/xir/ilist.h b/include/luisa/xir/ilist.h index e79d26099..bd8e6a48c 100644 --- a/include/luisa/xir/ilist.h +++ b/include/luisa/xir/ilist.h @@ -4,7 +4,6 @@ #include namespace luisa::compute::xir { - template class IntrusiveNode; diff --git a/include/luisa/xir/instructions/branch.h b/include/luisa/xir/instructions/branch.h index ef543c35e..6e1d08f5e 100644 --- a/include/luisa/xir/instructions/branch.h +++ b/include/luisa/xir/instructions/branch.h @@ -4,12 +4,12 @@ namespace luisa::compute::xir { -class BranchInst : public DerivedBranchInstruction { +class BranchInst final : public DerivedBranchInstruction { public: using DerivedBranchInstruction::DerivedBranchInstruction; }; -class ConditionalBranchInst : public DerivedConditionalBranchInstruction { +class ConditionalBranchInst final : public DerivedConditionalBranchInstruction { public: using DerivedConditionalBranchInstruction::DerivedConditionalBranchInstruction; }; diff --git a/include/luisa/xir/instructions/outline.h b/include/luisa/xir/instructions/outline.h index f666cd92c..1205ce172 100644 --- a/include/luisa/xir/instructions/outline.h +++ b/include/luisa/xir/instructions/outline.h @@ -6,8 +6,8 @@ namespace luisa::compute::xir { class BasicBlock; -class LC_XIR_API OutlineInst final : public DerivedBranchInstruction, - public InstructionMergeMixin { +class OutlineInst final : public DerivedBranchInstruction, + public InstructionMergeMixin { public: using DerivedBranchInstruction::DerivedBranchInstruction; }; diff --git a/include/luisa/xir/instructions/unreachable.h b/include/luisa/xir/instructions/unreachable.h index bbb59b201..315c04203 100644 --- a/include/luisa/xir/instructions/unreachable.h +++ b/include/luisa/xir/instructions/unreachable.h @@ -5,7 +5,7 @@ namespace luisa::compute::xir { // Note: this instruction must be the terminator of a basic block. -class LC_XIR_API UnreachableInst final : public DerivedTerminatorInstruction { +class UnreachableInst final : public DerivedTerminatorInstruction { public: using DerivedTerminatorInstruction::DerivedTerminatorInstruction; }; diff --git a/include/luisa/xir/metadata.h b/include/luisa/xir/metadata.h index 2cc1da478..84e8b3dc6 100644 --- a/include/luisa/xir/metadata.h +++ b/include/luisa/xir/metadata.h @@ -11,7 +11,7 @@ enum struct DerivedMetadataTag { COMMENT, }; -class LC_XIR_API Metadata : public IntrusiveForwardNode { +class Metadata : public IntrusiveForwardNode { public: using Super::Super; [[nodiscard]] virtual DerivedMetadataTag derived_metadata_tag() const noexcept = 0; @@ -49,7 +49,7 @@ template class MetadataMixin { private: - MetadataList _metadata_list; + MetadataList _metadata_list{}; private: [[nodiscard]] Pool *_get_pool_from_parent() noexcept { diff --git a/include/luisa/xir/use.h b/include/luisa/xir/use.h index dcbde73cb..e6bc067e0 100644 --- a/include/luisa/xir/use.h +++ b/include/luisa/xir/use.h @@ -7,7 +7,7 @@ namespace luisa::compute::xir { class Value; class User; -class LC_XIR_API Use : public IntrusiveForwardNode { +class LC_XIR_API Use final : public IntrusiveForwardNode { private: User *_user; diff --git a/src/xir/basic_block.cpp b/src/xir/basic_block.cpp index e2a333747..4541c9a68 100644 --- a/src/xir/basic_block.cpp +++ b/src/xir/basic_block.cpp @@ -3,6 +3,9 @@ namespace luisa::compute::xir { BasicBlock::BasicBlock(Pool *pool) noexcept - : DerivedValue{pool, nullptr}, _instructions{pool} {} + : DerivedValue{pool, nullptr}, _instructions{pool} { + _instructions.head_sentinel()->_set_parent_block(this); + _instructions.tail_sentinel()->_set_parent_block(this); +} }// namespace luisa::compute::xir