1! Tests for the `-save-temps` flag. Instead of checking the commands generated 2! by the driver with `-###` (like the save-temps.f90 test does), here we check 3! that the MLIR files are actually produced in the specified location because 4! the driver does not generate specific passes for MLIR. Instead, they are 5! generated during code generation as additional outputs. 6 7! As `flang` does not implement `-fc1as` (i.e. a driver for the integrated 8! assembler), we need to use `-fno-integrated-as` here. 9! However, calling an external assembler on arm64 Macs fails, because it's 10! currently being invoked with the `-Q` flag, that is not supported on arm64. 11! UNSUPPORTED: system-windows, system-darwin 12 13!-------------------------- 14! Invalid output directory 15!-------------------------- 16! RUN: not %flang_fc1 -emit-llvm-bc -save-temps=#invalid-dir -o - %s 2>&1 | FileCheck %s -check-prefix=MLIR-ERROR 17! MLIR-ERROR: error: Saving MLIR temp file failed 18 19!-------------------------- 20! Save to cwd 21!-------------------------- 22! RUN: rm -rf %t && mkdir -p %t 23! RUN: pushd %t && %flang -c -fno-integrated-as -save-temps=cwd -o out.o %s 2>&1 24! RUN: FileCheck %s -input-file=save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR 25! RUN: FileCheck %s -input-file=save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR 26! RUN: popd 27 28! RUN: rm -rf %t && mkdir -p %t 29! RUN: pushd %t && %flang -c -fno-integrated-as -save-temps -o out.o %s 2>&1 30! RUN: FileCheck %s -input-file=save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR 31! RUN: FileCheck %s -input-file=save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR 32! RUN: popd 33 34!-------------------------- 35! Save to output directory 36!-------------------------- 37! RUN: rm -rf %t && mkdir -p %t 38! RUN: %flang -c -fno-integrated-as -save-temps=obj -o %t/out.o %s 2>&1 39! RUN: FileCheck %s -input-file=%t/save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR 40! RUN: FileCheck %s -input-file=%t/save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR 41 42!-------------------------- 43! Save to specific directory 44!-------------------------- 45! RUN: rm -rf %t && mkdir -p %t 46! RUN: %flang -c -fno-integrated-as -save-temps=%t -o %t/out.o %s 2>&1 47! RUN: FileCheck %s -input-file=%t/save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR 48! RUN: FileCheck %s -input-file=%t/save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR 49 50!-------------------------- 51! Content to check from the MLIR outputs 52!-------------------------- 53! MLIR-FIR-NOT: llvm.func 54! MLIR-FIR: func.func @{{.*}}main(){{.*}} 55 56! MLIR-LLVMIR-NOT: func.func 57! MLIR-LLVMIR: llvm.func @{{.*}}main(){{.*}} 58 59end program 60