[Sanitizer] remove array-bounds-pseudofn#149430
Conversation
Created using spr 1.3.4
|
@llvm/pr-subscribers-debuginfo Author: Florian Mayer (fmayer) ChangesThis has been replaced by -fsanitize-annotate-debug-info Full diff: https://github.com/llvm/llvm-project/pull/149430.diff 1 Files Affected:
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 446cf8d9e05c6..d6a5c4c476d5c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -58,13 +58,6 @@
using namespace clang;
using namespace clang::CodeGen;
-// TODO: consider deprecating ClArrayBoundsPseudoFn; functionality is subsumed
-// by -fsanitize-annotate-debug-info
-static llvm::cl::opt<bool> ClArrayBoundsPseudoFn(
- "array-bounds-pseudofn", llvm::cl::Hidden, llvm::cl::Optional,
- llvm::cl::desc("Emit debug info that places array-bounds instrumentation "
- "in an inline function called __ubsan_check_array_bounds."));
-
static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext &Ctx) {
auto TI = Ctx.getTypeInfo(Ty);
if (TI.isAlignRequired())
@@ -6482,7 +6475,11 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
SanitizerHandler Handler) {
llvm::DILocation *CheckDebugLoc = Builder.getCurrentDebugLocation();
auto *DI = getDebugInfo();
- if (!DI)
+ if (!DI || !CheckDebugLoc)
+ return CheckDebugLoc;
+ const auto &AnnotateDebugInfo =
+ CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo;
+ if (AnnotateDebugInfo.empty())
return CheckDebugLoc;
std::string Label;
@@ -6491,14 +6488,8 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
else
Label = SanitizerHandlerToCheckLabel(Handler);
- for (auto Ord : Ordinals) {
- // TODO: deprecate ClArrayBoundsPseudoFn
- if (((ClArrayBoundsPseudoFn && Ord == SanitizerKind::SO_ArrayBounds) ||
- CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo.has(Ord)) &&
- CheckDebugLoc) {
- return DI->CreateSyntheticInlineAt(CheckDebugLoc, Label);
- }
- }
+ if (any_of(Ordinals, [&](auto Ord) { return AnnotateDebugInfo.has(Ord); }))
+ return DI->CreateSyntheticInlineAt(CheckDebugLoc, Label);
return CheckDebugLoc;
}
|
|
@llvm/pr-subscribers-clang-codegen Author: Florian Mayer (fmayer) ChangesThis has been replaced by -fsanitize-annotate-debug-info Full diff: https://github.com/llvm/llvm-project/pull/149430.diff 1 Files Affected:
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 446cf8d9e05c6..d6a5c4c476d5c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -58,13 +58,6 @@
using namespace clang;
using namespace clang::CodeGen;
-// TODO: consider deprecating ClArrayBoundsPseudoFn; functionality is subsumed
-// by -fsanitize-annotate-debug-info
-static llvm::cl::opt<bool> ClArrayBoundsPseudoFn(
- "array-bounds-pseudofn", llvm::cl::Hidden, llvm::cl::Optional,
- llvm::cl::desc("Emit debug info that places array-bounds instrumentation "
- "in an inline function called __ubsan_check_array_bounds."));
-
static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext &Ctx) {
auto TI = Ctx.getTypeInfo(Ty);
if (TI.isAlignRequired())
@@ -6482,7 +6475,11 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
SanitizerHandler Handler) {
llvm::DILocation *CheckDebugLoc = Builder.getCurrentDebugLocation();
auto *DI = getDebugInfo();
- if (!DI)
+ if (!DI || !CheckDebugLoc)
+ return CheckDebugLoc;
+ const auto &AnnotateDebugInfo =
+ CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo;
+ if (AnnotateDebugInfo.empty())
return CheckDebugLoc;
std::string Label;
@@ -6491,14 +6488,8 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
else
Label = SanitizerHandlerToCheckLabel(Handler);
- for (auto Ord : Ordinals) {
- // TODO: deprecate ClArrayBoundsPseudoFn
- if (((ClArrayBoundsPseudoFn && Ord == SanitizerKind::SO_ArrayBounds) ||
- CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo.has(Ord)) &&
- CheckDebugLoc) {
- return DI->CreateSyntheticInlineAt(CheckDebugLoc, Label);
- }
- }
+ if (any_of(Ordinals, [&](auto Ord) { return AnnotateDebugInfo.has(Ord); }))
+ return DI->CreateSyntheticInlineAt(CheckDebugLoc, Label);
return CheckDebugLoc;
}
|
|
@llvm/pr-subscribers-clang Author: Florian Mayer (fmayer) ChangesThis has been replaced by -fsanitize-annotate-debug-info Full diff: https://github.com/llvm/llvm-project/pull/149430.diff 1 Files Affected:
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 446cf8d9e05c6..d6a5c4c476d5c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -58,13 +58,6 @@
using namespace clang;
using namespace clang::CodeGen;
-// TODO: consider deprecating ClArrayBoundsPseudoFn; functionality is subsumed
-// by -fsanitize-annotate-debug-info
-static llvm::cl::opt<bool> ClArrayBoundsPseudoFn(
- "array-bounds-pseudofn", llvm::cl::Hidden, llvm::cl::Optional,
- llvm::cl::desc("Emit debug info that places array-bounds instrumentation "
- "in an inline function called __ubsan_check_array_bounds."));
-
static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext &Ctx) {
auto TI = Ctx.getTypeInfo(Ty);
if (TI.isAlignRequired())
@@ -6482,7 +6475,11 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
SanitizerHandler Handler) {
llvm::DILocation *CheckDebugLoc = Builder.getCurrentDebugLocation();
auto *DI = getDebugInfo();
- if (!DI)
+ if (!DI || !CheckDebugLoc)
+ return CheckDebugLoc;
+ const auto &AnnotateDebugInfo =
+ CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo;
+ if (AnnotateDebugInfo.empty())
return CheckDebugLoc;
std::string Label;
@@ -6491,14 +6488,8 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
else
Label = SanitizerHandlerToCheckLabel(Handler);
- for (auto Ord : Ordinals) {
- // TODO: deprecate ClArrayBoundsPseudoFn
- if (((ClArrayBoundsPseudoFn && Ord == SanitizerKind::SO_ArrayBounds) ||
- CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo.has(Ord)) &&
- CheckDebugLoc) {
- return DI->CreateSyntheticInlineAt(CheckDebugLoc, Label);
- }
- }
+ if (any_of(Ordinals, [&](auto Ord) { return AnnotateDebugInfo.has(Ord); }))
+ return DI->CreateSyntheticInlineAt(CheckDebugLoc, Label);
return CheckDebugLoc;
}
|
| auto *DI = getDebugInfo(); | ||
| if (!DI) | ||
| if (!DI || !CheckDebugLoc) | ||
| return CheckDebugLoc; |
There was a problem hiding this comment.
Do all the extra early-exits speed up or slow down the codegen?
There was a problem hiding this comment.
I would expect a non-null check to be cheaper than constructing a string for the Label
There was a problem hiding this comment.
The performance tradeoff depends on how often the check fails (if CheckDebugLoc is rarely null, then adding the check here may slow down codegen overall).
There was a problem hiding this comment.
We need to check it somewhere?
| return DI->CreateSyntheticInlineAt(CheckDebugLoc, Label); | ||
| } | ||
| } | ||
| if (any_of(Ordinals, [&](auto Ord) { return AnnotateDebugInfo.has(Ord); })) |
There was a problem hiding this comment.
Maybe !any_of could be combined with the AnnotateDebugInfo.empty() check earlier? That would avoid the need for return CheckDebugLoc; in line 6494.
There was a problem hiding this comment.
Doesn't that kind of obfuscate the code? Right now, we have preconditions / early exit first, then the actual logic "if any Ord matches"
There was a problem hiding this comment.
Arguably, "if no Ord matches" is a precondition / early exit; and, like your earlier checks, avoids the cost of constructing a string for the Label. But up to you, YOLO.
| return DI->CreateSyntheticInlineAt(CheckDebugLoc, Label); | ||
| } | ||
| } | ||
| if (any_of(Ordinals, [&](auto Ord) { return AnnotateDebugInfo.has(Ord); })) |
There was a problem hiding this comment.
Arguably, "if no Ord matches" is a precondition / early exit; and, like your earlier checks, avoids the cost of constructing a string for the Label. But up to you, YOLO.
This has been replaced by -fsanitize-annotate-debug-info