tejohnson created this revision. tejohnson added a reviewer: pcc. Herald added subscribers: dexonsmith, steven_wu, inglorion, Prazek, mehdi_amini. Herald added a project: clang.
LTO Unit splitting does not apply to regular LTO modules, only ThinLTO (which must be consistently split into regular and Thin units for optimizations such as whole program devirtualization and lower type tests). Don't add the corresponding module flag to regular LTO modules, to avoid mismatched module flag errors when linking a regular LTO module with the regular LTO part of a split ThinLTO module. This relies on a corresponding LTO patch that ignores the status of this module flag on non-ThinLTO modules. Depends on D65008 <https://reviews.llvm.org/D65008>. Repository: rC Clang https://reviews.llvm.org/D65009 Files: lib/CodeGen/BackendUtil.cpp test/CodeGen/split-lto-unit.c Index: test/CodeGen/split-lto-unit.c =================================================================== --- /dev/null +++ test/CodeGen/split-lto-unit.c @@ -0,0 +1,13 @@ +// ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0 +// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s +// CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0} +// +// ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1 +// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --check-prefix=SPLIT +// SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1} +// +// ; Check that regular LTO has no EnableSplitLTOUnit flag +// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=THINLTOOFF +// THINLTOOFF: !{i32 1, !"ThinLTO", i32 0} + +int main() {} Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -847,8 +847,6 @@ if (EmitLTOSummary) { if (!TheModule->getModuleFlag("ThinLTO")) TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0)); - TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit", - CodeGenOpts.EnableSplitLTOUnit); } PerModulePasses.add(createBitcodeWriterPass(
Index: test/CodeGen/split-lto-unit.c =================================================================== --- /dev/null +++ test/CodeGen/split-lto-unit.c @@ -0,0 +1,13 @@ +// ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0 +// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s +// CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0} +// +// ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1 +// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --check-prefix=SPLIT +// SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1} +// +// ; Check that regular LTO has no EnableSplitLTOUnit flag +// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=THINLTOOFF +// THINLTOOFF: !{i32 1, !"ThinLTO", i32 0} + +int main() {} Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -847,8 +847,6 @@ if (EmitLTOSummary) { if (!TheModule->getModuleFlag("ThinLTO")) TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0)); - TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit", - CodeGenOpts.EnableSplitLTOUnit); } PerModulePasses.add(createBitcodeWriterPass(
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits