diff --git a/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp b/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp --- a/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp +++ b/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp @@ -396,8 +396,10 @@ for (llvm::MDNode *node : *nodes) { FailureOr> accessGroups = loopAnnotationImporter.lookupAccessGroupAttrs(node); - if (failed(accessGroups)) - return emitWarning(loc) << "could not lookup access group"; + if (failed(accessGroups)) { + emitWarning(loc) << "could not lookup access group"; + continue; + } llvm::append_range(refs, *accessGroups); } return refs; diff --git a/mlir/test/Target/LLVMIR/Import/import-failure.ll b/mlir/test/Target/LLVMIR/Import/import-failure.ll --- a/mlir/test/Target/LLVMIR/Import/import-failure.ll +++ b/mlir/test/Target/LLVMIR/Import/import-failure.ll @@ -309,6 +309,23 @@ ; // ----- +; CHECK: import-failure.ll +; CHECK-SAME: warning: could not lookup access group +define void @unused_access_group(ptr %arg) { +entry: + %0 = load i32, ptr %arg, !llvm.access.group !0 + br label %end, !llvm.loop !1 +end: + ret void +} + +!0 = distinct !{} +!1 = distinct !{!1, !2} +!2 = !{!"llvm.loop.parallel_accesses", !0, !3} +!3 = distinct !{} + +; // ----- + ; CHECK: import-failure.ll ; CHECK-SAME: warning: expected function_entry_count to be attached to a function ; CHECK: warning: unhandled metadata: !0 = !{!"function_entry_count", i64 42} diff --git a/mlir/test/Target/LLVMIR/Import/metadata-loop.ll b/mlir/test/Target/LLVMIR/Import/metadata-loop.ll --- a/mlir/test/Target/LLVMIR/Import/metadata-loop.ll +++ b/mlir/test/Target/LLVMIR/Import/metadata-loop.ll @@ -323,3 +323,23 @@ !1 = distinct !{!1, !2} !2 = !{!"llvm.loop.parallel_accesses", !0, !3} !3 = distinct !{} + +; // ----- + +; Verify the unused access group is not imported. +; CHECK: llvm.metadata @__llvm_global_metadata { +; CHECK-COUNT1: llvm.access_group + +; CHECK-LABEL: @unused_parallel_access +define void @unused_parallel_access(ptr %arg) { +entry: + %0 = load i32, ptr %arg, !llvm.access.group !0 + br label %end, !llvm.loop !1 +end: + ret void +} + +!0 = distinct !{} +!1 = distinct !{!1, !2} +!2 = !{!"llvm.loop.parallel_accesses", !0, !3} +!3 = distinct !{}