summaryrefslogtreecommitdiff
path: root/lib/ubsan/ubsan_handlers.cc
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2015-02-10 19:50:20 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2015-02-10 19:50:20 +0000
commitfeafeaf22a3ad581bfa0d1d1a4c1f692affb04a0 (patch)
tree5d79c35f9b75de888c71c1ad813851decf1a50d5 /lib/ubsan/ubsan_handlers.cc
parent63a5f4077723ea65d7eaf79a3d4c82de0b3c69ba (diff)
[UBSan] Reduce the number of getCallerLocation() calls.
getCallerLocation() is expensive as it issues a call to symbolizer. (In fact, this function has a memory leak at the moment, but this will be fixed in the nearest future). We should only call it if we're actually going to print an error report, in particular, once for every reported source location. __ubsan_handle_type_mismatch: call getCallerLocation() only if provided source location is invalid, and only if the report is not deduplicated. __ubsan_handle_float_cast_overflow: call getSourceLocation with correct CallerPC (the one in user code, not in UBSan handler). Source location for this check is not currently emitted by frontend. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228732 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ubsan/ubsan_handlers.cc')
-rw-r--r--lib/ubsan/ubsan_handlers.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/ubsan/ubsan_handlers.cc b/lib/ubsan/ubsan_handlers.cc
index a0ecff943..579ff7617 100644
--- a/lib/ubsan/ubsan_handlers.cc
+++ b/lib/ubsan/ubsan_handlers.cc
@@ -37,14 +37,14 @@ const char *TypeCheckKinds[] = {
}
static void handleTypeMismatchImpl(TypeMismatchData *Data, ValueHandle Pointer,
- Location FallbackLoc, ReportOptions Opts) {
+ ReportOptions Opts) {
Location Loc = Data->Loc.acquire();
// Use the SourceLocation from Data to track deduplication, even if 'invalid'
if (ignoreReport(Loc.getSourceLocation(), Opts))
return;
if (Data->Loc.isInvalid())
- Loc = FallbackLoc;
+ Loc = getCallerLocation(Opts.pc);
ScopedReport R(Opts, Loc);
@@ -67,12 +67,12 @@ static void handleTypeMismatchImpl(TypeMismatchData *Data, ValueHandle Pointer,
void __ubsan::__ubsan_handle_type_mismatch(TypeMismatchData *Data,
ValueHandle Pointer) {
GET_REPORT_OPTIONS(false);
- handleTypeMismatchImpl(Data, Pointer, getCallerLocation(), Opts);
+ handleTypeMismatchImpl(Data, Pointer, Opts);
}
void __ubsan::__ubsan_handle_type_mismatch_abort(TypeMismatchData *Data,
ValueHandle Pointer) {
GET_REPORT_OPTIONS(true);
- handleTypeMismatchImpl(Data, Pointer, getCallerLocation(), Opts);
+ handleTypeMismatchImpl(Data, Pointer, Opts);
Die();
}
@@ -288,7 +288,7 @@ void __ubsan::__ubsan_handle_vla_bound_not_positive_abort(VLABoundData *Data,
static void handleFloatCastOverflow(FloatCastOverflowData *Data,
ValueHandle From, ReportOptions Opts) {
// TODO: Add deduplication once a SourceLocation is generated for this check.
- Location Loc = getCallerLocation();
+ Location Loc = getCallerLocation(Opts.pc);
ScopedReport R(Opts, Loc);
Diag(Loc, DL_Error,