This is an archive of the discontinued LLVM Phabricator instance.

[sancov][sanitizer-common] Correct sanitizer coverage point
ClosedPublic

Authored by XiaodongLoong on Feb 8 2022, 4:25 AM.

Details

Summary

Sanitizer coverage point should be the previous instruction PC of the
caller and the offset to the previous instruction might be different
on each CPU architecture.

Diff Detail

Event Timeline

XiaodongLoong created this revision.Feb 8 2022, 4:25 AM
XiaodongLoong requested review of this revision.Feb 8 2022, 4:25 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 8 2022, 4:25 AM
Herald added subscribers: llvm-commits, Restricted Project. · View Herald Transcript
XiaodongLoong added inline comments.Feb 8 2022, 4:47 AM
compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp
17–18

clang-format might make a mistake as following:

clang-format suggested style edits found:

          14 #include "sanitizer_allocator_internal.h"
          15 #include "sanitizer_atomic.h"
          16 #include "sanitizer_common.h"
>>> -     17 #include "sanitizer_common/sanitizer_stacktrace.h"
    -     18 #include "sanitizer_file.h"
    +        #  include "sanitizer_common/sanitizer_stacktrace.h"
    +        #  include "sanitizer_file.h"
          19 
          20 using namespace __sanitizer;
          21 
          22 using AddressRange = LoadedModule::AddressRange;

What should I do for this issue?

XiaodongLoong marked an inline comment as not done.

rebase code

XiaodongLoong added inline comments.Feb 22 2022, 4:14 AM
compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp
17–18

After rebased code, it is OK now.

It seems that the building failure is not caused by this patch.

See D120362: I think we should refactor the -1/-4 thing first.

This patch should focus on fixing the offset for __sanitizer_cov_trace_pc_guard.

compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp
227

I have confirmed that aarch64 needs this as well.

llvm/include/llvm/ADT/Triple.h
779

Upload a separate patch for the Triple.h change. You may add ro as a reviewer.

MaskRay added a subscriber: ro.Feb 22 2022, 3:36 PM
MaskRay added inline comments.
llvm/include/llvm/ADT/Triple.h
779

Maybe for @ro to add this. @ro may have some idea whether this can be used elsewhere.

@MaskRay Thanks for your review. I have rebased the code and split Triple.h to other patch D120381.

MaskRay accepted this revision.Feb 22 2022, 8:38 PM
MaskRay added inline comments.
llvm/tools/sancov/sancov.cpp
694–696

Drop this unrelated change.

@ro can decide what to do with isSparc. There are three places to update if - 8 is wrong:

3de5322b5f719d9414423d4237a6533fe43cd7f8
fc0bd3c2cee929ffbd75b5cca486f4c77f7d5c59
1ec9dd3aae0b8c90a91f845ad629ef7d199986c0

This revision is now accepted and ready to land.Feb 22 2022, 8:38 PM

drop isSparc part

XiaodongLoong edited the summary of this revision. (Show Details)Feb 23 2022, 9:10 PM
This revision was automatically updated to reflect the committed changes.