Skip to content

Commit d873f55

Browse files
mandlebugtstellar
authored andcommitted
[LTO] Fix fat-lto output for -c -emit-llvm. (llvm#79404)
Fix and add a test case for combining '-ffat-lto-objects -c -emit-llvm' options and fix a spelling mistake in same test. (cherry picked from commit f1b1611)
1 parent f685b94 commit d873f55

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

clang/lib/Driver/Driver.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -4764,9 +4764,9 @@ Action *Driver::ConstructPhaseAction(
47644764
case phases::Backend: {
47654765
if (isUsingLTO() && TargetDeviceOffloadKind == Action::OFK_None) {
47664766
types::ID Output;
4767-
if (Args.hasArg(options::OPT_ffat_lto_objects))
4768-
Output = Args.hasArg(options::OPT_emit_llvm) ? types::TY_LTO_IR
4769-
: types::TY_PP_Asm;
4767+
if (Args.hasArg(options::OPT_ffat_lto_objects) &&
4768+
!Args.hasArg(options::OPT_emit_llvm))
4769+
Output = types::TY_PP_Asm;
47704770
else if (Args.hasArg(options::OPT_S))
47714771
Output = types::TY_LTO_IR;
47724772
else

clang/test/Driver/fat-lto-objects.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@
2323
// CHECK-CC-S-EL-LTO-SAME: -emit-llvm
2424
// CHECK-CC-S-EL-LTO-SAME: -ffat-lto-objects
2525

26-
/// When fat LTO is enabled wihtout -S we expect native object output and -ffat-lto-object to be passed to cc1.
26+
/// When fat LTO is enabled without -S we expect native object output and -ffat-lto-object to be passed to cc1.
2727
// RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -### %s -c 2>&1 | FileCheck %s -check-prefix=CHECK-CC-C-LTO
2828
// CHECK-CC-C-LTO: -cc1
29-
// CHECK-CC-C-LTO: -emit-obj
30-
// CHECK-CC-C-LTO: -ffat-lto-objects
29+
// CHECK-CC-C-LTO-SAME: -emit-obj
30+
// CHECK-CC-C-LTO-SAME: -ffat-lto-objects
31+
32+
/// When fat LTO is enabled with -c and -emit-llvm we expect bitcode output and -ffat-lto-object to be passed to cc1.
33+
// RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -### %s -c -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-CC-C-EL-LTO
34+
// CHECK-CC-C-EL-LTO: -cc1
35+
// CHECK-CC-C-EL-LTO-SAME: -emit-llvm-bc
36+
// CHECK-CC-C-EL-LTO-SAME: -ffat-lto-objects
3137

3238
/// Make sure we don't have a warning for -ffat-lto-objects being unused
3339
// RUN: %clang --target=x86_64-unknown-linux-gnu -ffat-lto-objects -fdriver-only -Werror -v %s -c 2>&1 | FileCheck %s -check-prefix=CHECK-CC-NOLTO

0 commit comments

Comments
 (0)