Skip to content

Commit 4dee58a

Browse files
committed
[Clang][CodeGen][UBSan] Bail out on DynamicTypeCacheMiss
1 parent 1ba2bc2 commit 4dee58a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3620,8 +3620,11 @@ static void emitCheckHandlerCall(CodeGenFunction &CGF,
36203620
// Add more precise attributes to recoverable ubsan handlers for better
36213621
// optimizations.
36223622
if (CGF.CGM.getCodeGenOpts().OptimizationLevel > 0 && MayReturn) {
3623-
B.addMemoryAttr(llvm::MemoryEffects::argMemOnly(llvm::ModRefInfo::Ref) |
3624-
llvm::MemoryEffects::inaccessibleMemOnly());
3623+
// __ubsan_handle_dynamic_type_cache_miss reads the vtable, which is also
3624+
// accessible by the current module.
3625+
if (CheckHandler != SanitizerHandler::DynamicTypeCacheMiss)
3626+
B.addMemoryAttr(llvm::MemoryEffects::argMemOnly(llvm::ModRefInfo::Ref) |
3627+
llvm::MemoryEffects::inaccessibleMemOnly());
36253628
// If the handler does not return, we must hit a undefined behavior.
36263629
B.addAttribute(llvm::Attribute::WillReturn);
36273630
}

0 commit comments

Comments
 (0)