diff --git a/test/addrspacecast_null.ll b/test/addrspacecast_null.ll index 0c0d84fce0..a835e4581e 100644 --- a/test/addrspacecast_null.ll +++ b/test/addrspacecast_null.ll @@ -1,5 +1,4 @@ -; RUN: llvm-as %s -o %t.bc -; RUN: llvm-spirv %t.bc -o %t.spv +; RUN: llvm-spirv %s -o %t.spv ; RUN: spirv-dis %t.spv | FileCheck %s ; Test that addrspacecast of null pointer generates appropriate OpConstantNull diff --git a/test/align-duplicate.ll b/test/align-duplicate.ll index a9b3160190..b5cef7debd 100644 --- a/test/align-duplicate.ll +++ b/test/align-duplicate.ll @@ -1,5 +1,4 @@ -; RUN: llvm-as %s -o %t.bc -; RUN: llvm-spirv %t.bc -o %t.spv +; RUN: llvm-spirv %s -o %t.spv ; RUN: spirv-val %t.spv ; Test that duplicate align information does not result in SPIR-V validation diff --git a/test/array-alloca.ll b/test/array-alloca.ll index 0e0daf3355..a1e1317767 100644 --- a/test/array-alloca.ll +++ b/test/array-alloca.ll @@ -1,18 +1,17 @@ -; RUN: llvm-as %s -o %t.bc -; RUN: llvm-spirv %t.bc -o %t.spv +; RUN: llvm-spirv %s -o %t.spv ; Validation test. ; RUN: spirv-val %t.spv ; SPIR-V codegen test. -; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llvm-spirv %s -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; Roundtrip test. ; RUN: llvm-spirv -r %t.spv -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-LLVM -; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_KHR_untyped_pointers +; RUN: llvm-spirv %s -o %t.spv --spirv-ext=+SPV_KHR_untyped_pointers ; RUN: spirv-val %t.spv -; RUN: llvm-spirv %t.bc -spirv-text --spirv-ext=+SPV_KHR_untyped_pointers -o - | FileCheck %s --check-prefix=CHECK-SPIRV +; RUN: llvm-spirv %s -spirv-text --spirv-ext=+SPV_KHR_untyped_pointers -o - | FileCheck %s --check-prefix=CHECK-SPIRV ; RUN: llvm-spirv -r %t.spv -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-LLVM target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" diff --git a/tools/llvm-spirv/CMakeLists.txt b/tools/llvm-spirv/CMakeLists.txt index 189a7f19b1..28a92304d1 100644 --- a/tools/llvm-spirv/CMakeLists.txt +++ b/tools/llvm-spirv/CMakeLists.txt @@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS BitReader BitWriter Core + IRReader Passes Support TargetParser diff --git a/tools/llvm-spirv/llvm-spirv.cpp b/tools/llvm-spirv/llvm-spirv.cpp index 4fc9f6f0e0..5fbe989efb 100644 --- a/tools/llvm-spirv/llvm-spirv.cpp +++ b/tools/llvm-spirv/llvm-spirv.cpp @@ -49,11 +49,11 @@ #include "llvm/ADT/APInt.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Bitcode/BitcodeReader.h" #include "llvm/Bitcode/BitcodeWriter.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/Verifier.h" +#include "llvm/IRReader/IRReader.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Error.h" @@ -62,6 +62,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" +#include "llvm/Support/SourceMgr.h" #include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/raw_ostream.h" @@ -375,11 +376,14 @@ class StreambufToArray : public std::streambuf { static int convertLLVMToSPIRV(const SPIRV::TranslatorOpts &Opts) { LLVMContext Context; - std::unique_ptr MB = - ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFile))); - std::unique_ptr M = - ExitOnErr(getOwningLazyBitcodeModule(std::move(MB), Context, - /*ShouldLazyLoadMetadata=*/true)); + SMDiagnostic GetIRErr; + std::unique_ptr M = getLazyIRFileModule( + InputFile, GetIRErr, Context, /*ShouldLazyLoadMetadata=*/true); + if (!M) { + ExitOnErr( + createStringError(inconvertibleErrorCode(), GetIRErr.getMessage())); + } + ExitOnErr(M->materializeAll()); if (OutputFile.empty()) {