LLVM  10.0.0svn
MisExpect.h
Go to the documentation of this file.
1 //===--- MisExpect.h - Check the use of llvm.expect with PGO data ---------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This contains code to emit warnings for potentially incorrect usage of the
10 // llvm.expect intrinsic. This utility extracts the threshold values from
11 // metadata associated with the instrumented Branch or Switch instruction. The
12 // threshold values are then used to determine if a warning should be emmited.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/IR/Function.h"
18 #include "llvm/IR/Instructions.h"
19 #include "llvm/IR/LLVMContext.h"
20 
21 namespace llvm {
22 namespace misexpect {
23 
24 /// verifyMisExpect - compares PGO counters to the thresholds used for
25 /// llvm.expect and warns if the PGO counters are outside of the expected
26 /// range.
27 /// \param I The Instruction being checked
28 /// \param Weights A vector of profile weights for each target block
29 /// \param Ctx The current LLVM context
31  const llvm::SmallVector<uint32_t, 4> &Weights,
32  llvm::LLVMContext &Ctx);
33 
34 /// checkClangInstrumentation - verify if llvm.expect matches PGO profile
35 /// This function checks the frontend instrumentation in the backend when
36 /// lowering llvm.expect intrinsics. It checks for existing metadata, and
37 /// then validates the use of llvm.expect against the assigned branch weights.
38 //
39 /// \param I the Instruction being checked
41 
42 } // namespace misexpect
43 } // namespace llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:23
void verifyMisExpect(llvm::Instruction *I, const llvm::SmallVector< uint32_t, 4 > &Weights, llvm::LLVMContext &Ctx)
verifyMisExpect - compares PGO counters to the thresholds used for llvm.expect and warns if the PGO c...
Definition: MisExpect.cpp:95
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:64
#define I(x, y, z)
Definition: MD5.cpp:58
void checkFrontendInstrumentation(Instruction &I)
checkClangInstrumentation - verify if llvm.expect matches PGO profile This function checks the fronte...
Definition: MisExpect.cpp:147