Skip to content

Commit 32f1f5e

Browse files
authored
[PGO] Add tests for modules with only globals and function declarations (#93764)
When a module contains globals and/or function declarations only, the '__llvm_profile_raw_version' variable should not be generated because the module was not instrumented at all. NFC
1 parent 3db1f31 commit 32f1f5e

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN --check-prefix=GEN-COMDAT
2+
3+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
4+
target triple = "x86_64-unknown-linux-gnu"
5+
6+
; GEN-COMDAT: $__llvm_profile_raw_version = comdat any
7+
; GEN-COMDAT: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
8+
; GEN: @__profn_foo = linkonce_odr hidden constant [3 x i8] c"foo"
9+
; GEN: @__profn_bar = linkonce_odr hidden constant [3 x i8] c"bar"
10+
11+
define available_externally hidden void @foo() {
12+
ret void
13+
}
14+
15+
define available_externally i32 @bar() {
16+
ret i32 42
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN --check-prefix=GEN-COMDAT
2+
3+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
4+
target triple = "x86_64-unknown-linux-gnu"
5+
6+
; GEN-COMDAT: $__llvm_profile_raw_version = comdat any
7+
; GEN-COMDAT: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
8+
; GEN-NOT: @__profn_test_1 = private constant [6 x i8] c"test_1"
9+
; GEN-NOT: @__profn_test_2 = private constant [6 x i8] c"test_2"
10+
11+
declare i32 @test_1(i32 %i)
12+
13+
declare i32 @test_2(i32 %i)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN-COMDAT
2+
3+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
4+
target triple = "x86_64-unknown-linux-gnu"
5+
6+
; GEN-COMDAT: $__llvm_profile_raw_version = comdat any
7+
; GEN-COMDAT: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
8+
9+
@var = internal unnamed_addr global [35 x ptr] zeroinitializer, align 16

0 commit comments

Comments
 (0)