Skip to content

Commit 7cac17b

Browse files
committed
Change file name
1 parent 62acbce commit 7cac17b

File tree

5 files changed

+53
-51
lines changed

5 files changed

+53
-51
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
//===- SanitizerCommonUtils.h - Sanitizer commnon utils ---------*- C++ -*-===//
1+
//===- SPIRVSanitizerCommonUtils.h - Commnon utils --------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file declares common infrastructure for Sanitizer.
9+
// This file declares common infrastructure for SPIRV Sanitizer.
1010
//
1111
//===----------------------------------------------------------------------===//
12-
#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERCOMMONUTILS_H
13-
#define LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERCOMMONUTILS_H
12+
#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_SPIRVSANITIZERCOMMONUTILS_H
13+
#define LLVM_TRANSFORMS_INSTRUMENTATION_SPIRVSANITIZERCOMMONUTILS_H
1414

1515
#include "llvm/IR/DerivedTypes.h"
1616
#include "llvm/IR/Instructions.h"
1717
#include "llvm/IR/Type.h"
1818
#include "llvm/IR/Value.h"
1919

2020
namespace llvm {
21-
namespace SanitizerCommonUtils {
21+
namespace SPIRVSanitizerCommonUtils {
2222

2323
// Spir memory address space
2424
constexpr unsigned kSpirOffloadPrivateAS = 0;
@@ -29,7 +29,7 @@ constexpr unsigned kSpirOffloadGenericAS = 4;
2929

3030
TargetExtType *getTargetExtType(Type *Ty);
3131
bool isJointMatrixAccess(Value *V);
32-
} // namespace SanitizerCommonUtils
32+
} // namespace SPIRVSanitizerCommonUtils
3333
} // namespace llvm
3434

35-
#endif // LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERCOMMONUTILS_H
35+
#endif // LLVM_TRANSFORMS_INSTRUMENTATION_SPIRVSANITIZERCOMMONUTILS_H

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
#include "llvm/TargetParser/Triple.h"
7575
#include "llvm/Transforms/Instrumentation/AddressSanitizerCommon.h"
7676
#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
77-
#include "llvm/Transforms/Instrumentation/SanitizerCommonUtils.h"
77+
#include "llvm/Transforms/Instrumentation/SPIRVSanitizerCommonUtils.h"
7878
#include "llvm/Transforms/Utils/ASanStackFrameLayout.h"
7979
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
8080
#include "llvm/Transforms/Utils/Instrumentation.h"
@@ -867,7 +867,7 @@ struct AddressSanitizer {
867867
void instrumentMemIntrinsic(MemIntrinsic *MI, RuntimeCallInserter &RTCI);
868868
Value *memToShadow(
869869
Value *Shadow, IRBuilder<> &IRB,
870-
uint32_t AddressSpace = SanitizerCommonUtils::kSpirOffloadPrivateAS);
870+
uint32_t AddressSpace = SPIRVSanitizerCommonUtils::kSpirOffloadPrivateAS);
871871
bool suppressInstrumentationSiteForDebug(int &Instrumented);
872872
bool instrumentFunction(Function &F, const TargetLibraryInfo *TLI);
873873
bool maybeInsertAsanInitAtFunctionEntry(Function &F);
@@ -1397,9 +1397,9 @@ static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM,
13971397
SpirFixupKernels.emplace_back(&F);
13981398

13991399
auto KernelName = F.getName();
1400-
auto *KernelNameGV =
1401-
GetOrCreateGlobalString(M, "__asan_kernel", KernelName,
1402-
SanitizerCommonUtils::kSpirOffloadConstantAS);
1400+
auto *KernelNameGV = GetOrCreateGlobalString(
1401+
M, "__asan_kernel", KernelName,
1402+
SPIRVSanitizerCommonUtils::kSpirOffloadConstantAS);
14031403
SpirKernelsMetadata.emplace_back(ConstantStruct::get(
14041404
StructTy, ConstantExpr::getPointerCast(KernelNameGV, IntptrTy),
14051405
ConstantInt::get(IntptrTy, KernelName.size())));
@@ -1435,7 +1435,7 @@ static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM,
14351435

14361436
// New argument: uintptr_t as(1)*, which is allocated in shared USM buffer
14371437
Types.push_back(llvm::PointerType::get(
1438-
IntptrTy, SanitizerCommonUtils::kSpirOffloadGlobalAS));
1438+
IntptrTy, SPIRVSanitizerCommonUtils::kSpirOffloadGlobalAS));
14391439

14401440
FunctionType *NewFTy = FunctionType::get(F->getReturnType(), Types, false);
14411441

@@ -1495,7 +1495,7 @@ static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM,
14951495

14961496
FixupMetadata("kernel_arg_addr_space",
14971497
ConstantAsMetadata::get(Builder.getInt32(
1498-
SanitizerCommonUtils::kSpirOffloadGlobalAS)));
1498+
SPIRVSanitizerCommonUtils::kSpirOffloadGlobalAS)));
14991499
FixupMetadata("kernel_arg_access_qual",
15001500
MDString::get(M.getContext(), "read_write"));
15011501
FixupMetadata("kernel_arg_type", MDString::get(M.getContext(), "void*"));
@@ -1681,34 +1681,34 @@ static bool isUnsupportedSPIRAccess(Value *Addr, Instruction *Inst) {
16811681
// Ignore load/store for target ext type since we can't know exactly what size
16821682
// it is.
16831683
if (auto *SI = dyn_cast<StoreInst>(Inst))
1684-
if (SanitizerCommonUtils::getTargetExtType(
1684+
if (SPIRVSanitizerCommonUtils::getTargetExtType(
16851685
SI->getValueOperand()->getType()) ||
1686-
SanitizerCommonUtils::isJointMatrixAccess(SI->getPointerOperand()))
1686+
SPIRVSanitizerCommonUtils::isJointMatrixAccess(SI->getPointerOperand()))
16871687
return true;
16881688

16891689
if (auto *LI = dyn_cast<LoadInst>(Inst))
1690-
if (SanitizerCommonUtils::getTargetExtType(Inst->getType()) ||
1691-
SanitizerCommonUtils::isJointMatrixAccess(LI->getPointerOperand()))
1690+
if (SPIRVSanitizerCommonUtils::getTargetExtType(Inst->getType()) ||
1691+
SPIRVSanitizerCommonUtils::isJointMatrixAccess(LI->getPointerOperand()))
16921692
return true;
16931693

16941694
Type *PtrTy = cast<PointerType>(Addr->getType()->getScalarType());
16951695
switch (PtrTy->getPointerAddressSpace()) {
1696-
case SanitizerCommonUtils::kSpirOffloadPrivateAS: {
1696+
case SPIRVSanitizerCommonUtils::kSpirOffloadPrivateAS: {
16971697
if (!ClSpirOffloadPrivates)
16981698
return true;
16991699
// Skip kernel arguments
17001700
return Inst->getFunction()->getCallingConv() == CallingConv::SPIR_KERNEL &&
17011701
isa<Argument>(Addr);
17021702
}
1703-
case SanitizerCommonUtils::kSpirOffloadGlobalAS: {
1703+
case SPIRVSanitizerCommonUtils::kSpirOffloadGlobalAS: {
17041704
return !ClSpirOffloadGlobals;
17051705
}
1706-
case SanitizerCommonUtils::kSpirOffloadLocalAS: {
1706+
case SPIRVSanitizerCommonUtils::kSpirOffloadLocalAS: {
17071707
if (!ClSpirOffloadLocals)
17081708
return true;
17091709
return Addr->getName().starts_with("__Asan");
17101710
}
1711-
case SanitizerCommonUtils::kSpirOffloadGenericAS: {
1711+
case SPIRVSanitizerCommonUtils::kSpirOffloadGenericAS: {
17121712
return !ClSpirOffloadGenerics;
17131713
}
17141714
}
@@ -1724,15 +1724,15 @@ void AddressSanitizer::AppendDebugInfoToArgs(Instruction *InsertBefore,
17241724

17251725
// SPIR constant address space
17261726
PointerType *ConstASPtrTy = llvm::PointerType::get(
1727-
Type::getInt8Ty(C), SanitizerCommonUtils::kSpirOffloadConstantAS);
1727+
Type::getInt8Ty(C), SPIRVSanitizerCommonUtils::kSpirOffloadConstantAS);
17281728

17291729
// File & Line
17301730
if (Loc) {
17311731
llvm::SmallString<128> Source = Loc->getDirectory();
17321732
sys::path::append(Source, Loc->getFilename());
1733-
auto *FileNameGV =
1734-
GetOrCreateGlobalString(*M, "__asan_file", Source,
1735-
SanitizerCommonUtils::kSpirOffloadConstantAS);
1733+
auto *FileNameGV = GetOrCreateGlobalString(
1734+
*M, "__asan_file", Source,
1735+
SPIRVSanitizerCommonUtils::kSpirOffloadConstantAS);
17361736
Args.push_back(ConstantExpr::getPointerCast(FileNameGV, ConstASPtrTy));
17371737
Args.push_back(ConstantInt::get(Type::getInt32Ty(C), Loc.getLine()));
17381738
} else {
@@ -1742,9 +1742,9 @@ void AddressSanitizer::AppendDebugInfoToArgs(Instruction *InsertBefore,
17421742

17431743
// Function
17441744
auto FuncName = InsertBefore->getFunction()->getName();
1745-
auto *FuncNameGV =
1746-
GetOrCreateGlobalString(*M, "__asan_func", demangle(FuncName),
1747-
SanitizerCommonUtils::kSpirOffloadConstantAS);
1745+
auto *FuncNameGV = GetOrCreateGlobalString(
1746+
*M, "__asan_func", demangle(FuncName),
1747+
SPIRVSanitizerCommonUtils::kSpirOffloadConstantAS);
17481748
Args.push_back(ConstantExpr::getPointerCast(FuncNameGV, ConstASPtrTy));
17491749
}
17501750

@@ -1781,7 +1781,7 @@ bool AddressSanitizer::instrumentSyclDynamicLocalMemory(
17811781
for (auto &Arg : F.args()) {
17821782
Type *PtrTy = dyn_cast<PointerType>(Arg.getType()->getScalarType());
17831783
if (PtrTy && PtrTy->getPointerAddressSpace() ==
1784-
SanitizerCommonUtils::kSpirOffloadLocalAS)
1784+
SPIRVSanitizerCommonUtils::kSpirOffloadLocalAS)
17851785
LocalArgs.push_back(&Arg);
17861786
}
17871787

@@ -1826,9 +1826,10 @@ void AddressSanitizer::instrumentInitAsanLaunchInfo(
18261826
// FIXME: if the initial value of "__AsanLaunchInfo" is zero, we'll not need
18271827
// this step
18281828
initializeCallbacks(TLI);
1829-
IRB.CreateStore(ConstantPointerNull::get(llvm::PointerType::get(
1830-
IntptrTy, SanitizerCommonUtils::kSpirOffloadGlobalAS)),
1831-
AsanLaunchInfo);
1829+
IRB.CreateStore(
1830+
ConstantPointerNull::get(llvm::PointerType::get(
1831+
IntptrTy, SPIRVSanitizerCommonUtils::kSpirOffloadGlobalAS)),
1832+
AsanLaunchInfo);
18321833
}
18331834

18341835
// Instrument memset/memmove/memcpy
@@ -1874,7 +1875,7 @@ bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) {
18741875
!(SSGI && SSGI->isSafe(AI)) &&
18751876
// ignore alloc contains target ext type since we can't know exactly what
18761877
// size it is.
1877-
!SanitizerCommonUtils::getTargetExtType(AI.getAllocatedType()));
1878+
!SPIRVSanitizerCommonUtils::getTargetExtType(AI.getAllocatedType()));
18781879

18791880
It->second = IsInteresting;
18801881
return IsInteresting;
@@ -2848,7 +2849,7 @@ void ModuleAddressSanitizer::instrumentDeviceGlobal(IRBuilder<> &IRB) {
28482849
SmallVector<Constant *, 8> DeviceGlobalMetadata;
28492850

28502851
Type *IntptrTy = M.getDataLayout().getIntPtrType(
2851-
*C, SanitizerCommonUtils::kSpirOffloadGlobalAS);
2852+
*C, SPIRVSanitizerCommonUtils::kSpirOffloadGlobalAS);
28522853

28532854
// Device global meta data is described by a structure
28542855
// size_t device_global_size
@@ -3607,7 +3608,8 @@ void AddressSanitizer::initializeCallbacks(const TargetLibraryInfo *TLI) {
36073608
// )
36083609
if (TargetTriple.isSPIROrSPIRV()) {
36093610
auto *Int8PtrTy = llvm::PointerType::get(
3610-
Type::getInt8Ty(*C), SanitizerCommonUtils::kSpirOffloadConstantAS);
3611+
Type::getInt8Ty(*C),
3612+
SPIRVSanitizerCommonUtils::kSpirOffloadConstantAS);
36113613

36123614
Args1.push_back(Int8PtrTy); // file
36133615
Args1.push_back(Type::getInt32Ty(*C)); // line
@@ -3709,15 +3711,15 @@ void AddressSanitizer::initializeCallbacks(const TargetLibraryInfo *TLI) {
37093711
AsanLaunchInfo = M.getOrInsertGlobal(
37103712
"__AsanLaunchInfo",
37113713
llvm::PointerType::get(IntptrTy,
3712-
SanitizerCommonUtils::kSpirOffloadGlobalAS),
3714+
SPIRVSanitizerCommonUtils::kSpirOffloadGlobalAS),
37133715
[&] {
37143716
return new GlobalVariable(
37153717
M,
37163718
llvm::PointerType::get(
3717-
IntptrTy, SanitizerCommonUtils::kSpirOffloadGlobalAS),
3719+
IntptrTy, SPIRVSanitizerCommonUtils::kSpirOffloadGlobalAS),
37183720
false, GlobalVariable::ExternalLinkage, nullptr,
37193721
"__AsanLaunchInfo", nullptr, GlobalVariable::NotThreadLocal,
3720-
SanitizerCommonUtils::kSpirOffloadLocalAS);
3722+
SPIRVSanitizerCommonUtils::kSpirOffloadLocalAS);
37213723
});
37223724

37233725
AsanMemToShadow = M.getOrInsertFunction(kAsanMemToShadow, IntptrTy,
@@ -4503,7 +4505,7 @@ void FunctionStackPoisoner::processStaticAllocas() {
45034505

45044506
// Poison the stack red zones at the entry.
45054507
Value *ShadowBase = ASan.memToShadow(
4506-
LocalStackBase, IRB, SanitizerCommonUtils::kSpirOffloadPrivateAS);
4508+
LocalStackBase, IRB, SPIRVSanitizerCommonUtils::kSpirOffloadPrivateAS);
45074509
// As mask we must use most poisoned case: red zones and after scope.
45084510
// As bytes we can use either the same or just red zones only.
45094511
copyToShadow(ShadowAfterScope, ShadowAfterScope, IRB, ShadowBase,

llvm/lib/Transforms/Instrumentation/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ add_llvm_component_library(LLVMInstrumentation
2626
TypeSanitizer.cpp
2727
HWAddressSanitizer.cpp
2828
RealtimeSanitizer.cpp
29-
SanitizerCommonUtils.cpp
29+
SPIRVSanitizerCommonUtils.cpp
3030

3131
ADDITIONAL_HEADER_DIRS
3232
${LLVM_MAIN_INCLUDE_DIR}/llvm/Transforms

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
#include "llvm/Support/Path.h"
201201
#include "llvm/Support/raw_ostream.h"
202202
#include "llvm/TargetParser/Triple.h"
203-
#include "llvm/Transforms/Instrumentation/SanitizerCommonUtils.h"
203+
#include "llvm/Transforms/Instrumentation/SPIRVSanitizerCommonUtils.h"
204204
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
205205
#include "llvm/Transforms/Utils/Instrumentation.h"
206206
#include "llvm/Transforms/Utils/Local.h"
@@ -1750,14 +1750,14 @@ static bool isUnsupportedSPIRAccess(const Value *Addr, Instruction *I) {
17501750
// Ignore load/store for target ext type since we can't know exactly what size
17511751
// it is.
17521752
if (auto *SI = dyn_cast<StoreInst>(I))
1753-
if (SanitizerCommonUtils::getTargetExtType(
1753+
if (SPIRVSanitizerCommonUtils::getTargetExtType(
17541754
SI->getValueOperand()->getType()) ||
1755-
SanitizerCommonUtils::isJointMatrixAccess(SI->getPointerOperand()))
1755+
SPIRVSanitizerCommonUtils::isJointMatrixAccess(SI->getPointerOperand()))
17561756
return true;
17571757

17581758
if (auto *LI = dyn_cast<LoadInst>(I))
1759-
if (SanitizerCommonUtils::getTargetExtType(I->getType()) ||
1760-
SanitizerCommonUtils::isJointMatrixAccess(LI->getPointerOperand()))
1759+
if (SPIRVSanitizerCommonUtils::getTargetExtType(I->getType()) ||
1760+
SPIRVSanitizerCommonUtils::isJointMatrixAccess(LI->getPointerOperand()))
17611761
return true;
17621762

17631763
Type *PtrTy = cast<PointerType>(Addr->getType()->getScalarType());

llvm/lib/Transforms/Instrumentation/SanitizerCommonUtils.cpp renamed to llvm/lib/Transforms/Instrumentation/SPIRVSanitizerCommonUtils.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
//===- SanitizerCommonUtils.cpp- Sanitizer commnon utils------------------===//
1+
//===- SPIRVSanitizerCommonUtils.cpp- SPIRV Sanitizer commnon utils ------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file declares common infrastructure for Sanitizer.
9+
// This file defines common infrastructure for SPIRV Sanitizer.
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "llvm/Transforms/Instrumentation/SanitizerCommonUtils.h"
13+
#include "llvm/Transforms/Instrumentation/SPIRVSanitizerCommonUtils.h"
1414

1515
using namespace llvm;
1616

1717
namespace llvm {
18-
namespace SanitizerCommonUtils {
18+
namespace SPIRVSanitizerCommonUtils {
1919

2020
TargetExtType *getTargetExtType(Type *Ty) {
2121
if (auto *TargetTy = dyn_cast<TargetExtType>(Ty))
@@ -59,5 +59,5 @@ bool isJointMatrixAccess(Value *V) {
5959
}
6060
return false;
6161
}
62-
} // namespace SanitizerCommonUtils
62+
} // namespace SPIRVSanitizerCommonUtils
6363
} // namespace llvm

0 commit comments

Comments
 (0)