-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[sanitizer] Add plumbing for -fsanitize-annotate-debug-info and partly replace '-mllvm -array-bounds-pseudofn' #138577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
1cb28ef
959cbe0
31cdd17
8cdce5e
9380a10
74cd26a
de25cce
d25206a
25c3fce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2533,6 +2533,31 @@ def fno_sanitize_merge_handlers : Flag<["-"], "fno-sanitize-merge">, Group<f_cla | |||||||||
| Alias<fno_sanitize_merge_handlers_EQ>, AliasArgs<["all"]>, | ||||||||||
| Visibility<[ClangOption, CLOption]>, | ||||||||||
| HelpText<"Do not allow compiler to merge handlers for any sanitizers">; | ||||||||||
| def fsanitize_annotate_debug_info_EQ | ||||||||||
| : CommaJoined<["-"], "fsanitize-annotate-debug-info=">, | ||||||||||
| Group<f_clang_Group>, | ||||||||||
| HelpText<"Annotate checks with debug info for specified sanitizers, if " | ||||||||||
| "supported">; | ||||||||||
|
||||||||||
| HelpText<"Annotate checks with debug info for specified sanitizers, if " | |
| "supported">; | |
| HelpText<"Annotate sanitizer instrumentation with extra debug info for the specified sanitizers, if " | |
| "supported">; |
My thinking is
- Replace
checkswithinstrumentationbecause not all instrumentation is necessarily a check. E.g. I think stack poisoning is done with instrumentation and that's not a "check". - Say "extra debug info" since this is additional information on top of normal debug info
- Add missing "the"
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| HelpText<"Do not allow compiler to annotate checks with debug info for " | |
| "specified sanitizers">; | |
| HelpText<"Do not allow compiler to annotate checks with debug info for " | |
| "the specified sanitizers">; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1228,7 +1228,11 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr *E, llvm::Value *Bound, | |
| SanitizerScope SanScope(this); | ||
|
|
||
| llvm::DILocation *CheckDI = Builder.getCurrentDebugLocation(); | ||
| if (ClArrayBoundsPseudoFn && CheckDI) { | ||
| auto CurrentCheckKind = SanitizerKind::SO_ArrayBounds; | ||
| // TODO: deprecate ClArrayBoundsPseudoFn | ||
| if ((ClArrayBoundsPseudoFn || | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add TODO to clean up mllvm flag
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be nice to make clear that SO_ArrayBounds here is the same as on line 1252
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added CurrentCheckKind (there is already a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would drop the Current then for symmety
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo.has(CurrentCheckKind)) && | ||
| CheckDI) { | ||
| CheckDI = getDebugInfo()->CreateSyntheticInlineAt( | ||
| Builder.getCurrentDebugLocation(), "__ubsan_check_array_bounds"); | ||
| } | ||
|
|
@@ -1245,7 +1249,7 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr *E, llvm::Value *Bound, | |
| }; | ||
| llvm::Value *Check = Accessed ? Builder.CreateICmpULT(IndexVal, BoundVal) | ||
| : Builder.CreateICmpULE(IndexVal, BoundVal); | ||
| EmitCheck(std::make_pair(Check, SanitizerKind::SO_ArrayBounds), | ||
| EmitCheck(std::make_pair(Check, CurrentCheckKind), | ||
| SanitizerHandler::OutOfBounds, StaticData, Index); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.