[PATCH] D35605: LTO: Export functions referenced by the CFI jump table.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 19 11:19:40 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL308504: LTO: Export functions referenced by the CFI jump table. (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D35605?vs=107238&id=107346#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35605

Files:
  llvm/trunk/lib/LTO/LTO.cpp
  llvm/trunk/test/LTO/Resolution/X86/export-jumptable.ll


Index: llvm/trunk/lib/LTO/LTO.cpp
===================================================================
--- llvm/trunk/lib/LTO/LTO.cpp
+++ llvm/trunk/lib/LTO/LTO.cpp
@@ -1072,6 +1072,12 @@
         ExportedGUIDs.insert(GUID);
     }
 
+    // Any functions referenced by the jump table in the regular LTO object must
+    // be exported.
+    for (auto &Def : ThinLTO.CombinedIndex.cfiFunctionDefs())
+      ExportedGUIDs.insert(
+          GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Def)));
+
     auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) {
       const auto &ExportList = ExportLists.find(ModuleIdentifier);
       return (ExportList != ExportLists.end() &&
Index: llvm/trunk/test/LTO/Resolution/X86/export-jumptable.ll
===================================================================
--- llvm/trunk/test/LTO/Resolution/X86/export-jumptable.ll
+++ llvm/trunk/test/LTO/Resolution/X86/export-jumptable.ll
@@ -0,0 +1,32 @@
+; Test that we do not internalize functions that appear in the CFI jump table in
+; the full LTO object file; any such functions will be referenced by the jump
+; table.
+
+; RUN: opt -thinlto-bc -o %t %s
+; RUN: llvm-lto2 run -o %t2 -r %t,f1,p -r %t,f2,p -r %t,_start,px %t -save-temps
+; RUN: llvm-dis %t2.1.2.internalize.bc -o - | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK: define void @f1()
+define void @f1() !type !0 {
+  ret void
+}
+
+; CHECK: define internal void @f2()
+define void @f2() !type !1 {
+  ret void
+}
+
+define i1 @_start(i8* %p) {
+  %1 = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")
+  call void @f1()
+  call void @f2()
+  ret i1 %1
+}
+
+declare i1 @llvm.type.test(i8*, metadata)
+
+!0 = !{i64 0, !"typeid1"}
+!1 = !{i64 0, !"typeid2"}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35605.107346.patch
Type: text/x-patch
Size: 1831 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170719/e762d851/attachment.bin>


More information about the llvm-commits mailing list