-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[SystemZ] Add check for INIT_UNDEF in getInstSizeInBytes #134661
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
@llvm/pr-subscribers-backend-systemz Author: None (tltao) ChangesDue to some optimization changes, INIT_UNDEF is making its way to Full diff: https://github.com/llvm/llvm-project/pull/134661.diff 2 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h
index 102b1eb07358e..cd7b3055ad722 100644
--- a/llvm/include/llvm/CodeGen/MachineInstr.h
+++ b/llvm/include/llvm/CodeGen/MachineInstr.h
@@ -1409,6 +1409,7 @@ class MachineInstr
}
bool isKill() const { return getOpcode() == TargetOpcode::KILL; }
bool isImplicitDef() const { return getOpcode()==TargetOpcode::IMPLICIT_DEF; }
+ bool isInitUndef() const { return getOpcode()==TargetOpcode::INIT_UNDEF; }
bool isInlineAsm() const {
return getOpcode() == TargetOpcode::INLINEASM ||
getOpcode() == TargetOpcode::INLINEASM_BR;
diff --git a/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp b/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp
index f19b932f3c731..f0f33c960d822 100644
--- a/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp
@@ -218,6 +218,7 @@ static unsigned getInstSizeInBytes(const MachineInstr &MI,
// These do not have a size:
MI.isDebugOrPseudoInstr() || MI.isPosition() || MI.isKill() ||
MI.isImplicitDef() || MI.getOpcode() == TargetOpcode::MEMBARRIER ||
+ MI.isInitUndef() ||
// These have a size that may be zero:
MI.isInlineAsm() || MI.getOpcode() == SystemZ::STACKMAP ||
MI.getOpcode() == SystemZ::PATCHPOINT ||
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
@@ -1409,6 +1409,7 @@ class MachineInstr | |||
} | |||
bool isKill() const { return getOpcode() == TargetOpcode::KILL; } | |||
bool isImplicitDef() const { return getOpcode()==TargetOpcode::IMPLICIT_DEF; } | |||
bool isInitUndef() const { return getOpcode() == TargetOpcode::INIT_UNDEF; } |
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 don't think this is common enough to warrant a dedicated accessor.
We probably should be more generic here and check for |
I believe @nikic tried this in the original PR #106744, but ultimately decided against it as it caused more changes. Perhaps a compromise can be to fix it with |
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.
This looks fine to me, but should it also have a test?
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, thanks!
Due to some optimization changes, INIT_UNDEF is making its way to `getInstSizeInBytes` in `llvm/lib/Target/SystemZ/SystemZLongBranch.cpp` but we do not have an exception there in the assert. Since INIT_UNDEF is described as being similar to IMPLICIT_DEF and there is a check for IMPLICIT_DEF, it seems logical to also add a check for INIT_UNDEF. --------- Co-authored-by: Tony Tao <[email protected]>
Due to some optimization changes, INIT_UNDEF is making its way to
getInstSizeInBytes
inllvm/lib/Target/SystemZ/SystemZLongBranch.cpp
but we do not have an exception there in the assert. Since INIT_UNDEF is described as being similar to IMPLICIT_DEF and there is a check for IMPLICIT_DEF, it seems logical to also add a check for INIT_UNDEF.