|
31 | 31 | #include "llvm/Analysis/TargetLibraryInfo.h" |
32 | 32 | #include "llvm/Analysis/ValueTracking.h" |
33 | 33 | #include "llvm/BinaryFormat/MachO.h" |
| 34 | +#include "llvm/Bitcode/BitcodeWriter.h" |
34 | 35 | #include "llvm/Demangle/Demangle.h" |
35 | 36 | #include "llvm/IR/Argument.h" |
36 | 37 | #include "llvm/IR/Attributes.h" |
|
68 | 69 | #include "llvm/Support/CommandLine.h" |
69 | 70 | #include "llvm/Support/Debug.h" |
70 | 71 | #include "llvm/Support/ErrorHandling.h" |
| 72 | +#include "llvm/Support/MD5.h" |
71 | 73 | #include "llvm/Support/MathExtras.h" |
72 | 74 | #include "llvm/Support/Path.h" |
73 | 75 | #include "llvm/Support/raw_ostream.h" |
@@ -1379,8 +1381,15 @@ static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM, |
1379 | 1381 | "sycl-device-global-size", std::to_string(DL.getTypeAllocSize(ArrayTy))); |
1380 | 1382 | AsanSpirKernelMetadata->addAttribute("sycl-device-image-scope"); |
1381 | 1383 | AsanSpirKernelMetadata->addAttribute("sycl-host-access", "0"); // read only |
| 1384 | + // Create a memory buffer to hold the serialized module |
| 1385 | + std::string Buffer; |
| 1386 | + llvm::raw_string_ostream Stream(Buffer); |
| 1387 | + llvm::WriteBitcodeToFile(M, Stream); |
| 1388 | + Stream.flush(); |
| 1389 | + auto ModuleHash = llvm::utohexstr(MD5Hash(Buffer), true); |
| 1390 | + |
1382 | 1391 | AsanSpirKernelMetadata->addAttribute("sycl-unique-id", |
1383 | | - "_Z20__AsanKernelMetadata"); |
| 1392 | + "_Z20__AsanKernelMetadata" + ModuleHash); |
1384 | 1393 | AsanSpirKernelMetadata->setDSOLocal(true); |
1385 | 1394 |
|
1386 | 1395 | // Handle SpirFixupKernels |
|
0 commit comments