From 99a2c6afdf8aacb0fd5d93a0adfe9216823e5319 Mon Sep 17 00:00:00 2001 From: Tom Weaver Date: Tue, 2 Feb 2021 14:19:31 +0000 Subject: [PATCH] Revert "[InstrProfiling] Use !associated metadata for counters, data and values" This reverts commit df3e39f60b356ca9dbfc11e96e5fdda30afa7acb. introduced failing test instrprof-gc-sections.c causing build bot to fail: http://lab.llvm.org:8011/#/builders/53/builds/1184 --- include/llvm/Transforms/Instrumentation.h | 3 --- .../Instrumentation/InstrProfiling.h | 3 --- .../Instrumentation/InstrProfiling.cpp | 25 ------------------- test/Instrumentation/InstrProfiling/icall.ll | 10 -------- .../Instrumentation/InstrProfiling/linkage.ll | 23 ----------------- test/Transforms/PGOProfile/associated.ll | 12 --------- test/Transforms/PGOProfile/counter_promo.ll | 2 +- .../PGOProfile/counter_promo_mexits.ll | 2 +- 8 files changed, 2 insertions(+), 78 deletions(-) delete mode 100644 test/Transforms/PGOProfile/associated.ll diff --git a/include/llvm/Transforms/Instrumentation.h b/include/llvm/Transforms/Instrumentation.h index ef6f6674af4..c960d5b0ab5 100644 --- a/include/llvm/Transforms/Instrumentation.h +++ b/include/llvm/Transforms/Instrumentation.h @@ -132,9 +132,6 @@ struct InstrProfOptions { // Use BFI to guide register promotion bool UseBFIInPromotion = false; - // Use !associated metadata to enable linker GC - bool CounterLinkOrder = false; - // Name of the profile file to use as output std::string InstrProfileOutput; diff --git a/include/llvm/Transforms/Instrumentation/InstrProfiling.h b/include/llvm/Transforms/Instrumentation/InstrProfiling.h index f0ab0a32484..5ce72cd59ac 100644 --- a/include/llvm/Transforms/Instrumentation/InstrProfiling.h +++ b/include/llvm/Transforms/Instrumentation/InstrProfiling.h @@ -83,9 +83,6 @@ private: /// Returns true if profile counter update register promotion is enabled. bool isCounterPromotionEnabled() const; - /// Returns true if the use of !associated metadata is enabled. - bool isCounterLinkOrderEnabled() const; - /// Count the number of instrumented value sites for the function. void computeNumValueSiteCounts(InstrProfValueProfileInst *Ins); diff --git a/lib/Transforms/Instrumentation/InstrProfiling.cpp b/lib/Transforms/Instrumentation/InstrProfiling.cpp index be2693bc350..9efc7d1ac50 100644 --- a/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -69,11 +69,6 @@ cl::opt RuntimeCounterRelocation( cl::desc("Enable relocating counters at runtime."), cl::init(false)); -cl::opt CounterLinkOrder( - "counter-link-order", - cl::desc("Set counter associated metadata to enable garbage collection at link time."), - cl::init(false)); - cl::opt ValueProfileStaticAlloc( "vp-static-alloc", cl::desc("Do static counter allocation for value profiler"), @@ -484,13 +479,6 @@ bool InstrProfiling::isCounterPromotionEnabled() const { return Options.DoCounterPromotion; } -bool InstrProfiling::isCounterLinkOrderEnabled() const { - if (CounterLinkOrder.getNumOccurrences() > 0) - return CounterLinkOrder; - - return Options.CounterLinkOrder; -} - void InstrProfiling::promoteCounterLoadStores(Function *F) { if (!isCounterPromotionEnabled()) return; @@ -862,12 +850,6 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) { CounterPtr->setAlignment(Align(8)); MaybeSetComdat(CounterPtr); CounterPtr->setLinkage(Linkage); - // We need a self-link for the counter variable because the ELF section name - // (that is __llvm_prf_cnts) is a C identifier and considered a GC root in the - // absence of the SHF_LINK_ORDER flag. - if (isCounterLinkOrderEnabled()) - CounterPtr->setMetadata(LLVMContext::MD_associated, - MDNode::get(Ctx, ValueAsMetadata::get(Fn))); auto *Int8PtrTy = Type::getInt8PtrTy(Ctx); // Allocate statically the array of pointers to value profile nodes for @@ -889,10 +871,6 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) { getInstrProfSectionName(IPSK_vals, TT.getObjectFormat())); ValuesVar->setAlignment(Align(8)); MaybeSetComdat(ValuesVar); - if (isCounterLinkOrderEnabled()) - ValuesVar->setMetadata( - LLVMContext::MD_associated, - MDNode::get(Ctx, ValueAsMetadata::get(CounterPtr))); ValuesPtrExpr = ConstantExpr::getBitCast(ValuesVar, Type::getInt8PtrTy(Ctx)); } @@ -927,9 +905,6 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) { Data->setAlignment(Align(INSTR_PROF_DATA_ALIGNMENT)); MaybeSetComdat(Data); Data->setLinkage(Linkage); - if (isCounterLinkOrderEnabled()) - Data->setMetadata(LLVMContext::MD_associated, - MDNode::get(Ctx, ValueAsMetadata::get(CounterPtr))); PD.RegionCounters = CounterPtr; PD.DataVar = Data; diff --git a/test/Instrumentation/InstrProfiling/icall.ll b/test/Instrumentation/InstrProfiling/icall.ll index d6e49be3378..9d45d7cd563 100644 --- a/test/Instrumentation/InstrProfiling/icall.ll +++ b/test/Instrumentation/InstrProfiling/icall.ll @@ -11,7 +11,6 @@ ; RUN: opt < %s -mtriple=mips64-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-SEXT ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -vp-static-alloc=false -instrprof -S | FileCheck %s --check-prefix=DYN ; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -vp-static-alloc=false -S | FileCheck %s --check-prefix=DYN -; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -counter-link-order -vp-static-alloc=true -S | FileCheck %s --check-prefix=METADATA @__profn_foo = private constant [3 x i8] c"foo" @@ -58,12 +57,3 @@ attributes #0 = { nounwind } ; STATIC: declare void @__llvm_profile_instrument_target(i64, i8*, i32) ; STATIC-EXT: declare void @__llvm_profile_instrument_target(i64, i8*, i32 zeroext) ; STATIC-SEXT: declare void @__llvm_profile_instrument_target(i64, i8*, i32 signext) - -; METADATA: @__profc_foo = private global [1 x i64] zeroinitializer, section "{{[^"]+}}", align 8, !associated !0 -; METADATA: @__profvp_foo = private global [1 x i64] zeroinitializer, section "{{[^"]+}}", align 8, !associated !1 -; METADATA: @__profc_bar = private global [1 x i64] zeroinitializer, section "{{[^"]+}}", comdat($__profd_bar), align 8, !associated !2 -; METADATA: @__profvp_bar = private global [1 x i64] zeroinitializer, section "{{[^"]+}}", comdat($__profd_bar), align 8, !associated !3 -; METADATA: !0 = !{i32 (i32 ()*)* @foo} -; METADATA: !1 = !{[1 x i64]* @__profc_foo} -; METADATA: !2 = !{i32 (i32 ()*)* @bar} -; METADATA: !3 = !{[1 x i64]* @__profc_bar} diff --git a/test/Instrumentation/InstrProfiling/linkage.ll b/test/Instrumentation/InstrProfiling/linkage.ll index ffad1f03eaa..6320060afe4 100644 --- a/test/Instrumentation/InstrProfiling/linkage.ll +++ b/test/Instrumentation/InstrProfiling/linkage.ll @@ -8,8 +8,6 @@ ; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX ; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX ; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF -; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -counter-link-order -S | FileCheck %s --check-prefixes=LINUX,POSIX,METADATA -; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -counter-link-order -S | FileCheck %s --check-prefixes=LINUX,POSIX,METADATA ; MACHO: @__llvm_profile_runtime = external global i32 ; LINUX-NOT: @__llvm_profile_runtime = external global i32 @@ -21,9 +19,7 @@ @__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern" ; POSIX: @__profc_foo = hidden global -; METADATA-SAME: !associated !0 ; POSIX: @__profd_foo = hidden global -; METADATA-SAME: !associated !1 ; COFF: @__profc_foo = internal global ; COFF-NOT: comdat ; COFF: @__profd_foo = internal global @@ -33,9 +29,7 @@ define void @foo() { } ; POSIX: @__profc_foo_weak = weak hidden global -; METADATA: !associated !2 ; POSIX: @__profd_foo_weak = weak hidden global -; METADATA: !associated !3 ; COFF: @__profc_foo_weak = internal global ; COFF: @__profd_foo_weak = internal global define weak void @foo_weak() { @@ -44,9 +38,7 @@ define weak void @foo_weak() { } ; POSIX: @"__profc_linkage.ll:foo_internal" = internal global -; METADATA-SAME: !associated !4 ; POSIX: @"__profd_linkage.ll:foo_internal" = internal global -; METADATA-SAME: !associated !5 ; COFF: @"__profc_linkage.ll:foo_internal" = internal global ; COFF: @"__profd_linkage.ll:foo_internal" = internal global define internal void @foo_internal() { @@ -55,9 +47,7 @@ define internal void @foo_internal() { } ; POSIX: @__profc_foo_inline = linkonce_odr hidden global -; METADATA-SAME: !associated !6 ; POSIX: @__profd_foo_inline = linkonce_odr hidden global -; METADATA-SAME: !associated !7 ; COFF: @__profc_foo_inline = internal global{{.*}} section ".lprfc$M", align 8 ; COFF: @__profd_foo_inline = internal global{{.*}} section ".lprfd$M", align 8 define linkonce_odr void @foo_inline() { @@ -66,9 +56,7 @@ define linkonce_odr void @foo_inline() { } ; LINUX: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_cnts", comdat($__profd_foo_extern), align 8 -; METADATA-SAME: !associated !8 ; LINUX: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_data", comdat, align 8 -; METADATA-SAME: !associated !9 ; MACHO: @__profc_foo_extern = linkonce_odr hidden global ; MACHO: @__profd_foo_extern = linkonce_odr hidden global ; COFF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfc$M", comdat, align 8 @@ -87,14 +75,3 @@ declare void @llvm.instrprof.increment(i8*, i64, i32, i32) ; COFF: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} comdat { ; LINUX-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} { ; LINUX-NOT: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime - -; METADATA: !0 = !{void ()* @foo} -; METADATA: !1 = !{[1 x i64]* @__profc_foo} -; METADATA: !2 = !{void ()* @foo_weak} -; METADATA: !3 = !{[1 x i64]* @__profc_foo_weak} -; METADATA: !4 = !{void ()* @foo_internal} -; METADATA: !5 = !{[1 x i64]* @"__profc_linkage.ll:foo_internal"} -; METADATA: !6 = !{void ()* @foo_inline} -; METADATA: !7 = !{[1 x i64]* @__profc_foo_inline} -; METADATA: !8 = !{void ()* @foo_extern} -; METADATA: !9 = !{[1 x i64]* @__profc_foo_extern} diff --git a/test/Transforms/PGOProfile/associated.ll b/test/Transforms/PGOProfile/associated.ll deleted file mode 100644 index 3f8b4af254a..00000000000 --- a/test/Transforms/PGOProfile/associated.ll +++ /dev/null @@ -1,12 +0,0 @@ -; RUN: opt < %s -pgo-instr-gen -instrprof -counter-link-order -S | FileCheck %s -; RUN: opt < %s -passes=pgo-instr-gen,instrprof -counter-link-order -S | FileCheck %s - -; CHECK: @__profc_foo = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8, !associated !0 -; CHECK: @__profd_foo = private global {{.*}}, section "__llvm_prf_data", align 8, !associated !1 - -define void @foo() { - ret void -} - -; CHECK: !0 = !{void ()* @foo} -; CHECK: !1 = !{[1 x i64]* @__profc_foo} diff --git a/test/Transforms/PGOProfile/counter_promo.ll b/test/Transforms/PGOProfile/counter_promo.ll index a477970830b..55930c1be16 100644 --- a/test/Transforms/PGOProfile/counter_promo.ll +++ b/test/Transforms/PGOProfile/counter_promo.ll @@ -60,7 +60,7 @@ bb12: ; preds = %bb9 ; ATOMIC_PROMO: atomicrmw add {{.*}} @__profc_foo{{.*}}0), i64 %[[LIVEOUT1]] seq_cst ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}1), i64 %[[LIVEOUT2]] seq_cst ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}2), i64 %[[LIVEOUT3]] seq_cst -; PROMO-NOT: @__profc_foo{{.*}}) +; PROMO-NOT: @__profc_foo } diff --git a/test/Transforms/PGOProfile/counter_promo_mexits.ll b/test/Transforms/PGOProfile/counter_promo_mexits.ll index 8e907acb34d..bb799757a47 100644 --- a/test/Transforms/PGOProfile/counter_promo_mexits.ll +++ b/test/Transforms/PGOProfile/counter_promo_mexits.ll @@ -69,7 +69,7 @@ bb15_0: ; preds = %bb11 ; PROMO-NEXT: %pgocount{{.*}} = load {{.*}} @__profc_foo{{.*}} 4) ; PROMO-NEXT: add ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}4) -; PROMO-NOT: @__profc_foo{{.*}}) +; PROMO-NOT: @__profc_foo bb15: ; preds = %bb14, %bb4