60 lines · plain
1! Tests for the `-save-temps` flag. Instead of checking the commands generated2! by the driver with `-###` (like the save-temps.f90 test does), here we check3! that the MLIR files are actually produced in the specified location because4! the driver does not generate specific passes for MLIR. Instead, they are5! generated during code generation as additional outputs.6 7! As `flang` does not implement `-fc1as` (i.e. a driver for the integrated8! assembler), we need to use `-fno-integrated-as` here.9! However, calling an external assembler on arm64 Macs fails, because it's10! currently being invoked with the `-Q` flag, that is not supported on arm64.11! UNSUPPORTED: system-windows, system-darwin12 13!--------------------------14! Invalid output directory15!--------------------------16! RUN: not %flang_fc1 -emit-llvm-bc -save-temps=#invalid-dir -o - %s 2>&1 | FileCheck %s -check-prefix=MLIR-ERROR17! MLIR-ERROR: error: Saving MLIR temp file failed18 19!--------------------------20! Save to cwd21!--------------------------22! RUN: rm -rf %t && mkdir -p %t23! RUN: pushd %t && %flang -c -fno-integrated-as -save-temps=cwd -o out.o %s 2>&124! RUN: FileCheck %s -input-file=save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR25! RUN: FileCheck %s -input-file=save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR26! RUN: popd27 28! RUN: rm -rf %t && mkdir -p %t29! RUN: pushd %t && %flang -c -fno-integrated-as -save-temps -o out.o %s 2>&130! RUN: FileCheck %s -input-file=save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR31! RUN: FileCheck %s -input-file=save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR32! RUN: popd33 34!--------------------------35! Save to output directory36!--------------------------37! RUN: rm -rf %t && mkdir -p %t38! RUN: %flang -c -fno-integrated-as -save-temps=obj -o %t/out.o %s 2>&139! RUN: FileCheck %s -input-file=%t/save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR40! RUN: FileCheck %s -input-file=%t/save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR41 42!--------------------------43! Save to specific directory44!--------------------------45! RUN: rm -rf %t && mkdir -p %t46! RUN: %flang -c -fno-integrated-as -save-temps=%t -o %t/out.o %s 2>&147! RUN: FileCheck %s -input-file=%t/save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR48! RUN: FileCheck %s -input-file=%t/save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR49 50!--------------------------51! Content to check from the MLIR outputs52!--------------------------53! MLIR-FIR-NOT: llvm.func54! MLIR-FIR: func.func @{{.*}}main(){{.*}}55 56! MLIR-LLVMIR-NOT: func.func57! MLIR-LLVMIR: llvm.func @{{.*}}main(){{.*}}58 59end program60