================ @@ -3615,6 +3618,23 @@ static void emitCheckHandlerCall(CodeGenFunction &CGF, .addAttribute(llvm::Attribute::NoUnwind); } B.addUWTableAttr(llvm::UWTableKind::Default); + // Add more precise attributes to recoverable ubsan handlers for better + // optimizations. + if (CGF.CGM.getCodeGenOpts().OptimizationLevel > 0 && MayReturn) { + // __ubsan_handle_dynamic_type_cache_miss reads the vtable, which is also + // accessible by the current module. + if (CheckHandler != SanitizerHandler::DynamicTypeCacheMiss) { + llvm::MemoryEffects ME = + llvm::MemoryEffects::argMemOnly(llvm::ModRefInfo::Ref) | + llvm::MemoryEffects::inaccessibleMemOnly(); + if (MayReadFromPtrToInt) + ME |= llvm::MemoryEffects::readOnly(); + B.addMemoryAttr(ME); + } + // If the handler does not return, it must interact with the environment in + // an observable way. + B.addAttribute(llvm::Attribute::MustProgress); ---------------- efriedma-quic wrote:
I know this isn't new... but I don't think this "mustprogress" marking actually does anything useful. "mustprogress" is more a characteristic of function definitions, not calls. https://github.com/llvm/llvm-project/pull/135135 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits