================ @@ -50,6 +51,41 @@ findCallsAtConstantOffset(SmallVectorImpl<DevirtCallSite> &DevirtCalls, } } +static bool hasTypeIdLoadAtConstantOffset(const Module *M, Value *VPtr, + int64_t Offset, const CallInst *CI, + CXXABI *ABI) { + bool HasTypeIdLoad = false; + for (const Use &U : VPtr->uses()) { + Value *User = U.getUser(); + if (isa<BitCastInst>(User)) { + HasTypeIdLoad |= hasTypeIdLoadAtConstantOffset(M, User, Offset, CI, ABI); + } else if (isa<LoadInst>(User)) { + if (Offset == + ABI->getOffsetFromTypeInfoSlotToAddressPoint(M->getDataLayout())) + return true; + } else if (auto GEP = dyn_cast<GetElementPtrInst>(User)) { + // Take into account the GEP offset. + if (VPtr == GEP->getPointerOperand() && GEP->hasAllConstantIndices()) { + SmallVector<Value *, 8> Indices(drop_begin(GEP->operands())); + int64_t GEPOffset = M->getDataLayout().getIndexedOffsetInType( + GEP->getSourceElementType(), Indices); + HasTypeIdLoad |= + hasTypeIdLoadAtConstantOffset(M, User, Offset + GEPOffset, CI, ABI); + } + } else if (auto *Call = dyn_cast<CallInst>(User)) { + if (Call->getIntrinsicID() == llvm::Intrinsic::load_relative) { + if (auto *LoadOffset = dyn_cast<ConstantInt>(Call->getOperand(1))) { + HasTypeIdLoad |= + hasTypeIdLoadAtConstantOffset(M, User, Offset, CI, ABI); + } + } + } else { + HasTypeIdLoad = true; + } ---------------- luxufan wrote:
Thank you for testing this patch and providing the test case. I have fixed the issue and added it as a test case. https://github.com/llvm/llvm-project/pull/126336 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits