-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SandboxIR] Implement LoadInst #99597
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
Conversation
} | ||
|
||
public: | ||
unsigned getUseOperandNo(const Use &Use) const final { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The final
confused me. It comes from User
. For style and safeness, I would mark it as override
first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm why would you mark it as override
? LoadInst
won't have subclasses so it should be safe to mark it final
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. But getUseOperandNo
overrides a virtual = 0 from User
. Once you mark it override
the compiler will do checks for you. override final
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think override final
is redundant, and I am not sure it's being used in LLVM. If you use final
the compiler will check that you are actually overriding and print an error if not, and on top of that it will also check that it is final.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. I found one occurrence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that LoadInst
is final, the finals are kind of redundant. Feel free to ignore, but override
would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't they still useful though? If you misspell a final
function name you will still get an error, but you won't get one if you just rely on the class being marked final
.
Well, I think I would prefer to stick with final
because it conveys both that it's overriden and that it's final.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. The class is marked final. You cannot inherit from anyway and overwriting the functions. My only confusion is that final is kind of redundant. override
is less confusing and gives the same compiler checks.
@@ -553,6 +557,50 @@ class Instruction : public sandboxir::User { | |||
#endif | |||
}; | |||
|
|||
class LoadInst : public Instruction { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is LoadInst
final?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can mark LoadInst
as final for documentation and optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
switch (cast<llvm::Instruction>(LLVMV)->getOpcode()) { | ||
case llvm::Instruction::Load: { | ||
auto *LLVMLd = cast<llvm::LoadInst>(LLVMV); | ||
It->second = std::unique_ptr<LoadInst>(new LoadInst(LLVMLd, *this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use std::make_unique
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just like the lines above we can't use make_unique
because the constructors are private.
I moved |
Pushed a forward declaration of LoadInst, which should fix the windows build. |
Removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This patch implements a `LoadInst` instruction in SandboxIR. It mirrors `llvm::LoadInst`.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/108/builds/1476 Here is the relevant piece of the build log for the reference:
|
Summary: This patch implements a `LoadInst` instruction in SandboxIR. It mirrors `llvm::LoadInst`. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251256
This patch implements a
LoadInst
instruction in SandboxIR. It mirrorsllvm::LoadInst
.