[llvm] d65c052 - change checking for auto-init metadata to use `equalsStr` instead of casing MDOperand nodes.
Zain Jaffal via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 8 07:58:16 PDT 2023
Author: Zain Jaffal
Date: 2023-06-08T15:58:01+01:00
New Revision: d65c0527ab70b8089492b6788c0e2ea0cfa219e6
URL: https://github.com/llvm/llvm-project/commit/d65c0527ab70b8089492b6788c0e2ea0cfa219e6
DIFF: https://github.com/llvm/llvm-project/commit/d65c0527ab70b8089492b6788c0e2ea0cfa219e6.diff
LOG: change checking for auto-init metadata to use `equalsStr` instead of casing MDOperand nodes.
Since `MD_annotation` metadata now supports having mutliple strings in the annotation node. casing Operand to string directly will cause a crash. When checking if `MDOperand` equals str you can use `equalsStr` method.
Reviewed By: serge-sans-paille
Differential Revision: https://reviews.llvm.org/D152372
Added:
Modified:
llvm/lib/Transforms/Utils/MoveAutoInit.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/MoveAutoInit.cpp b/llvm/lib/Transforms/Utils/MoveAutoInit.cpp
index 21249bd2cf83c..b0ca0b15c08e0 100644
--- a/llvm/lib/Transforms/Utils/MoveAutoInit.cpp
+++ b/llvm/lib/Transforms/Utils/MoveAutoInit.cpp
@@ -40,9 +40,7 @@ static cl::opt<unsigned> MoveAutoInitThreshold(
static bool hasAutoInitMetadata(const Instruction &I) {
return I.hasMetadata(LLVMContext::MD_annotation) &&
any_of(I.getMetadata(LLVMContext::MD_annotation)->operands(),
- [](const MDOperand &Op) {
- return cast<MDString>(Op.get())->getString() == "auto-init";
- });
+ [](const MDOperand &Op) { return Op.equalsStr("auto-init"); });
}
static std::optional<MemoryLocation> writeToAlloca(const Instruction &I) {
More information about the llvm-commits
mailing list