llvm.org GIT mirror llvm / dba60ce
LTO: Export functions referenced by the CFI jump table. If the LowerTypeTests pass decides to add a function to a jump table for CFI, it will add its name to the set cfiFunctionDefs, which among other things will cause the function to be renamed in the ThinLTO backend. One other thing that we must do with such functions is to not internalize them, because the jump table in the full LTO object will contain a reference to the actual function body in the ThinLTO object. This patch handles that by ensuring that we export any functions whose names appear in the cfiFunctionDefs set. Fixes PR33831. Differential Revision: https://reviews.llvm.org/D35605 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308504 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 3 years ago
2 changed file(s) with 38 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
10711071 ExportedGUIDs.insert(GUID);
10721072 }
10731073
1074 // Any functions referenced by the jump table in the regular LTO object must
1075 // be exported.
1076 for (auto &Def : ThinLTO.CombinedIndex.cfiFunctionDefs())
1077 ExportedGUIDs.insert(
1078 GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Def)));
1079
10741080 auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) {
10751081 const auto &ExportList = ExportLists.find(ModuleIdentifier);
10761082 return (ExportList != ExportLists.end() &&
0 ; Test that we do not internalize functions that appear in the CFI jump table in
1 ; the full LTO object file; any such functions will be referenced by the jump
2 ; table.
3
4 ; RUN: opt -thinlto-bc -o %t %s
5 ; RUN: llvm-lto2 run -o %t2 -r %t,f1,p -r %t,f2,p -r %t,_start,px %t -save-temps
6 ; RUN: llvm-dis %t2.1.2.internalize.bc -o - | FileCheck %s
7
8 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
9 target triple = "x86_64-unknown-linux-gnu"
10
11 ; CHECK: define void @f1()
12 define void @f1() !type !0 {
13 ret void
14 }
15
16 ; CHECK: define internal void @f2()
17 define void @f2() !type !1 {
18 ret void
19 }
20
21 define i1 @_start(i8* %p) {
22 %1 = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")
23 call void @f1()
24 call void @f2()
25 ret i1 %1
26 }
27
28 declare i1 @llvm.type.test(i8*, metadata)
29
30 !0 = !{i64 0, !"typeid1"}
31 !1 = !{i64 0, !"typeid2"}