diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils/SampleProfileLoaderBaseUtil.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SampleProfileLoaderBaseUtil.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SampleProfileLoaderBaseUtil.cpp b/llvm/lib/Transforms/Utils/SampleProfileLoaderBaseUtil.cpp index d2cd0de..6d995cf4 100644 --- a/llvm/lib/Transforms/Utils/SampleProfileLoaderBaseUtil.cpp +++ b/llvm/lib/Transforms/Utils/SampleProfileLoaderBaseUtil.cpp @@ -159,5 +159,19 @@ unsigned SampleCoverageTracker::computeCoverage(unsigned Used, return Total > 0 ? Used * 100 / Total : 100; } +/// Create a global variable to flag FSDiscriminators are used. +void createFSDiscriminatorVariable(Module *M) { + const char *FSDiscriminatorVar = "__llvm_fs_discriminator__"; + if (M->getGlobalVariable(FSDiscriminatorVar)) + return; + + auto &Context = M->getContext(); + // Place this variable to llvm.used so it won't be GC'ed. + appendToUsed(*M, {new GlobalVariable(*M, Type::getInt1Ty(Context), true, + GlobalValue::WeakODRLinkage, + ConstantInt::getTrue(Context), + FSDiscriminatorVar)}); +} + } // end of namespace sampleprofutil } // end of namespace llvm |