aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorShubham Sandeep Rastogi <srastogi22@apple.com>2024-02-05 15:30:35 -0800
committerShubham Sandeep Rastogi <srastogi22@apple.com>2024-02-05 15:33:21 -0800
commit6ce03ff3fef8fb6fa9afe8eb22c6d98bced26d48 (patch)
tree472afc99e6540b0675b4b56b172cd7aefc6fc291 /llvm/lib/IR/Function.cpp
parenta7bc9cb6ffa91ff0ebabc45c0c7263c7c2c3a4de (diff)
downloadllvm-6ce03ff3fef8fb6fa9afe8eb22c6d98bced26d48.zip
llvm-6ce03ff3fef8fb6fa9afe8eb22c6d98bced26d48.tar.gz
llvm-6ce03ff3fef8fb6fa9afe8eb22c6d98bced26d48.tar.bz2
Revert "[IR] Use range-based for loops (NFC)"
This reverts commit e8512786fedbfa6ddba70ceddc29d7122173ba5e. This revert is done because llvm::drop_begin over an empty ArrayRef doesn't return an empty range, and therefore can lead to an invalid address returned instead. See discussion in https://github.com/llvm/llvm-project/pull/80737 for more context.
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index d3e2ae0..22e2455 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -1976,9 +1976,10 @@ DenseSet<GlobalValue::GUID> Function::getImportGUIDs() const {
if (MDNode *MD = getMetadata(LLVMContext::MD_prof))
if (MDString *MDS = dyn_cast<MDString>(MD->getOperand(0)))
if (MDS->getString().equals("function_entry_count"))
- for (const MDOperand &MDO : llvm::drop_begin(MD->operands(), 2))
- R.insert(
- mdconst::extract<ConstantInt>(MDO)->getValue().getZExtValue());
+ for (unsigned i = 2; i < MD->getNumOperands(); i++)
+ R.insert(mdconst::extract<ConstantInt>(MD->getOperand(i))
+ ->getValue()
+ .getZExtValue());
return R;
}