[compiler-rt] [TSan][compiler-rt] Defer symbolization of Reports to as late as possible (PR #151120)
Thurston Dang via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 29 09:55:39 PDT 2025
================
@@ -199,6 +198,80 @@ void ScopedReportBase::AddMemoryAccess(uptr addr, uptr external_tag, Shadow s,
}
}
+void ScopedReportBase::SymbolizeStackElems() {
+ // symbolize memory ops
+ for (usize i = 0; i < rep_->mops.Size(); i++) {
+ ReportMop *mop = rep_->mops[i];
+ mop->stack = SymbolizeStack(mop->stack_trace);
+ if (mop->stack)
+ mop->stack->suppressable = true;
+ }
+
+ Vector<ReportLocation *> locs_tmp;
+
+ // Repopulate the locations in the order they were added - take care with
+ // the added locations
+ usize locs_idx = 0;
+ for (usize i = 0; i < rep_->added_location_addrs.Size(); i++) {
+ AddedLocationAddr *added_loc_addr = &rep_->added_location_addrs[i];
+
+ for (; locs_idx < added_loc_addr->locs_idx; locs_idx++) {
+ ReportLocation *loc = rep_->locs[locs_idx];
+ loc->stack = SymbolizeStackId(loc->stack_id);
+ locs_tmp.PushBack(loc);
+ }
+
+ if (ReportLocation *added_loc = SymbolizeData(added_loc_addr->addr)) {
+ added_loc->suppressable = true;
+ locs_tmp.PushBack(added_loc);
+ }
+ }
+
+ // Append any remaining locations
+ for (; locs_idx < rep_->locs.Size(); locs_idx++) {
+ ReportLocation *loc = rep_->locs[locs_idx];
+ loc->stack = SymbolizeStackId(loc->stack_id);
+ locs_tmp.PushBack(loc);
+ }
+
+ rep_->locs.Reset();
+ for (usize i = 0; i < locs_tmp.Size(); i++) rep_->locs.PushBack(locs_tmp[i]);
+
+ // symbolize locations
+ for (usize i = 0; i < rep_->locs.Size(); i++) {
+ ReportLocation *loc = rep_->locs[i];
+ loc->stack = SymbolizeStackId(loc->stack_id);
+ }
+
+ usize offset = 0;
+ for (usize i = 0; i < rep_->added_location_addrs.Size(); i++) {
+ struct AddedLocationAddr *added_loc = &rep_->added_location_addrs[i];
+ if (ReportLocation *loc = SymbolizeData(added_loc->addr)) {
+ offset++;
+ loc->suppressable = true;
+ rep_->locs[added_loc->locs_idx] = loc;
+ }
+ }
----------------
thurstond wrote:
IIUC this is inserting elements from rep_->added_location_addrs into the correct place in rep_->locs (a small portion is calling the symbolized), but it's a lot of work. I think it can be simplified by adding placeholders in ScopedReportBase::AddLocation (see comment below).
https://github.com/llvm/llvm-project/pull/151120
More information about the llvm-commits
mailing list