KCFI traps should always be recoverable, but as Intrinsic::trap
is marked noreturn, it's not possible to continue execution after
handling the trap as the compiler is free to assume we never
return. Switch to debugtrap instead to ensure we have the option
to resume execution after the trap.
Instruction *ThenTerm =
SplitBlockAndInsertIfThen(Test, Call, false, VeryUnlikelyWeights);
Builder.SetInsertPoint(ThenTerm);
- Builder.CreateCall(Intrinsic::getDeclaration(&M, Intrinsic::trap));
+ Builder.CreateCall(Intrinsic::getDeclaration(&M, Intrinsic::debugtrap));
++NumKCFIChecks;
}
; CHECK-NEXT: %[[#ICMP:]] = icmp ne i32 %[[#LOAD]], 12345678
; CHECK-NEXT: br i1 %[[#ICMP]], label %[[#TRAP:]], label %[[#CALL:]], !prof ![[#WEIGHTS:]]
; CHECK: [[#TRAP]]:
- ; CHECK-NEXT: call void @llvm.trap()
+ ; CHECK-NEXT: call void @llvm.debugtrap()
; CHECK-NEXT: br label %[[#CALL]]
; CHECK: [[#CALL]]:
; CHECK-NEXT: call void %x()