llvm.org GIT mirror llvm / 66f1b7d
[PGO] Prohibit address recording if the function is both internal and COMDAT Differential Revision: http://reviews.llvm.org/D19515 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267792 91177308-0d34-0410-b5e6-96231b3b80d8 Rong Xu 3 years ago
2 changed file(s) with 30 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
236236 if (!F->hasLinkOnceLinkage() && !F->hasLocalLinkage() &&
237237 !F->hasAvailableExternallyLinkage())
238238 return true;
239 // Prohibit function address recording if the function is both internal and
240 // COMDAT. This avoids the profile data variable referencing internal symbols
241 // in COMDAT.
242 if (F->hasLocalLinkage() && F->hasComdat())
243 return false;
239244 // Check uses of this function for other than direct calls or invokes to it.
240245 return F->hasAddressTaken();
241246 }
0 ; RUN: opt < %s -pgo-instr-gen -instrprof -S | FileCheck %s
1 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
2 target triple = "x86_64-unknown-linux-gnu"
3
4 $foo = comdat any
5
6 ; CHECK: $__llvm_profile_raw_version = comdat any
7 ; CHECK: $__profv__stdin__foo = comdat any
8
9 @bar = global i32 ()* @foo, align 8
10
11 ; CHECK: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
12 ; CHECK: @__profn__stdin__foo = private constant [11 x i8] c":foo"
13 ; CHECK: @__profc__stdin__foo = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat($__profv__stdin__foo), align 8
14 ; CHECK: @__profd__stdin__foo = private global { i64, i64, i64*, i8*, i8*, i32, [1 x i16] } { i64 -5640069336071256030, i64 12884901887, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__stdin__foo, i32 0, i32 0), i8*
15 ; CHECK-NOT: bitcast (i32 ()* @foo to i8*)
16 ; CHECK-SAME: null
17 ; CHECK-SAME: , i8* null, i32 1, [1 x i16] zeroinitializer }, section "__llvm_prf_data", comdat($__profv__stdin__foo), align 8
18 ; CHECK: @__llvm_prf_nm = private constant [21 x i8] c"\0B\13x\DA\B3).I\C9\CC\B3\B3J\CB\CF\07\00\18a\04\1B", section "__llvm_prf_names"
19 ; CHECK: @llvm.used = appending global [2 x i8*] [i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [1 x i16] }* @__profd__stdin__foo to i8*), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @__llvm_prf_nm, i32 0, i32 0)], section "llvm.metadata"
20
21 define internal i32 @foo() comdat {
22 entry:
23 ret i32 1
24 }