pcc added inline comments. ================ Comment at: lib/CodeGen/CGExpr.cpp:2620 @@ +2619,3 @@ + Builder.CreateICmpEQ(Data, llvm::ConstantPointerNull::get(Int8PtrTy)); + Builder.CreateCondBr(DataIsNullPtr, TrapBB, ContBB); + ---------------- This looks like `CodeGenFunction::EmitTrapCheck`.
================ Comment at: lib/CodeGen/CGExpr.cpp:2654-2678 @@ +2653,27 @@ + for (auto CheckKindMaskPair : CheckKinds) { + int Kind = CheckKindMaskPair.first; + SanitizerMask Mask = CheckKindMaskPair.second; + // All CFI checks are recoverable. + assert(getRecoverableKind(Mask) == CheckRecoverableKind::Recoverable); + if (CGM.getCodeGenOpts().SanitizeTrap.has(Mask)) { + SI->addCase(llvm::ConstantInt::get(Int8Ty, Kind), TrapBB); + } else if (CGM.getCodeGenOpts().SanitizeRecover.has(Mask)) { + if (!RecoverBB) { + RecoverBB = createBasicBlock("non_fatal"); + EmitBlock(RecoverBB); + emitCheckHandlerCall(*this, F->getFunctionType(), {Data, Addr}, + "cfi_check_fail", + CheckRecoverableKind::Recoverable, false, ExitBB); + } + SI->addCase(llvm::ConstantInt::get(Int8Ty, Kind), RecoverBB); + } else { + if (!FatalBB) { + FatalBB = createBasicBlock("fatal"); + EmitBlock(FatalBB); + emitCheckHandlerCall(*this, F->getFunctionType(), {Data, Addr}, + "cfi_check_fail", + CheckRecoverableKind::Recoverable, true, ExitBB); + } + SI->addCase(llvm::ConstantInt::get(Int8Ty, Kind), FatalBB); + } + } ---------------- Can't you replace all this code with a call to `EmitCheck` passing `icmp`s for each of the check kinds? Sure, it wouldn't be a switch, but we don't care about the performance of this code anyway. ================ Comment at: lib/CodeGen/CodeGenFunction.h:1386 @@ -1385,3 +1385,3 @@ - enum CFITypeCheckKind { + enum CFICheckKind { CFITCK_VCall, ---------------- No need to rename, these are still all type checks. ================ Comment at: test/CodeGen/cfi-icall-cross-dso.c:28 @@ -22,3 +27,3 @@ // ITANIUM: call i1 @llvm.bitset.test(i8* %{{.*}}, metadata !"_ZTSFvE"), !nosanitize -// ITANIUM: call void @__cfi_slowpath(i64 6588678392271548388, i8* %{{.*}}) {{.*}}, !nosanitize +// ITANIUM: call void @__cfi_slowpath_diag(i64 6588678392271548388, i8* %{{.*}}, {{.*}}@[[DATA]]{{.*}}, !nosanitize ---------------- Are you still testing the `__cfi_slowpath` code path? Repository: rL LLVM http://reviews.llvm.org/D15699 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits