Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ Comdat *llvm::getOrCreateFunctionComdat(Function &F, Triple &T) {

void llvm::setGlobalVariableLargeSection(const Triple &TargetTriple,
GlobalVariable &GV) {
if (TargetTriple.getArch() == Triple::x86_64 &&
TargetTriple.getObjectFormat() == Triple::ELF) {
GV.setCodeModel(CodeModel::Large);
}
// Limit to x86-64 ELF.
if (TargetTriple.getArch() != Triple::x86_64 ||
TargetTriple.getObjectFormat() != Triple::ELF)
return;
// Limit to medium/large code models.
std::optional<CodeModel::Model> CM = GV.getParent()->getCodeModel();
if (!CM || (*CM != CodeModel::Medium && *CM != CodeModel::Large))
return;
GV.setCodeModel(CodeModel::Large);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
;; Check that asan_globals is marked large under x86-64 medium code model.
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes=asan -S | FileCheck %s --check-prefixes=CHECK,X8664
; RUN: opt < %s -mtriple=ppc64-unknown-linux-gnu -passes=asan -S | FileCheck %s --check-prefixes=CHECK,PPC

; CHECK: @__asan_global_global =
; X8664-SAME: code_model "large"
; PPC-NOT: code_model "large"

@global = global i32 0, align 4

!llvm.module.flags = !{!0}

!0 = !{i32 1, !"Code Model", i32 3}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
;; Check that asan_globals is not marked large without an explicit code model.
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes=asan -S | FileCheck %s

; CHECK: @__asan_global_global =
; CHECK-NOT: code_model "large"

@global = global i32 0, align 4

This file was deleted.

25 changes: 0 additions & 25 deletions llvm/test/Instrumentation/InstrProfiling/icall-comdat.ll
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
; RUN: opt %s -mtriple=powerpc64-ibm-aix -passes=instrprof -S | FileCheck %s --check-prefix=ALIGN
; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefix=ALIGN

;; Check that globals have the proper code model.
; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CODEMODEL,CODEMODEL-X8664
; RUN: opt %s -mtriple=powerpc-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CODEMODEL,CODEMODEL-PPC

@__profn_foo = private constant [3 x i8] c"foo"
@__profn_bar = private constant [3 x i8] c"bar"

Expand Down Expand Up @@ -78,24 +74,3 @@ attributes #0 = { nounwind }
; ALIGN: @__profd_bar = private global {{.*}} section "__llvm_prf_data",{{.*}} align 8
; ALIGN: @__llvm_prf_vnodes = private global {{.*}} section "__llvm_prf_vnds",{{.*}} align 8
; ALIGN: @__llvm_prf_nm = private constant {{.*}} section "__llvm_prf_names",{{.*}} align 1

; CODEMODEL: @__profc_foo =
; CODEMODEL-NOT: code_model "large"
; CODEMODEL: @__profvp_foo =
; CODEMODEL-X8664-SAME: code_model "large"
; CODEMODEL-PPC-NOT: code_model
; CODEMODEL: @__profd_foo =
; CODEMODEL-NOT: code_model "large"
; CODEMODEL: @__profc_bar =
; CODEMODEL-NOT: code_model "large"
; CODEMODEL: @__profvp_bar =
; CODEMODEL-X8664-SAME: code_model "large"
; CODEMODEL-PPC-NOT: code_model
; CODEMODEL: @__profd_bar =
; CODEMODEL-NOT: code_model "large"
; CODEMODEL: @__llvm_prf_vnodes =
; CODEMODEL-X8664-SAME: code_model "large"
; CODEMODEL-PPC-NOT: code_model
; CODEMODEL: @__llvm_prf_nm =
; CODEMODEL-X8664-SAME: code_model "large"
; CODEMODEL-PPC-NOT: code_model
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;; Check that certain globals are in large sections under x86-64 large code model (but not in other arches).
; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment makes it sound like this should have a RUN line for other arches. Was that intentional or copy paste from the other tests?


@__profn_foo = private constant [3 x i8] c"foo"

define i32 @foo(ptr) {
call void @llvm.instrprof.increment(ptr @__profn_foo, i64 12884901887, i32 1, i32 0)
%2 = ptrtoint ptr %0 to i64
call void @llvm.instrprof.value.profile(ptr @__profn_foo, i64 12884901887, i64 %2, i32 0, i32 0)
%3 = tail call i32 %0()
ret i32 %3
}

; Function Attrs: nounwind
declare void @llvm.instrprof.increment(ptr, i64, i32, i32) #0

; Function Attrs: nounwind
declare void @llvm.instrprof.value.profile(ptr, i64, i64, i32, i32) #0

attributes #0 = { nounwind }

!llvm.module.flags = !{!0}

!0 = !{i32 1, !"Code Model", i32 4}

; CHECK: @__profc_foo =
; CHECK-NOT: code_model "large"
; CHECK: @__profvp_foo =
; CHECK-SAME: code_model "large"
; CHECK: @__profd_foo =
; CHECK-NOT: code_model "large"
; CHECK: @__llvm_prf_vnodes =
; CHECK-SAME: code_model "large"
; CHECK: @__llvm_prf_nm =
; CHECK-SAME: code_model "large"
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
;; Check that certain globals are in large sections under x86-64 medium code model (but not in other arches).
; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,X8664
; RUN: opt %s -mtriple=ppc64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,PPC

@__profn_foo = private constant [3 x i8] c"foo"

define i32 @foo(ptr) {
call void @llvm.instrprof.increment(ptr @__profn_foo, i64 12884901887, i32 1, i32 0)
%2 = ptrtoint ptr %0 to i64
call void @llvm.instrprof.value.profile(ptr @__profn_foo, i64 12884901887, i64 %2, i32 0, i32 0)
%3 = tail call i32 %0()
ret i32 %3
}

; Function Attrs: nounwind
declare void @llvm.instrprof.increment(ptr, i64, i32, i32) #0

; Function Attrs: nounwind
declare void @llvm.instrprof.value.profile(ptr, i64, i64, i32, i32) #0

attributes #0 = { nounwind }

!llvm.module.flags = !{!0}

!0 = !{i32 1, !"Code Model", i32 3}

; CHECK: @__profc_foo =
; CHECK-NOT: code_model "large"
; CHECK: @__profvp_foo =
; X8664-SAME: code_model "large"
; PPC-NOT: code_model "large"
; CHECK: @__profd_foo =
; CHECK-NOT: code_model "large"
; CHECK: @__llvm_prf_vnodes =
; X8664-SAME: code_model "large"
; PPC-NOT: code_model "large"
; CHECK: @__llvm_prf_nm =
; X8664-SAME: code_model "large"
; PPC-NOT: code_model "large"
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;; Check that globals are not marked large under x86-64 small code model.
; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s

@__profn_foo = private constant [3 x i8] c"foo"

define i32 @foo(ptr) {
call void @llvm.instrprof.increment(ptr @__profn_foo, i64 12884901887, i32 1, i32 0)
%2 = ptrtoint ptr %0 to i64
call void @llvm.instrprof.value.profile(ptr @__profn_foo, i64 12884901887, i64 %2, i32 0, i32 0)
%3 = tail call i32 %0()
ret i32 %3
}

; Function Attrs: nounwind
declare void @llvm.instrprof.increment(ptr, i64, i32, i32) #0

; Function Attrs: nounwind
declare void @llvm.instrprof.value.profile(ptr, i64, i64, i32, i32) #0

attributes #0 = { nounwind }

!llvm.module.flags = !{!0}

!0 = !{i32 1, !"Code Model", i32 1}

; CHECK: @__profc_foo =
; CHECK-NOT: code_model "large"
; CHECK: @__profvp_foo =
; CHECK-NOT: code_model "large"
; CHECK: @__profd_foo =
; CHECK-NOT: code_model "large"
; CHECK: @__llvm_prf_vnodes =
; CHECK-NOT: code_model "large"
; CHECK: @__llvm_prf_nm =
; CHECK-NOT: code_model "large"