This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] [dfsan] Unify aarch64 mapping
ClosedPublic

Authored by zatrazz on Nov 16 2015, 1:00 PM.

Details

Summary

This patch reorganize the platform specific mapping information to
export the application mask on a external variable. This exported
variable will be used by intrumentation phase to create code to be
used on architecture with multiple VMA range.

The patch creates a new header, dfsan_platform.h, and move all the
mapping information and also create function accessors to the
mapping value. Also for aarch64 it initialize application exported
mask to the value based on runtime VMA detection.

Diff Detail

Event Timeline

zatrazz updated this revision to Diff 40324.Nov 16 2015, 1:00 PM
zatrazz retitled this revision from to [compiler-rt] [dfsan] Unify aarch64 mapping.
zatrazz updated this object.
zatrazz added a subscriber: llvm-commits.
eugenis added a reviewer: pcc.Nov 16 2015, 2:25 PM
pcc added inline comments.Nov 16 2015, 8:10 PM
lib/dfsan/dfsan.cc
371

You don't need this #ifdef (or the macro), as it is redundant with __aarch64__.

378

ThreadSanitizer -> DataFlowSanitizer

lib/dfsan/dfsan_platform.h
93

I would prefer if these functions were written more directly.

e.g.

uptr UnionTableAddr() {
#if defined(__x86_64__)
  return 0x200000000000;
#elif ...
#elif defined(__aarch64__)
  if (vmaSize == 39)
    return ...;
  else
    return ...;
#endif
}

Thanks for the review, comments below.

lib/dfsan/dfsan.cc
371

The idea of adding these two ifdefs, although currently redundant, is to make explicit DFSAN_RUNTIME_VMA is not tied to aarch64. I can remove it if you prefer.

378

I will change that.

lib/dfsan/dfsan_platform.h
93

I based this modifications on my pending thread sanitizer patch [1] and the idea it avoid the constant ifdef for multiple function which IHMO only make the code hard to read and duplicate logic. Which this approach you have only two required platform specific blocks: one for the mapping definition and other for multiple VMA handling. I sensed, based on thread sanitizer review, that this approach would be desirable one for compiler-rt.

[1] http://reviews.llvm.org/D14199

dvyukov edited edge metadata.Nov 17 2015, 5:20 AM

Yes, this is based on my proposal for tsan. Tsan supports more mappings, logic is more complex and requires more constants. So I wanted to (1) see all constants in a single place (Mapping struct) and (2) don't duplicate any mapping related functions.

pcc added inline comments.Nov 17 2015, 11:44 AM
lib/dfsan/dfsan.cc
371

I'd prefer to remove it. We can always add it back if it becomes necessary.

lib/dfsan/dfsan_platform.h
93

Okay, let's be consistent with TSan here.

zatrazz updated this revision to Diff 40641.Nov 19 2015, 6:55 AM
zatrazz edited edge metadata.

Changes from previous version:

  • Remove aarch64 ifdef on PlatformEarlyInit.

Ping. The llvm side is already approved [1].

[1] http://reviews.llvm.org/D14724

pcc edited edge metadata.Nov 26 2015, 12:31 PM
pcc added a subscriber: pcc.

Lgtm

zatrazz accepted this revision.Nov 27 2015, 5:05 AM
zatrazz added a reviewer: zatrazz.

Accepted baded on 'pcc' comment.

This revision is now accepted and ready to land.Nov 27 2015, 5:05 AM
zatrazz closed this revision.Nov 27 2015, 5:05 AM