-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sycl' into work_group_static
- Loading branch information
Showing
235 changed files
with
3,502 additions
and
2,985 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//===-- AsanKernelMetadata.h - fix kernel medatadata for sanitizer ---===// | ||
// | ||
// 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 pass fixes attributes and metadata of the global variable | ||
// "__AsanKernelMetadata" | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include "llvm/IR/PassManager.h" | ||
|
||
namespace llvm { | ||
|
||
class AsanKernelMetadataPass : public PassInfoMixin<AsanKernelMetadataPass> { | ||
public: | ||
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM); | ||
}; | ||
|
||
} // namespace llvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//===-- AsanKernelMetadata.cpp - fix kernel medatadata for sanitizer -===// | ||
// | ||
// 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 pass fixes attributes and metadata of global variable | ||
// "__AsanKernelMetadata". | ||
// We treat "__AsanKernelMetadata" as a device global variable, so that it can | ||
// be read by runtime. | ||
// "spirv.Decorations" is removed by llvm-link, so we add it here again. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "llvm/SYCLLowerIR/AsanKernelMetadata.h" | ||
|
||
#include "llvm/IR/IRBuilder.h" | ||
|
||
#define DEBUG_TYPE "AsanKernelMetadata" | ||
|
||
using namespace llvm; | ||
|
||
namespace llvm { | ||
|
||
constexpr StringRef SPIRV_DECOR_MD_KIND = "spirv.Decorations"; | ||
constexpr uint32_t SPIRV_HOST_ACCESS_DECOR = 6147; | ||
|
||
PreservedAnalyses AsanKernelMetadataPass::run(Module &M, | ||
ModuleAnalysisManager &MAM) { | ||
auto *KernelMetadata = M.getNamedGlobal("__AsanKernelMetadata"); | ||
if (!KernelMetadata) { | ||
return PreservedAnalyses::all(); | ||
} | ||
|
||
auto &DL = M.getDataLayout(); | ||
auto &Ctx = M.getContext(); | ||
|
||
// Fix attributes | ||
KernelMetadata->addAttribute( | ||
"sycl-device-global-size", | ||
std::to_string(DL.getTypeAllocSize(KernelMetadata->getValueType()))); | ||
|
||
// Fix metadata | ||
unsigned MDKindID = Ctx.getMDKindID(SPIRV_DECOR_MD_KIND); | ||
|
||
SmallVector<Metadata *, 1> MDOps; | ||
|
||
SmallVector<Metadata *, 3> MD; | ||
auto *Ty = Type::getInt32Ty(Ctx); | ||
MD.push_back(ConstantAsMetadata::get( | ||
Constant::getIntegerValue(Ty, APInt(32, SPIRV_HOST_ACCESS_DECOR)))); | ||
MD.push_back( | ||
ConstantAsMetadata::get(Constant::getIntegerValue(Ty, APInt(32, 0)))); | ||
MD.push_back(MDString::get(Ctx, "_Z20__AsanKernelMetadata")); | ||
|
||
MDOps.push_back(MDNode::get(Ctx, MD)); | ||
|
||
KernelMetadata->addMetadata(MDKindID, *MDNode::get(Ctx, MDOps)); | ||
|
||
return PreservedAnalyses::none(); | ||
} | ||
|
||
} // namespace llvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.