Skip to content

Commit c324d34

Browse files
keryellbcardosolopessmeenai
authored
[CIR][driver] Forward -fno-clangir-direct-lowering option to cc1 (#822)
Allow from the clang driver the use of lowering from CIR to MLIR standard dialect. Update the test to match the real output when `-fno-clangir-direct-lowering` is used, or with a combination of both `-fclangir-direct-lowering` and `-fno-clangir-direct-lowering`. --------- Co-authored-by: Bruno Cardoso Lopes <[email protected]> Co-authored-by: Shoaib Meenai <[email protected]>
1 parent f5e58b4 commit c324d34

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4972,15 +4972,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
49724972
Args.hasArg(options::OPT_emit_cir_flat))
49734973
CmdArgs.push_back("-fclangir");
49744974

4975-
if (Args.hasArg(options::OPT_fclangir_direct_lowering))
4976-
CmdArgs.push_back("-fclangir-direct-lowering");
4975+
Args.addOptOutFlag(CmdArgs, options::OPT_fclangir_direct_lowering,
4976+
options::OPT_fno_clangir_direct_lowering);
49774977

49784978
if (Args.hasArg(options::OPT_clangir_disable_passes))
49794979
CmdArgs.push_back("-clangir-disable-passes");
49804980

49814981
if (Args.hasArg(options::OPT_fclangir_call_conv_lowering))
49824982
CmdArgs.push_back("-fclangir-call-conv-lowering");
4983-
4983+
49844984
if (Args.hasArg(options::OPT_fclangir_mem2reg))
49854985
CmdArgs.push_back("-fclangir-mem2reg");
49864986

clang/test/CIR/driver.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55
// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -fclangir-direct-lowering -S -emit-llvm %s -o %t1.ll
66
// RUN: FileCheck --input-file=%t1.ll %s -check-prefix=LLVM
77
// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -fno-clangir-direct-lowering -S -emit-llvm %s -o %t2.ll
8-
// RUN: FileCheck --input-file=%t2.ll %s -check-prefix=LLVM
9-
// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -fclangir-direct-lowering -c -emit-llvm %s -o %t1.bc
8+
// RUN: FileCheck --input-file=%t2.ll %s -check-prefix=CIR_STD_LLVM
9+
// Test also the cases for both -fclangir-direct-lowering and -fno-clangir-direct-lowering,
10+
// with -fno-clangir-direct-lowering having the preference
11+
// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -fclangir-direct-lowering -fno-clangir-direct-lowering -S -emit-llvm %s -o %t2.ll
12+
// RUN: FileCheck --input-file=%t2.ll %s -check-prefix=CIR_STD_LLVM
13+
// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -fno-clangir-direct-lowering -fclangir-direct-lowering -c -emit-llvm %s -o %t1.bc
14+
// RUN: FileCheck --input-file=%t2.ll %s -check-prefix=CIR_STD_LLVM
1015
// RUN: llvm-dis %t1.bc -o %t1.bc.ll
1116
// RUN: FileCheck --input-file=%t1.bc.ll %s -check-prefix=LLVM
1217
// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -fno-clangir-direct-lowering -c -emit-llvm %s -o %t2.bc
1318
// RUN: llvm-dis %t2.bc -o %t2.bc.ll
14-
// RUN: FileCheck --input-file=%t2.bc.ll %s -check-prefix=LLVM
19+
// RUN: FileCheck --input-file=%t2.bc.ll %s -check-prefix=CIR_STD_LLVM
1520
// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -c %s -o %t.o
1621
// RUN: llvm-objdump -d %t.o | FileCheck %s -check-prefix=OBJ
1722
// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -clangir-disable-passes -S -Xclang -emit-cir %s -o %t.cir
@@ -39,6 +44,10 @@ void foo(void) {}
3944
// LLVM-NEXT: ret void
4045
// LLVM-NEXT: }
4146

47+
// CIR_STD_LLVM: define void @foo()
48+
// CIR_STD_LLVM-NEXT: ret void
49+
// CIR_STD_LLVM-NEXT: }
50+
4251
// LLVM_MACOS: define void @foo()
4352
// LLVM_MACOS-NEXT: ret void
4453
// LLVM_MACOS-NEXT: }

0 commit comments

Comments
 (0)