[llvm] 95f9026 - Revert "[SampleFDO] Using common linkage for the discriminator flag variable"
Rong Xu via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 15 21:24:32 PDT 2021
Author: Rong Xu
Date: 2021-06-15T21:22:23-07:00
New Revision: 95f9026c17880795f78563ec7a5673c240c33a5e
URL: https://github.com/llvm/llvm-project/commit/95f9026c17880795f78563ec7a5673c240c33a5e
DIFF: https://github.com/llvm/llvm-project/commit/95f9026c17880795f78563ec7a5673c240c33a5e.diff
LOG: Revert "[SampleFDO] Using common linkage for the discriminator flag variable"
This reverts commit 434fed5aff5e62460e2e984c7cc2674c12779b1e.
Post commit review suggested to use another implmenentation.
Detailed can be found in the review.
Added:
Modified:
llvm/lib/CodeGen/MIRFSDiscriminator.cpp
llvm/test/CodeGen/X86/fsafdo_test1.ll
llvm/test/CodeGen/X86/fsafdo_test2.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MIRFSDiscriminator.cpp b/llvm/lib/CodeGen/MIRFSDiscriminator.cpp
index db399a36e3cf9..b8d7d300e1de0 100644
--- a/llvm/lib/CodeGen/MIRFSDiscriminator.cpp
+++ b/llvm/lib/CodeGen/MIRFSDiscriminator.cpp
@@ -132,10 +132,9 @@ bool MIRAddFSDiscriminators::runOnMachineFunction(MachineFunction &MF) {
if (!M->getGlobalVariable(FSDiscriminatorVar)) {
auto &Context = M->getContext();
// Create a global variable to flag that FSDiscriminators are used.
- // Using "common" linkage so that it will not gc GC'ed.
- new GlobalVariable(*M, Type::getInt1Ty(Context), false,
- GlobalValue::CommonLinkage,
- ConstantInt::getFalse(Context), FSDiscriminatorVar);
+ new GlobalVariable(*M, Type::getInt1Ty(Context), true,
+ GlobalValue::WeakAnyLinkage,
+ ConstantInt::getTrue(Context), FSDiscriminatorVar);
}
LLVM_DEBUG(dbgs() << "Num of FS Discriminators: " << NumNewD << "\n");
diff --git a/llvm/test/CodeGen/X86/fsafdo_test1.ll b/llvm/test/CodeGen/X86/fsafdo_test1.ll
index af6c027250960..99c65c917f69e 100644
--- a/llvm/test/CodeGen/X86/fsafdo_test1.ll
+++ b/llvm/test/CodeGen/X86/fsafdo_test1.ll
@@ -1,13 +1,17 @@
; RUN: llc -enable-fs-discriminator < %s | FileCheck %s
;
-;; Check that fs-afdo discriminators are generated.
+; Check that fs-afdo discriminators are generated.
; CHECK: .loc 1 7 3 is_stmt 0 discriminator 2 # foo.c:7:3
; Check: .loc 1 9 5 is_stmt 1 discriminator 2 # foo.c:9:5
; CHECK: .loc 1 9 5 is_stmt 0 discriminator 268435458 # foo.c:9:5
; CHECK: .loc 1 7 3 is_stmt 1 discriminator 3892314114 # foo.c:7:3
-;; Check that variable __llvm_fs_discriminator__ is generated.
-; CHECK: .type __llvm_fs_discriminator__, at object
-; CHECK: .comm __llvm_fs_discriminator__,1,1
+; Check that variable __llvm_fs_discriminator__ is generated.
+; CHECK: .type __llvm_fs_discriminator__, at object # @__llvm_fs_discriminator__
+; CHECK: .section .rodata,"a", at progbits
+; CHECK: .weak __llvm_fs_discriminator__
+; CHECK: __llvm_fs_discriminator__:
+; CHECK: .byte 1
+; CHECK: .size __llvm_fs_discriminator__, 1
target triple = "x86_64-unknown-linux-gnu"
diff --git a/llvm/test/CodeGen/X86/fsafdo_test2.ll b/llvm/test/CodeGen/X86/fsafdo_test2.ll
index 07ea1be2463a5..ca26f307b08be 100644
--- a/llvm/test/CodeGen/X86/fsafdo_test2.ll
+++ b/llvm/test/CodeGen/X86/fsafdo_test2.ll
@@ -43,8 +43,12 @@
; CHECK: .loc 1 23 9 is_stmt 0 discriminator 3623878657 # unroll.c:23:9
;;
;; Check that variable __llvm_fs_discriminator__ is generated.
-; CHECK: .type __llvm_fs_discriminator__, at object
-; CHECK: .comm __llvm_fs_discriminator__,1,1
+; CHECK: .type __llvm_fs_discriminator__, at object # @__llvm_fs_discriminator__
+; CHECK: .section .rodata,"a", at progbits
+; CHECK: .weak __llvm_fs_discriminator__
+; CHECK: __llvm_fs_discriminator__:
+; CHECK: .byte 1
+; CHECK: .size __llvm_fs_discriminator__, 1
target triple = "x86_64-unknown-linux-gnu"
More information about the llvm-commits
mailing list