Files
clang-p2996/flang/test/Driver/input-from-stdin-llvm.ll
Andrzej Warzynski 3e782ba21b [flang][driver] Fix support for -x
Until now, `-x` wasn't really taken into account in Flang's compiler and
frontend drivers. `flang-new` and `flang-new -fc1` only recently gained
powers to consume inputs other than Fortran files and that's probably
why this hasn't been noticed yet.

This patch makes sure that `-x` is supported correctly and consistently
with Clang. To this end, verification is added when reading LLVM IR
files (i.e. IR modules are verified with `llvm::verifyModule`). This
way, LLVM IR parsing errors are correctly reported to Flang users. This
also aids testing.

With the new functionality, we can verify that `-x ir` breaks
compilation for e.g. Fortran files and vice-versa. Tests are updated
accordingly.

Differential Revision: https://reviews.llvm.org/D127207
2022-06-10 10:36:25 +00:00

27 lines
593 B
LLVM

; Verify that reading from stdin works as expected - LLVM input
;----------
; RUN LINES
;----------
; Input type is implicit - assumed to be Fortran. As the input is provided via
; stdin, the file extension is not relevant here.
; RUN: cat %s | not %flang -S - -o -
; RUN: cat %s | not %flang_fc1 -S - -o -
; Input type is explicit
; RUN: cat %s | %flang -x ir -S - -o - | FileCheck %s
; RUN: cat %s | %flang_fc1 -x ir -S - -o - | FileCheck %s
;----------------
; EXPECTED OUTPUT
;----------------
; CHECK-LABEL: foo:
; CHECK: ret
;------
; INPUT
;------
define void @foo() {
ret void
}