Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion llvm/lib/SYCLLowerIR/LocalAccessorToSharedMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//===----------------------------------------------------------------------===//

#include "llvm/SYCLLowerIR/LocalAccessorToSharedMemory.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Instructions.h"
Expand Down Expand Up @@ -248,10 +249,15 @@ class LocalAccessorToSharedMemory : public ModulePass {
if (!NvvmMetadata)
return;

// It is possible that the annotations node contains multiple pointers to
// the same metadata, recognise visited ones.
SmallSet<MDNode *, 4> Visited;
for (auto *MetadataNode : NvvmMetadata->operands()) {
if (MetadataNode->getNumOperands() != 3)
if (Visited.contains(MetadataNode) || MetadataNode->getNumOperands() != 3)
Comment thread
bader marked this conversation as resolved.
continue;

Visited.insert(MetadataNode);

// NVPTX identifies kernel entry points using metadata nodes of the form:
// !X = !{<function>, !"kernel", i32 1}
const MDOperand &TypeOperand = MetadataNode->getOperand(1);
Expand Down