Skip to content

Commit adfcecf

Browse files
committed
[SYCL] Recognise visited nodes in local accessor to shared mem pass
1 parent 03ff41f commit adfcecf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/lib/SYCLLowerIR/LocalAccessorToSharedMemory.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#include "llvm/SYCLLowerIR/LocalAccessorToSharedMemory.h"
18+
#include "llvm/ADT/SmallSet.h"
1819
#include "llvm/IR/Constants.h"
1920
#include "llvm/IR/GlobalValue.h"
2021
#include "llvm/IR/Instructions.h"
@@ -248,8 +249,12 @@ class LocalAccessorToSharedMemory : public ModulePass {
248249
if (!NvvmMetadata)
249250
return;
250251

252+
// It is possible that the annotations node contains multiple pointers to
253+
// the same metadata, recognise visited ones.
254+
SmallSet<MDNode *, 4> Visited;
251255
for (auto *MetadataNode : NvvmMetadata->operands()) {
252-
if (MetadataNode->getNumOperands() != 3)
256+
Visited.insert(MetadataNode);
257+
if (Visited.contains(MetadataNode) || MetadataNode->getNumOperands() != 3)
253258
continue;
254259

255260
// NVPTX identifies kernel entry points using metadata nodes of the form:

0 commit comments

Comments
 (0)