Skip to content

Commit 90a959a

Browse files
[Bazel] Add llvm-mca unittests (#90309)
This patch refactors the llvm-mca rules slightly so that the source files within the tool source directory but not the library source directory are included in a separate cc_library. This patch also adds the llvm-mca unittests.
1 parent 3385616 commit 90a959a

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,12 +3111,26 @@ cc_library(
31113111
)
31123112

31133113
cc_library(
3114-
name = "llvm-mca-headers",
3114+
name = "MCAApplication",
3115+
srcs = glob([
3116+
"tools/llvm-mca/Views/*.cpp",
3117+
]) + [
3118+
mca_source
3119+
for mca_source in glob(["tools/llvm-mca/*.cpp"])
3120+
if mca_source != "tools/llvm-mca/llvm-mca.cpp"
3121+
],
31153122
hdrs = glob([
31163123
"tools/llvm-mca/*.h",
31173124
"tools/llvm-mca/Views/*.h",
31183125
]),
31193126
strip_include_prefix = "tools/llvm-mca",
3127+
deps = [
3128+
":MC",
3129+
":MCA",
3130+
":MCParser",
3131+
":Support",
3132+
":TargetParser",
3133+
],
31203134
)
31213135

31223136
cc_library(
@@ -4034,12 +4048,9 @@ cc_binary(
40344048

40354049
cc_binary(
40364050
name = "llvm-mca",
4037-
srcs = glob([
4038-
"tools/llvm-mca/*.cpp",
4039-
"tools/llvm-mca/*.h",
4040-
"tools/llvm-mca/Views/*.cpp",
4041-
"tools/llvm-mca/Views/*.h",
4042-
]),
4051+
srcs =[
4052+
"tools/llvm-mca/llvm-mca.cpp",
4053+
],
40434054
copts = llvm_copts,
40444055
stamp = 0,
40454056
deps = [
@@ -4049,10 +4060,10 @@ cc_binary(
40494060
":AllTargetsMCAs",
40504061
":MC",
40514062
":MCA",
4063+
":MCAApplication",
40524064
":MCParser",
40534065
":Support",
40544066
":TargetParser",
4055-
":llvm-mca-headers",
40564067
],
40574068
)
40584069

utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,3 +811,29 @@ cc_test(
811811
"//third-party/unittest:gtest_main",
812812
],
813813
)
814+
815+
cc_test(
816+
name = "llvm_mca_tests",
817+
size = "small",
818+
srcs = glob(
819+
[
820+
"tools/llvm-mca/*.cpp",
821+
"tools/llvm-mca/*.h",
822+
"tools/llvm-mca/X86/*.cpp",
823+
"tools/llvm-mca/X86/*.h",
824+
],
825+
allow_empty = False,
826+
),
827+
includes = ["tools/llvm-mca"],
828+
deps = [
829+
"//llvm:MC",
830+
"//llvm:MCA",
831+
"//llvm:MCAApplication",
832+
"//llvm:Support",
833+
"//llvm:TargetParser",
834+
"//llvm:X86CodeGen",
835+
"//llvm:X86UtilsAndDesc",
836+
"//third-party/unittest:gtest",
837+
"//third-party/unittest:gtest_main",
838+
],
839+
)

0 commit comments

Comments
 (0)