llvm-project/compiler-rt/lib/esan/esan_interface.cpp
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00

122 lines
3.3 KiB
C++

//===-- esan_interface.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is a part of EfficiencySanitizer, a family of performance tuners.
//
//===----------------------------------------------------------------------===//
#include "esan_interface_internal.h"
#include "esan.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
using namespace __esan; // NOLINT
void __esan_init(ToolType Tool, void *Ptr) {
if (Tool != __esan_which_tool) {
Printf("ERROR: tool mismatch: %d vs %d\n", Tool, __esan_which_tool);
Die();
}
initializeLibrary(Tool);
processCompilationUnitInit(Ptr);
}
void __esan_exit(void *Ptr) {
processCompilationUnitExit(Ptr);
}
void __esan_aligned_load1(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 1, false);
}
void __esan_aligned_load2(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, false);
}
void __esan_aligned_load4(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, false);
}
void __esan_aligned_load8(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, false);
}
void __esan_aligned_load16(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, false);
}
void __esan_aligned_store1(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 1, true);
}
void __esan_aligned_store2(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, true);
}
void __esan_aligned_store4(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, true);
}
void __esan_aligned_store8(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, true);
}
void __esan_aligned_store16(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, true);
}
void __esan_unaligned_load2(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, false);
}
void __esan_unaligned_load4(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, false);
}
void __esan_unaligned_load8(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, false);
}
void __esan_unaligned_load16(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, false);
}
void __esan_unaligned_store2(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, true);
}
void __esan_unaligned_store4(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, true);
}
void __esan_unaligned_store8(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, true);
}
void __esan_unaligned_store16(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, true);
}
void __esan_unaligned_loadN(void *Addr, uptr Size) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, Size, false);
}
void __esan_unaligned_storeN(void *Addr, uptr Size) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, Size, true);
}
// Public interface:
extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE void __esan_report() {
reportResults();
}
SANITIZER_INTERFACE_ATTRIBUTE unsigned int __esan_get_sample_count() {
return getSampleCount();
}
} // extern "C"