More graceful failure when verifying llvm.noalias.
authorDimitrios Vytiniotis <dvytin@google.com>
Wed, 6 Mar 2019 19:05:43 +0000 (11:05 -0800)
committerjpienaar <jpienaar@google.com>
Sat, 30 Mar 2019 00:01:56 +0000 (17:01 -0700)
PiperOrigin-RevId: 237081778

mlir/lib/LLVMIR/IR/LLVMDialect.cpp
mlir/test/LLVMIR/invalid.mlir [new file with mode: 0644]

index d1eead96ac55ca7cd3a2eb88329084c487b4b091..57383f28a6475abb4a510f707ab57039cc86f444 100644 (file)
@@ -96,8 +96,9 @@ bool LLVMDialect::verifyFunctionArgAttribute(const Function *func,
                                              unsigned argIdx,
                                              NamedAttribute argAttr) {
   // Check that llvm.noalias is a boolean attribute.
-  if (argAttr.first == StringRef("llvm.noalias"))
-    return (!argAttr.second.isa<BoolAttr>());
+  if (argAttr.first == "llvm.noalias" && !argAttr.second.isa<BoolAttr>())
+    return func->emitError(
+        "llvm.noalias argument attribute of non boolean type");
   return false;
 }
 
diff --git a/mlir/test/LLVMIR/invalid.mlir b/mlir/test/LLVMIR/invalid.mlir
new file mode 100644 (file)
index 0000000..e289edc
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: mlir-opt %s -verify
+
+// expected-error@+1{{llvm.noalias argument attribute of non boolean type}}
+func @invalid_noalias(%arg0: !llvm<"i32"> {llvm.noalias: 3}) {
+  "llvm.return"() : () -> ()
+}