[llvm] [MergeFunc] Preserve observable function pointer identity (PR #213604)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 24 00:45:17 PDT 2026


================
@@ -964,11 +965,20 @@ int FunctionComparator::cmpBasicBlocks(const BasicBlock *BBL,
       return Res;
     if (needToCmpOperands) {
       assert(InstL->getNumOperands() == InstR->getNumOperands());
+      const auto *CBL = dyn_cast<CallBase>(&*InstL);
 
       for (unsigned i = 0, e = InstL->getNumOperands(); i != e; ++i) {
         Value *OpL = InstL->getOperand(i);
         Value *OpR = InstR->getOperand(i);
-        if (int Res = cmpValues(OpL, OpR))
+        int Res;
+        if (CBL && CBL->isCallee(&InstL->getOperandUse(i))) {
+          assert(isa<CallBase>(&*InstR) &&
----------------
nikic wrote:

The isa assert is implied by the `cast<>`.

https://github.com/llvm/llvm-project/pull/213604


More information about the llvm-commits mailing list