llvm.org GIT mirror llvm / 0f978ea
Handle calls and invokes in GlobalStatus. This patch teaches GlobalStatus to analyze a call that uses the global value as a callee, not as an argument. With this change internalize call handle the common use of linkonce_odr functions. This reduces the number of linkonce_odr functions in a LTO build of clang (checked with the emit-llvm gold plugin option) from 1730 to 60. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193436 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
2 changed file(s) with 42 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1010 #include "llvm/IR/BasicBlock.h"
1111 #include "llvm/IR/GlobalVariable.h"
1212 #include "llvm/IR/IntrinsicInst.h"
13 #include "llvm/Support/CallSite.h"
1314 #include "llvm/Transforms/Utils/GlobalStatus.h"
1415
1516 using namespace llvm;
147148 if (MSI->isVolatile())
148149 return true;
149150 GS.StoredType = GlobalStatus::Stored;
151 } else if (ImmutableCallSite C = I) {
152 if (!C.isCallee(UI))
153 return true;
154 GS.IsLoaded = true;
150155 } else {
151156 return true; // Any other non-load instruction might take address!
152157 }
0 ; RUN: opt < %s -internalize -internalize-dso-list foo1,foo2,foo3,foo4 -S | FileCheck %s
1
2 ; CHECK: define internal void @foo1(
3 define linkonce_odr void @foo1() noinline {
4 ret void
5 }
6
7 ; CHECK: define linkonce_odr void @foo2(
8 define linkonce_odr void @foo2() noinline {
9 ret void
10 }
11
12 ; CHECK: define internal void @foo3(
13 define linkonce_odr void @foo3() noinline {
14 ret void
15 }
16
17 ; CHECK: define linkonce_odr void @foo4(
18 define linkonce_odr void @foo4() noinline {
19 ret void
20 }
21
22 declare void @f(void()*)
23
24 define void @bar() {
25 bb0:
26 call void @foo1()
27 call void @f(void()* @foo2)
28 invoke void @foo3() to label %bb1 unwind label %clean
29 bb1:
30 invoke void @f(void()* @foo4) to label %bb2 unwind label %clean
31 bb2:
32 ret void
33 clean:
34 landingpad i32 personality i8* null cleanup
35 ret void
36 }