[llvm] Fix: Distinguish CFI Metadata Checks in MergeFunctions Pass (PR #65963)
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 11 07:15:37 PDT 2023
================
@@ -836,6 +837,54 @@ int FunctionComparator::cmpValues(const Value *L, const Value *R) const {
return cmpNumbers(LeftSN.first->second, RightSN.first->second);
}
+int FunctionComparator::cmpDistinctMetadata(const Function *L,
+ const Function *R) {
+ // Iterate over the basic blocks and instructions in Function L
+ for (const BasicBlock &BBL : *L) {
+ for (const Instruction &InstL : BBL) {
+ for (unsigned i = 0, e = InstL.getNumOperands(); i != e; ++i) {
+ if (MetadataAsValue *MDL =
+ dyn_cast<MetadataAsValue>(InstL.getOperand(i))) {
----------------
dexonsmith wrote:
I think the early return pattern should be used to reduce nesting:
```
MetadataAsValue *MDL = ...;
if (!MDL)
continue;
```
There are many other instances of this below.
https://github.com/llvm/llvm-project/pull/65963
More information about the llvm-commits
mailing list