61 lines · c
1//===AMDGPUAsanInstrumentation.h - ASAN helper functions -*- C++- *===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===--------------------------------------------------------------===//8 9#ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPU_ASAN_INSTRUMENTATION_H10#define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPU_ASAN_INSTRUMENTATION_H11 12#include "AMDGPU.h"13#include "AMDGPUMemoryUtils.h"14#include "Utils/AMDGPUBaseInfo.h"15#include "llvm/ADT/SetOperations.h"16#include "llvm/ADT/StringExtras.h"17#include "llvm/ADT/StringMap.h"18#include "llvm/ADT/StringRef.h"19#include "llvm/IR/Constants.h"20#include "llvm/IR/DerivedTypes.h"21#include "llvm/IR/IRBuilder.h"22#include "llvm/IR/Instructions.h"23#include "llvm/IR/IntrinsicsAMDGPU.h"24#include "llvm/IR/MDBuilder.h"25#include "llvm/InitializePasses.h"26#include "llvm/Pass.h"27#include "llvm/Support/CommandLine.h"28#include "llvm/Support/Debug.h"29#include "llvm/Support/OptimizedStructLayout.h"30#include "llvm/Support/raw_ostream.h"31#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"32#include "llvm/Transforms/Instrumentation/AddressSanitizerCommon.h"33#include "llvm/Transforms/Utils/BasicBlockUtils.h"34#include "llvm/Transforms/Utils/ModuleUtils.h"35 36namespace llvm {37namespace AMDGPU {38 39/// Given SizeInBytes of the Value to be instrunmented,40/// Returns the redzone size corresponding to it.41uint64_t getRedzoneSizeForGlobal(int Scale, uint64_t SizeInBytes);42 43/// Instrument the memory operand Addr.44/// Generates report blocks that catch the addressing errors.45void instrumentAddress(Module &M, IRBuilder<> &IRB, Instruction *OrigIns,46 Instruction *InsertBefore, Value *Addr, Align Alignment,47 TypeSize TypeStoreSize, bool IsWrite,48 Value *SizeArgument, bool UseCalls, bool Recover,49 int Scale, int Offset);50 51/// Get all the memory operands from the instruction52/// that needs to be instrumented53void getInterestingMemoryOperands(54 Module &M, Instruction *I,55 SmallVectorImpl<InterestingMemoryOperand> &Interesting);56 57} // end namespace AMDGPU58} // end namespace llvm59 60#endif // LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPU_ASAN_INSTRUMENTATION_H61