This is an archive of the discontinued LLVM Phabricator instance.

[Clang][Driver] Add KCFI to SupportsCoverage
ClosedPublic

Authored by samitolvanen on Nov 21 2022, 1:29 PM.

Details

Summary

Allow -fsanitize=kcfi to be enabled with -fsanitize-coverage= modes
such as trace-{pc,cmp}.

Link: https://github.com/ClangBuiltLinux/linux/issues/1743

Diff Detail

Event Timeline

samitolvanen created this revision.Nov 21 2022, 1:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2022, 1:29 PM
samitolvanen requested review of this revision.Nov 21 2022, 1:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2022, 1:29 PM
MaskRay accepted this revision.Nov 21 2022, 1:37 PM

with -fsanitize=trace-{pc,cmp}.

-fsanitize-coverage= modes such as trace-{pc,cmp}.

(a) It's -fsanitize-coverage=, not -fsanitize-coverage=trace-{pc,cmp}.
(b) -fsanitize=trace-{pc,cmp} may feel that they are the only modes, but SanitizerCoverage has much more modes than the mentioned two.

clang/test/CodeGen/sanitize-coverage.c
92

One call void @__sanitizer_cov_trace is probably sufficient.

94

%c()

{{.}} matches one byte. Just write the byte.

This revision is now accepted and ready to land.Nov 21 2022, 1:37 PM
samitolvanen marked an inline comment as done.

Addressed feedback.

clang/test/CodeGen/sanitize-coverage.c
94

%c()

{{.}} matches one byte. Just write the byte.

I do want to match just one byte, but the actual byte changes depending on how many statements there are in the function, so matching any byte seems less fragile. %c would match literally just %c. Am I missing some neat FileCheck trick here that would save me a ton of typing in future...?

samitolvanen edited the summary of this revision. (Show Details)Nov 21 2022, 3:06 PM
MaskRay added inline comments.Nov 21 2022, 6:23 PM
clang/test/CodeGen/sanitize-coverage.c
94

Ah, ok, it's an unnamed value. [[#]] can match %1 %2 ...

samitolvanen marked 2 inline comments as done.

Switched to [[#]].

MaskRay accepted this revision.Nov 22 2022, 9:27 AM
This revision was automatically updated to reflect the committed changes.