Skip to content

[TableGen] Remove unnecessary const_cast and use range-based for loops. NFC #130717

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

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4139,23 +4139,19 @@ void CodeGenDAGPatterns::InferInstructionFlags() {

// If requested by the target, guess any undefined properties.
if (Target.guessInstructionProperties()) {
for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
CodeGenInstruction *InstInfo =
const_cast<CodeGenInstruction *>(Instructions[i]);
for (const CodeGenInstruction *InstInfo : Instructions) {
if (InstInfo->InferredFrom)
continue;
// The mayLoad and mayStore flags default to false.
// Conservatively assume hasSideEffects if it wasn't explicit.
if (InstInfo->hasSideEffects_Unset)
InstInfo->hasSideEffects = true;
const_cast<CodeGenInstruction *>(InstInfo)->hasSideEffects = true;
}
return;
}

// Complain about any flags that are still undefined.
for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
CodeGenInstruction *InstInfo =
const_cast<CodeGenInstruction *>(Instructions[i]);
for (const CodeGenInstruction *InstInfo : Instructions) {
if (InstInfo->InferredFrom)
continue;
if (InstInfo->hasSideEffects_Unset)
Expand Down