[PATCH] D18298: ThinLTO: do not promote GlobalVariable that have a specific section.

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 19 15:17:58 PDT 2016


joker.eph created this revision.
joker.eph added a reviewer: tejohnson.
joker.eph added a subscriber: llvm-commits.
Herald added a subscriber: joker.eph.

The linker has some implicit contract on some sections, and
promoting/renaming is breaking it.

http://reviews.llvm.org/D18298

Files:
  lib/Transforms/Utils/FunctionImportUtils.cpp
  test/ThinLTO/X86/section.ll

Index: test/ThinLTO/X86/section.ll
===================================================================
--- /dev/null
+++ test/ThinLTO/X86/section.ll
@@ -0,0 +1,12 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: llvm-as -module-summary %s -o %t.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t2.bc %t.bc
+; RUN: llvm-lto -thinlto-action=promote -thinlto-index %t2.bc %t.bc -o - | llvm-dis | FileCheck %s
+
+; CHECK: @private = private constant %struct.NSConstantString
+
+%struct.NSConstantString = type { i32*, i32, i8*, i32 }
+ at private = private constant %struct.NSConstantString { i32* null, i32 1992, i8* null, i32 0 }, section "__DATA,__cfstring"
+define void @foo() {
+    ret void
+}
\ No newline at end of file
Index: lib/Transforms/Utils/FunctionImportUtils.cpp
===================================================================
--- lib/Transforms/Utils/FunctionImportUtils.cpp
+++ lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -64,6 +64,11 @@
   if (GVar && GVar->isConstant() && GVar->hasUnnamedAddr())
     return false;
 
+  if (GVar && GVar->hasSection())
+    // Some sections like "__DATA,__cfstring" are "magic" and promotion is not
+    // allowed. Just disable promotion on any GVar with sections right now.
+    return false;
+
   // Eventually we only need to promote functions in the exporting module that
   // are referenced by a potentially exported function (i.e. one that is in the
   // summary index).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18298.51121.patch
Type: text/x-patch
Size: 1472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160319/a59c13da/attachment.bin>


More information about the llvm-commits mailing list