r366623 - [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1

Teresa Johnson via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 19 16:02:58 PDT 2019


Author: tejohnson
Date: Fri Jul 19 16:02:58 2019
New Revision: 366623

URL: http://llvm.org/viewvc/llvm-project?rev=366623&view=rev
Log:
[LTO] Always mark regular LTO units with EnableSplitLTOUnit=1

Summary:
Regular LTO modules do not need LTO Unit splitting, only ThinLTO does
(they must be consistently split into regular and Thin units for
optimizations such as whole program devirtualization and lower type
tests). In order to avoid spurious errors from LTO when combining with
split ThinLTO modules, always set this flag for regular LTO modules.

Reviewers: pcc

Subscribers: mehdi_amini, Prazek, inglorion, steven_wu, dexonsmith, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65009

Added:
    cfe/trunk/test/CodeGen/split-lto-unit.c
Modified:
    cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=366623&r1=366622&r2=366623&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jul 19 16:02:58 2019
@@ -852,7 +852,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba
         if (!TheModule->getModuleFlag("ThinLTO"))
           TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
         TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
-                                 CodeGenOpts.EnableSplitLTOUnit);
+                                 uint32_t(1));
       }
 
       PerModulePasses.add(createBitcodeWriterPass(

Added: cfe/trunk/test/CodeGen/split-lto-unit.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-lto-unit.c?rev=366623&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/split-lto-unit.c (added)
+++ cfe/trunk/test/CodeGen/split-lto-unit.c Fri Jul 19 16:02:58 2019
@@ -0,0 +1,12 @@
+// ; 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 EnableSplitLTOUnit = 1
+// 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=SPLIT
+
+int main() {}




More information about the cfe-commits mailing list