|
|
|||
File indexing completed on 2026-05-10 08:44:43
0001 //===--- MisExpect.h - Check the use of llvm.expect with PGO data ---------===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // This contains code to emit diagnostic messages for potentially incorrect 0010 // usage of the llvm.expect intrinsic. This utility extracts the threshold 0011 // values from metadata associated with the instrumented Branch or Switch 0012 // instruction. The threshold values are then used to determine if a diagnostic 0013 // should be emitted. 0014 // 0015 //===----------------------------------------------------------------------===// 0016 0017 #ifndef LLVM_TRANSFORMS_UTILS_MISEXPECT_H 0018 #define LLVM_TRANSFORMS_UTILS_MISEXPECT_H 0019 0020 #include "llvm/ADT/SmallVector.h" 0021 #include "llvm/IR/Function.h" 0022 #include "llvm/IR/Instructions.h" 0023 #include "llvm/IR/LLVMContext.h" 0024 0025 namespace llvm { 0026 namespace misexpect { 0027 0028 /// checkBackendInstrumentation - compares PGO counters to the thresholds used 0029 /// for llvm.expect and warns if the PGO counters are outside of the expected 0030 /// range. It extracts the expected weights from the MD_prof weights attached 0031 /// to the instruction, which are assumed to come from lowered llvm.expect 0032 /// intrinsics. The RealWeights parameter and the extracted expected weights are 0033 /// then passed to verifyMisexpect() for verification 0034 /// 0035 /// \param I The Instruction being checked 0036 /// \param RealWeights A vector of profile weights for each target block 0037 void checkBackendInstrumentation(Instruction &I, 0038 const llvm::ArrayRef<uint32_t> RealWeights); 0039 0040 /// checkFrontendInstrumentation - compares PGO counters to the thresholds used 0041 /// for llvm.expect and warns if the PGO counters are outside of the expected 0042 /// range. It extracts the expected weights from the MD_prof weights attached 0043 /// to the instruction, which are assumed to come from profiling data 0044 /// attached by the frontend prior to llvm.expect intrinsic lowering. The 0045 /// ExpectedWeights parameter and the extracted real weights are then passed to 0046 /// verifyMisexpect() for verification 0047 /// 0048 /// \param I The Instruction being checked 0049 /// \param ExpectedWeights A vector of the expected weights for each target 0050 /// block, this determines the threshold values used when emitting diagnostics 0051 void checkFrontendInstrumentation(Instruction &I, 0052 const ArrayRef<uint32_t> ExpectedWeights); 0053 0054 /// veryifyMisExpect - compares RealWeights to the thresholds used 0055 /// for llvm.expect and warns if the PGO counters are outside of the expected 0056 /// range. 0057 /// 0058 /// \param I The Instruction being checked 0059 /// \param RealWeights A vector of profile weights from the profile data 0060 /// \param ExpectedWeights A vector of the weights attatch by llvm.expect 0061 void verifyMisExpect(Instruction &I, ArrayRef<uint32_t> RealWeights, 0062 const ArrayRef<uint32_t> ExpectedWeights); 0063 0064 /// checkExpectAnnotations - compares PGO counters to the thresholds used 0065 /// for llvm.expect and warns if the PGO counters are outside of the expected 0066 /// range. It extracts the expected weights from the MD_prof weights attached 0067 /// to the instruction, which are assumed to come from lowered llvm.expect 0068 /// intrinsics. The RealWeights parameter and the extracted expected weights are 0069 /// then passed to verifyMisexpect() for verification. It is a thin wrapper 0070 /// around the checkFrontendInstrumentation and checkBackendInstrumentation APIs 0071 /// 0072 /// \param I The Instruction being checked 0073 /// \param ExistingWeights A vector of profile weights for each target block 0074 /// \param IsFrontend A boolean describing if this is Frontend instrumentation 0075 void checkExpectAnnotations(Instruction &I, 0076 const ArrayRef<uint32_t> ExistingWeights, 0077 bool IsFrontend); 0078 0079 } // namespace misexpect 0080 } // namespace llvm 0081 0082 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|