Skip to content

Commit e845e69

Browse files
committed
Auto merge of #67829 - michaelwoerister:try-to-fix-pgo-branch-weights-test, r=Mark-Simulacrum
Attempt to fix intermittent failures of pgo-branch-weights test. This PR tries to fix the intermittent failures of the pgo-branch-weights test (#67746). The failing instances show no `!prof` annotations in LLVM IR. One possible cause is that the instrumented binary did not record anything. This is something I've occasionally seen happen for similarly small programs when using GNU ld as linker. The linker would not properly append the instruction counter sections, leading to most counters being dropped. This PR makes the test use the Gold linker instead. It also makes each command exit immediately on failure so we can pinpoint the failure source better, should there still be a problem. r? @Mark-Simulacrum
2 parents c5840f9 + 971aa2b commit e845e69

File tree

1 file changed

+19
-11
lines changed
  • src/test/run-make-fulldeps/pgo-branch-weights

1 file changed

+19
-11
lines changed

src/test/run-make-fulldeps/pgo-branch-weights/Makefile

+19-11
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,29 @@ ifdef IS_MSVC
1515
COMMON_FLAGS=-Cpanic=abort
1616
endif
1717

18+
# For some very small programs GNU ld seems to not properly handle
19+
# instrumentation sections correctly. Neither Gold nor LLD have that problem.
20+
ifeq ($(UNAME),Linux)
21+
ifneq (,$(findstring x86,$(TARGET)))
22+
COMMON_FLAGS=-Clink-args=-fuse-ld=gold
23+
endif
24+
endif
25+
26+
1827
all:
1928
# We don't compile `opaque` with either optimizations or instrumentation.
20-
# We don't compile `opaque` with either optimizations or instrumentation.
21-
$(RUSTC) $(COMMON_FLAGS) opaque.rs
29+
$(RUSTC) $(COMMON_FLAGS) opaque.rs || exit 1
2230
# Compile the test program with instrumentation
23-
mkdir -p "$(TMPDIR)"/prof_data_dir
31+
mkdir -p "$(TMPDIR)/prof_data_dir" || exit 1
2432
$(RUSTC) $(COMMON_FLAGS) interesting.rs \
25-
-Cprofile-generate="$(TMPDIR)"/prof_data_dir -O -Ccodegen-units=1
26-
$(RUSTC) $(COMMON_FLAGS) main.rs -Cprofile-generate="$(TMPDIR)"/prof_data_dir -O
33+
-Cprofile-generate="$(TMPDIR)/prof_data_dir" -O -Ccodegen-units=1 || exit 1
34+
$(RUSTC) $(COMMON_FLAGS) main.rs -Cprofile-generate="$(TMPDIR)/prof_data_dir" -O || exit 1
2735
# The argument below generates to the expected branch weights
2836
$(call RUN,main aaaaaaaaaaaa2bbbbbbbbbbbb2bbbbbbbbbbbbbbbbcc) || exit 1
29-
"$(LLVM_BIN_DIR)"/llvm-profdata merge \
30-
-o "$(TMPDIR)"/prof_data_dir/merged.profdata \
31-
"$(TMPDIR)"/prof_data_dir
37+
"$(LLVM_BIN_DIR)/llvm-profdata" merge \
38+
-o "$(TMPDIR)/prof_data_dir/merged.profdata" \
39+
"$(TMPDIR)/prof_data_dir" || exit 1
3240
$(RUSTC) $(COMMON_FLAGS) interesting.rs \
33-
-Cprofile-use="$(TMPDIR)"/prof_data_dir/merged.profdata -O \
34-
-Ccodegen-units=1 --emit=llvm-ir
35-
cat "$(TMPDIR)"/interesting.ll | "$(LLVM_FILECHECK)" filecheck-patterns.txt
41+
-Cprofile-use="$(TMPDIR)/prof_data_dir/merged.profdata" -O \
42+
-Ccodegen-units=1 --emit=llvm-ir || exit 1
43+
cat "$(TMPDIR)/interesting.ll" | "$(LLVM_FILECHECK)" filecheck-patterns.txt

0 commit comments

Comments
 (0)