Skip to content

Commit

Permalink
change checking for auto-init metadata to use equalsStr instead of …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Zain Jaffal committed Jun 8, 2023
1 parent fa6b7dd commit d65c052
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/Utils/MoveAutoInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d65c052

Please sign in to comment.