LLVM 23.0.0git
Instrumentor.h
Go to the documentation of this file.
1//===-- Instrumentor.h - Highly configurable instrumentation pass ---------===//
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// The Instrumentor, a highly configurable instrumentation pass.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_TRANSFORMS_IPO_INSTRUMENTOR_H
14#define LLVM_TRANSFORMS_IPO_INSTRUMENTOR_H
15
16#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/MapVector.h"
20#include "llvm/ADT/StringMap.h"
21#include "llvm/ADT/StringRef.h"
23#include "llvm/IR/Constants.h"
24#include "llvm/IR/DataLayout.h"
25#include "llvm/IR/IRBuilder.h"
26#include "llvm/IR/Instruction.h"
28#include "llvm/IR/LLVMContext.h"
29#include "llvm/IR/Module.h"
30#include "llvm/IR/PassManager.h"
36
37#include <cstdint>
38#include <functional>
39#include <memory>
40#include <string>
41#include <tuple>
42
43namespace llvm {
44namespace instrumentor {
45
48
49/// Callback type for getting/setting a value for a instrumented opportunity.
50///{
51using GetterCallbackTy = std::function<Value *(
53using SetterCallbackTy = std::function<Value *(
55///}
56
57/// Helper to represent an argument to an instrumentation runtime function.
58struct IRTArg {
59 /// Flags describing the possible properties of an argument.
61 NONE = 0,
62 STRING = 1 << 0,
63 REPLACABLE = 1 << 1,
67 VALUE_PACK = 1 << 5,
69 };
70
71 /// Construct an argument.
78
79 /// Whether the argument is enabled and should be passed to the function call.
80 bool Enabled;
81
82 /// The type of the argument.
84
85 /// A string with the name of the argument.
87
88 /// A string with the description of the argument.
90
91 /// The flags that describe the properties of the argument. Multiple flags may
92 /// be specified.
93 unsigned Flags;
94
95 /// The callback for getting the value of the argument.
97
98 /// The callback for consuming the output value of the argument.
100
101 /// Whether the argument value can be cached between the PRE and POST calls.
103};
104
105/// Helper to represent an instrumentation runtime function that is related to
106/// an instrumentation opportunity.
108 /// Construct an instrumentation function description linked to the \p IO
109 /// instrumentation opportunity and \p RetTy return type.
111
112 /// Create the type of the instrumentation function.
115 const DataLayout &DL,
116 bool ForceIndirection);
117
118 /// Create a call instruction that calls to the instrumentation function and
119 /// passes the corresponding arguments.
122 InstrumentationCaches &ICaches);
123
124 /// Create a string representation of the function declaration in C. Two
125 /// strings are returned: the function definition with direct arguments and
126 /// the function with any indirect argument.
127 std::pair<std::string, std::string>
128 createCSignature(const InstrumentationConfig &IConf) const;
129
130 /// Create a string representation of the function definition in C. The
131 /// function body implements a stub and only prints the passed arguments. Two
132 /// strings are returned: the function definition with direct arguments and
133 /// the function with any indirect argument.
134 std::pair<std::string, std::string> createCBodies() const;
135
136 /// Return whether the \p IRTA argument can be replaced.
137 bool isReplacable(IRTArg &IRTA) const {
139 }
140
141 /// Return whether the function may have any indirect argument.
142 bool isPotentiallyIndirect(IRTArg &IRTA) const {
143 return ((IRTA.Flags & IRTArg::POTENTIALLY_INDIRECT) ||
145 }
146
147 /// Whether the function requires indirection in some argument.
149
150 /// Whether any argument may require indirection.
152
153 /// The number of arguments that can be replaced.
154 unsigned NumReplaceableArgs = 0;
155
156 /// The instrumentation opportunity which it is linked to.
158
159 /// The return type of the instrumentation function.
160 Type *RetTy = nullptr;
161};
162
163/// Helper to represent an instrumentation location, which is composed of an
164/// instrumentation opportunity type and a position.
166 /// The supported location kinds, which are composed of a opportunity type and
167 /// position. The PRE position indicates the instrumentation function call is
168 /// inserted before the instrumented event occurs. The POST position indicates
169 /// the instrumentation call is inserted after the event occurs. Some
170 /// opportunity types may only support one position.
185
186 /// Construct an instrumentation location with the given kind.
187 InstrumentationLocation(KindTy Kind) : Kind(Kind) {}
188
189 /// Return the type and position.
190 KindTy getKind() const { return Kind; }
191
192 /// Return the string representation given a location kind. This is the string
193 /// used in the configuration file.
195 switch (Kind) {
196 case MODULE_PRE:
197 return "module_pre";
198 case MODULE_POST:
199 return "module_post";
200 case GLOBAL_PRE:
201 return "global_pre";
202 case GLOBAL_POST:
203 return "global_post";
204 case FUNCTION_PRE:
205 return "function_pre";
206 case FUNCTION_POST:
207 return "function_post";
208 case BASIC_BLOCK_PRE:
209 return "basic_block_pre";
210 case BASIC_BLOCK_POST:
211 return "basic_block_post";
212 case INSTRUCTION_PRE:
213 return "instruction_pre";
214 case INSTRUCTION_POST:
215 return "instruction_post";
216 case SPECIAL_VALUE:
217 return "special_value";
218 }
219 llvm_unreachable("Invalid kind!");
220 }
221
222 /// Return the location kind described by a string.
224 return StringSwitch<KindTy>(S)
225 .Case("module_pre", MODULE_PRE)
226 .Case("module_post", MODULE_POST)
227 .Case("global_pre", GLOBAL_PRE)
228 .Case("global_post", GLOBAL_POST)
229 .Case("function_pre", FUNCTION_PRE)
230 .Case("function_post", FUNCTION_POST)
231 .Case("basic_block_pre", BASIC_BLOCK_PRE)
232 .Case("basic_block_post", BASIC_BLOCK_POST)
233 .Case("instruction_pre", INSTRUCTION_PRE)
234 .Case("instruction_post", INSTRUCTION_POST)
235 .Case("special_value", SPECIAL_VALUE)
236 .Default(Last);
237 }
238
239 /// Return whether a location kind is positioned before the event occurs.
240 static bool isPRE(KindTy Kind) {
241 switch (Kind) {
242 case MODULE_PRE:
243 case GLOBAL_PRE:
244 case FUNCTION_PRE:
245 case BASIC_BLOCK_PRE:
246 case INSTRUCTION_PRE:
247 return true;
248 case MODULE_POST:
249 case GLOBAL_POST:
250 case FUNCTION_POST:
251 case BASIC_BLOCK_POST:
252 case INSTRUCTION_POST:
253 case SPECIAL_VALUE:
254 return false;
255 }
256 llvm_unreachable("Invalid kind!");
257 }
258
259 /// Return whether the instrumentation location is before the event occurs.
260 bool isPRE() const { return isPRE(Kind); }
261
262private:
263 /// The kind (type and position) of the instrumentation location.
264 const KindTy Kind;
265};
266
267/// An option for the base configuration.
269 /// The possible types of options.
274
275 /// Create a boolean option with \p Name name, \p Description description and
276 /// \p DefaultValue as boolean default value.
277 static std::unique_ptr<BaseConfigurationOption>
279 StringRef Description, bool DefaultValue);
280
281 /// Create a string option with \p Name name, \p Description description and
282 /// \p DefaultValue as string default value.
283 static std::unique_ptr<BaseConfigurationOption>
285 StringRef Description, StringRef DefaultValue);
286
287 /// Helper union that holds any possible option type.
288 union ValueTy {
289 bool Bool;
291 };
292
293 /// Set and get of the boolean value. Only valid if it is a boolean option.
294 ///{
295 void setBool(bool B) {
296 assert(Kind == BOOLEAN && "Not a boolean!");
297 Value.Bool = B;
298 }
299 bool getBool() const {
300 assert(Kind == BOOLEAN && "Not a boolean!");
301 return Value.Bool;
302 }
303 ///}
304
305 /// Set and get the string value. Only valid if it is a boolean option.
306 ///{
308 assert(Kind == STRING && "Not a string!");
309 Value.String = S;
310 }
312 assert(Kind == STRING && "Not a string!");
313 return Value.String;
314 }
315 ///}
316
317 /// The information of the option.
318 ///{
323 ///}
324
325 /// Construct a base configuration option.
328};
329
330/// The class that contains the configuration for the instrumentor. It holds the
331/// information for each instrumented opportunity, including the base
332/// configuration options. Another class may inherit from this one to modify the
333/// default behavior.
336
337 /// Construct an instrumentation configuration with the base options.
339
340 /// Initialize the config to a clean base state without loosing cached values
341 /// that can be reused across configurations.
343 // Clear previous configurations but not the caches.
345 for (auto &Map : IChoices)
346 Map.clear();
347
349 *this, "runtime_prefix", "The runtime API prefix.", "__instrumentor_");
351 *this, "runtime_stubs_file",
352 "The file into which runtime stubs should be written.", "");
354 *this, "target_regex",
355 "Regular expression to be matched against the module target. "
356 "Only targets that match this regex will be instrumented.",
357 "");
359 *this, "function_regex",
360 "Regular expression to be matched against a function name. "
361 "Only functions that match this regex will be instrumented.",
362 "");
364 *this, "demangle_function_names",
365 "Demangle functions names passed to the runtime.", true);
367 *this, "host_enabled", "Instrument non-GPU targets", true);
369 *this, "gpu_enabled", "Instrument GPU targets", true);
370 populate(IIRB);
371 }
372
373 /// Populate the instrumentation opportunities.
374 virtual void populate(InstrumentorIRBuilderTy &IIRB);
375
376 /// Get the runtime prefix for the instrumentation runtime functions.
377 StringRef getRTName() const { return RuntimePrefix->getString(); }
378
379 /// Get the instrumentation function name.
380 std::string getRTName(StringRef Prefix, StringRef Name,
381 StringRef Suffix1 = "", StringRef Suffix2 = "") const {
382 return (getRTName() + Prefix + Name + Suffix1 + Suffix2).str();
383 }
384
385 /// Add the base configuration option \p BCO into the list of base options.
387 BaseConfigurationOptions.push_back(BCO);
388 }
389
390 /// Register instrumentation opportunity \p IO.
392
393 /// Allocate an object of type \p Ty using a bump allocator and construct it
394 /// with the \p Args arguments. The object may not be freed manually.
395 template <typename Ty, typename... ArgsTy>
396 static Ty *allocate(ArgsTy &&...Args) {
398 Ty *Obj = Allocator.Allocate();
399 new (Obj) Ty(std::forward<ArgsTy>(Args)...);
400 return Obj;
401 }
402
403 /// Map to remember underlying objects for pointers.
405
406 /// Map to remember base pointer info for values in a specific function.
408
409 /// Return the base pointer info for \p V.
411
412 /// Mapping to remember global strings passed to the runtime.
414
415 /// Mapping from constants to globals with the constant as initializer.
417
419 Constant *&V = GlobalStringsMap[SS.save(S)];
420 if (!V) {
421 auto &M = *IIRB.IRB.GetInsertBlock()->getModule();
422 V = IIRB.IRB.CreateGlobalString(
423 S, getRTName() + ".str",
424 M.getDataLayout().getDefaultGlobalsAddressSpace(), &M);
425 if (V->getType() != IIRB.IRB.getPtrTy())
426 V = ConstantExpr::getAddrSpaceCast(V, IIRB.IRB.getPtrTy());
427 }
428 return V;
429 }
430 /// The list of enabled base configuration options.
432
433 /// The base configuration options.
434 std::unique_ptr<BaseConfigurationOption> RuntimePrefix;
435 std::unique_ptr<BaseConfigurationOption> RuntimeStubsFile;
436 std::unique_ptr<BaseConfigurationOption> DemangleFunctionNames;
437 std::unique_ptr<BaseConfigurationOption> TargetRegex;
438 std::unique_ptr<BaseConfigurationOption> FunctionRegex;
439 std::unique_ptr<BaseConfigurationOption> HostEnabled;
440 std::unique_ptr<BaseConfigurationOption> GPUEnabled;
441
442 /// The map registered instrumentation opportunities. The map is indexed by
443 /// the instrumentation location kind and then by the opportunity name. Notice
444 /// that an instrumentation location may have more than one instrumentation
445 /// opportunity registered.
449
450 /// Utilities for allocating and building strings.
451 ///{
454 ///}
455};
456
457/// Base class for instrumentation opportunities. All opportunities should
458/// inherit from this class and implement the virtual class members.
461
462 /// Construct an opportunity with location \p IP.
464
465 /// The instrumentation location of the opportunity.
467
468 /// The list of possible arguments for the instrumentation runtime function.
469 /// The order within the array determines the order of arguments. Arguments
470 /// may be disabled and will not be passed to the function call.
472
473 /// Whether the opportunity is enabled.
474 bool Enabled = true;
475
476 /// A filter expression to be matched against runtime property values. If the
477 /// filter is non-empty, only instrumentations matching the filter will be
478 /// executed. The filter syntax supports:
479 /// - Integer comparisons: ==, !=, <, >, <=, >=
480 /// - String comparisons: ==, != (with quoted strings)
481 /// - String prefix check: startswith("prefix")
482 /// - Logical operators: &&, ||
483 /// Examples:
484 /// "sync_scope_id==3 && atomicity_ordering>0"
485 /// "name==\"foo\" || name.startswith(\"test_\")"
486 /// If a property value is dynamic (not a constant), the filter is assumed to
487 /// pass (true).
489
490 /// Helpers to cast values, pass them to the runtime, and replace them. To be
491 /// used as part of the getter/setter of a InstrumentationOpportunity.
492 ///{
493 static Value *forceCast(Value &V, Type &Ty, InstrumentorIRBuilderTy &IIRB);
496 return forceCast(V, Ty, IIRB);
497 }
498 static Value *replaceValue(Value &V, Value &NewV,
501 ///}
502
503 /// Instrument the value \p V using the configuration \p IConf, and
504 /// potentially, the caches \p ICaches.
505 virtual Value *instrument(Value *&V, bool &Changed,
508 InstrumentationCaches &ICaches) {
509 if (CB && !CB(*V))
510 return nullptr;
511
512 // Check if the filter matches before instrumenting
513 if (!evaluateFilter(*V, Changed, *this, IConf, IIRB))
514 return nullptr;
515
516 Changed = true;
517 const DataLayout &DL = IIRB.IRB.GetInsertBlock()->getDataLayout();
518 IRTCallDescription IRTCallDesc(*this, getRetTy(V->getContext()));
519 auto *CI = IRTCallDesc.createLLVMCall(V, IConf, IIRB, DL, ICaches);
520 return CI;
521 }
522
523 /// Get the return type for the instrumentation runtime function.
524 virtual Type *getRetTy(LLVMContext &Ctx) const { return nullptr; }
525
526 /// Get the name of the instrumentation opportunity.
527 virtual StringRef getName() const = 0;
528
529 /// Get all opcodes for this instrumentation opportunity. For non-instruction
530 /// opportunities, returns an empty array. For instruction opportunities,
531 /// returns an array of all opcodes this IO handles.
532 virtual ArrayRef<unsigned> getAllOpcodes() const { return {}; }
533
534 /// Get the location kind of the instrumentation opportunity.
536 return IP.getKind();
537 }
538
539 /// An optional callback that takes the value that is about to be
540 /// instrumented and can return false if it should be skipped.
541 ///{
542 using CallbackTy = std::function<bool(Value &)>;
543 CallbackTy CB = nullptr;
544 ///}
545
546 /// Add arguments available in all instrumentation opportunities.
548 bool PassId) {
549 const auto CB = IP.isPRE() ? getIdPre : getIdPost;
550 if (PassId) {
551 IRTArgs.push_back(
553 "A unique ID associated with the given instrumentor call",
554 IRTArg::NONE, CB, nullptr, true, true));
555 }
556 }
557
558 /// Get the opportunity identifier for the pre and post positions.
559 ///{
560 static Value *getIdPre(Value &V, Type &Ty, InstrumentationConfig &IConf,
562 static Value *getIdPost(Value &V, Type &Ty, InstrumentationConfig &IConf,
564 ///}
565
566 /// Compute the opportunity identifier for the current instrumentation epoch
567 /// \p CurrentEpoch. The identifiers are assigned consecutively as the epoch
568 /// advances. Epochs may have no identifier assigned (e.g., because no id was
569 /// requested). This function always returns the same identifier when called
570 /// multiple times with the same epoch.
571 static int32_t getIdFromEpoch(uint32_t CurrentEpoch) {
572 static DenseMap<uint32_t, int32_t> EpochIdMap;
573 static int32_t GlobalId = 0;
574 int32_t &EpochId = EpochIdMap[CurrentEpoch];
575 if (EpochId == 0)
576 EpochId = ++GlobalId;
577 return EpochId;
578 }
579};
580
581/// The base instrumentation opportunity class for instruction opportunities.
582/// Each instruction opportunity should inherit from this class and implement
583/// the virtual class members. If multiple opcodes are provided, all of them
584/// are instrumented using the same logic, and a name must be explicitly
585/// provided by overriding getName().
586template <unsigned... Opcodes>
588 virtual ~InstructionIO() {}
589
590 /// Construct an instruction opportunity.
593 static_assert(sizeof...(Opcodes) >= 1,
594 "InstructionIO must have at least one opcode");
595 }
596
597 static constexpr std::array<unsigned, sizeof...(Opcodes)> OpcodesArray = {
598 Opcodes...};
599
600 /// Get all opcodes for this instrumentation opportunity (override).
601 ArrayRef<unsigned> getAllOpcodes() const override { return OpcodesArray; }
602
603 /// Get the number of opcodes.
604 static constexpr size_t getNumOpcodes() { return OpcodesArray.size(); }
605
606 /// Get the name of the instruction. For single-opcode IOs, this defaults to
607 /// the opcode name. For multi-opcode IOs, getName() MUST be overridden to
608 /// provide an explicit name identifying the whole group of opcodes.
609 virtual StringRef getName() const override {
610 // This method should not be called for multi-opcode IOs.
611 // Multi-opcode IOs must override getName().
612 assert(sizeof...(Opcodes) == 1 &&
613 "Multi-opcode InstructionIO must override getName() to provide an "
614 "explicit name instead of using the first opcode");
615 // Get the first opcode from the opcodes array.
617 }
618};
619
620/// The instrumentation opportunity for functions.
624
635
636 struct ConfigTy final : public BaseConfigTy<ConfigKind> {
637 std::function<bool(Argument &)> ArgFilter;
638
641
642 StringRef getName() const override { return "function"; }
643
645 ConfigTy *UserConfig = nullptr);
646
647 static Value *getFunctionAddress(Value &V, Type &Ty,
650 static Value *getFunctionName(Value &V, Type &Ty,
659 static Value *isMainFunction(Value &V, Type &Ty, InstrumentationConfig &IConf,
661
662 static void populate(InstrumentationConfig &IConf,
664 auto *PreIO =
666 PreIO->init(IConf, IIRB);
667 auto *PostIO =
669 PostIO->init(IConf, IIRB);
670 }
671};
672
673/// The instrumentation opportunity for alloca instructions.
674struct AllocaIO final : public InstructionIO<Instruction::Alloca> {
676
686
689
691 ConfigTy *UserConfig = nullptr);
692
693 static Value *getSize(Value &V, Type &Ty, InstrumentationConfig &IConf,
695 static Value *setSize(Value &V, Value &NewV, InstrumentationConfig &IConf,
697 static Value *getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf,
699
700 static void populate(InstrumentationConfig &IConf,
702 auto *PreIO =
704 PreIO->init(IConf, IIRB);
705 auto *PostIO =
707 PostIO->init(IConf, IIRB);
708 }
709};
710
711struct UnreachableIO final : public InstructionIO<Instruction::Unreachable> {
713 : InstructionIO<Instruction::Unreachable>(
714 InstrumentationLocation::INSTRUCTION_PRE) {}
715
720
723
725 ConfigTy *UserConfig = nullptr);
726
727 static void populate(InstrumentationConfig &IConf,
729 auto *PreIO = IConf.allocate<UnreachableIO>();
730 PreIO->init(IConf, IIRB);
731 }
732};
733
734// Special instrumentation opportunity for base pointers of memory operations.
739 virtual ~BasePointerIO() {};
740
747
750
751 StringRef getName() const override { return "base_pointer_info"; }
752
754 ConfigTy *UserConfig = nullptr);
755
756 static Value *getPointerKind(Value &V, Type &Ty, InstrumentationConfig &IConf,
758
759 /// This is necessary to produce a return value that can be used by other IOs.
760 /// No replacement is actually happening.
761 static Value *setValueNoop(Value &V, Value &NewV,
764 return &NewV;
765 }
766
767 static void populate(InstrumentationConfig &IConf,
769 auto *BPIO = IConf.allocate<BasePointerIO>();
770 BPIO->init(IConf, IIRB);
771 }
772};
773
774// Module instrumentation opportunity.
778
785
788
789 StringRef getName() const override { return "module"; }
790
792 ConfigTy *UserConfig = nullptr);
793
794 static Value *getModuleName(Value &V, Type &Ty, InstrumentationConfig &IConf,
796 static Value *getTargetTriple(Value &V, Type &Ty,
799
800 static void populate(InstrumentationConfig &IConf,
803 PreIO->init(IConf, IIRB);
804 auto *PostIO =
806 PostIO->init(IConf, IIRB);
807 }
808};
809
810// Global variable instrumentation opportunity.
814
828
831
832 StringRef getName() const override { return "global"; }
833
835 ConfigTy *UserConfig = nullptr);
836
837 static Value *getAddress(Value &V, Type &Ty, InstrumentationConfig &IConf,
839 static Value *setAddress(Value &V, Value &NewV, InstrumentationConfig &IConf,
841 static Value *getAS(Value &V, Type &Ty, InstrumentationConfig &IConf,
843 static Value *getDeclaredSize(Value &V, Type &Ty,
846 static Value *getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf,
848 static Value *getSymbolName(Value &V, Type &Ty, InstrumentationConfig &IConf,
850 static Value *getInitialValue(Value &V, Type &Ty,
853 static Value *isConstant(Value &V, Type &Ty, InstrumentationConfig &IConf,
855 static Value *isDefinition(Value &V, Type &Ty, InstrumentationConfig &IConf,
857
858 static void populate(InstrumentationConfig &IConf,
860 auto *PreIO =
862 PreIO->init(IConf, IIRB);
863 auto *PostIO =
865 PostIO->init(IConf, IIRB);
866 }
867};
868
869/// The instrumentation opportunity for store instructions.
870struct StoreIO : public InstructionIO<Instruction::Store> {
871 virtual ~StoreIO() {};
872
873 /// Construct a store instruction opportunity.
875
876 /// The selector of arguments for store opportunities.
877 ///{
893
896 ///}
897
898 /// Get the type of the stored value.
900 return IIRB.Int64Ty;
901 }
902
903 /// Initialize the store opportunity using the instrumentation config \p IConf
904 /// and the user config \p UserConfig.
906 ConfigTy *UserConfig = nullptr);
907
908 /// Getters and setters for the arguments of the instrumentation function for
909 /// the store opportunity.
910 ///{
911 static Value *getPointer(Value &V, Type &Ty, InstrumentationConfig &IConf,
913 static Value *setPointer(Value &V, Value &NewV, InstrumentationConfig &IConf,
915 static Value *getPointerAS(Value &V, Type &Ty, InstrumentationConfig &IConf,
917 static Value *getBasePointerInfo(Value &V, Type &Ty,
920 static Value *getValue(Value &V, Type &Ty, InstrumentationConfig &IConf,
922 static Value *getValueSize(Value &V, Type &Ty, InstrumentationConfig &IConf,
924 static Value *getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf,
926 static Value *getValueTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf,
928 static Value *getAtomicityOrdering(Value &V, Type &Ty,
931 static Value *getSyncScopeId(Value &V, Type &Ty, InstrumentationConfig &IConf,
933 static Value *isVolatile(Value &V, Type &Ty, InstrumentationConfig &IConf,
935 ///}
936
937 /// Create the store opportunities for pre and post positions. The
938 /// opportunities are also initialized with the arguments for their
939 /// instrumentation calls.
940 static void populate(InstrumentationConfig &IConf,
942 auto *PreIO =
944 PreIO->init(IConf, IIRB);
945 auto *PostIO =
947 PostIO->init(IConf, IIRB);
948 }
949};
950
951/// The instrumentation opportunity for load instructions.
952struct LoadIO : public InstructionIO<Instruction::Load> {
953 virtual ~LoadIO() {};
954
955 /// Construct a load opportunity.
957
958 /// The selector of arguments for load opportunities.
959 ///{
976
979 ///}
980
981 /// Get the type of the loaded value.
983 return IIRB.Int64Ty;
984 }
985
986 /// Initialize the load opportunity using the instrumentation config \p IConf
987 /// and the user config \p UserConfig.
989 ConfigTy *UserConfig = nullptr);
990
991 /// Getters and setters for the arguments of the instrumentation function for
992 /// the load opportunity.
993 ///{
994 static Value *getPointer(Value &V, Type &Ty, InstrumentationConfig &IConf,
996 static Value *setPointer(Value &V, Value &NewV, InstrumentationConfig &IConf,
998 static Value *getPointerAS(Value &V, Type &Ty, InstrumentationConfig &IConf,
1000 static Value *getBasePointerInfo(Value &V, Type &Ty,
1001 InstrumentationConfig &IConf,
1003 static Value *getValue(Value &V, Type &Ty, InstrumentationConfig &IConf,
1005 static Value *getValueSize(Value &V, Type &Ty, InstrumentationConfig &IConf,
1007 static Value *getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf,
1009 static Value *getValueTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf,
1011 static Value *getAtomicityOrdering(Value &V, Type &Ty,
1012 InstrumentationConfig &IConf,
1014 static Value *getSyncScopeId(Value &V, Type &Ty, InstrumentationConfig &IConf,
1016 static Value *isVolatile(Value &V, Type &Ty, InstrumentationConfig &IConf,
1018 ///}
1019
1020 /// Create the load opportunities for PRE and POST positions.
1023 auto *PreIO =
1025 PreIO->init(IConf, IIRB);
1026 auto *PostIO =
1028 PostIO->init(IConf, IIRB);
1029 }
1030};
1031
1032/// The instrumentation opportunity for type cast instructions.
1033/// This includes PtrToInt, IntToPtr, Trunc, ZExt, SExt, FPToUI, FPToSI,
1034/// UIToFP, SIToFP, FPTrunc, FPExt, AddrSpaceCast, and BitCast.
1035struct CastIO final
1036 : public InstructionIO<
1037 Instruction::PtrToInt, Instruction::IntToPtr, Instruction::Trunc,
1038 Instruction::ZExt, Instruction::SExt, Instruction::FPToUI,
1039 Instruction::FPToSI, Instruction::UIToFP, Instruction::SIToFP,
1040 Instruction::FPTrunc, Instruction::FPExt, Instruction::AddrSpaceCast,
1041 Instruction::BitCast> {
1043
1056
1059
1060 StringRef getName() const override { return "cast"; }
1061
1063 ConfigTy *UserConfig = nullptr);
1064
1065 static Value *getInput(Value &V, Type &Ty, InstrumentationConfig &IConf,
1067 static Value *getInputTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf,
1069 static Value *getInputSize(Value &V, Type &Ty, InstrumentationConfig &IConf,
1071 static Value *getResultTypeId(Value &V, Type &Ty,
1072 InstrumentationConfig &IConf,
1074 static Value *getResultSize(Value &V, Type &Ty, InstrumentationConfig &IConf,
1076
1079 auto *PreIO =
1081 PreIO->init(IConf, IIRB);
1082 auto *PostIO =
1084 PostIO->init(IConf, IIRB);
1085 }
1086};
1087
1088/// Instrumentation opportunity for numeric operations. This includes Add, FAdd,
1089/// Sub, FSub, Mul, FMul, UDiv, FDiv, SDiv, URem, SRem, FRem, Shl, LShr, AShr,
1090/// And, Or, Xor, and FNeg.
1091struct NumericIO : public InstructionIO<
1092 Instruction::Add, Instruction::FAdd, Instruction::Sub,
1093 Instruction::FSub, Instruction::Mul, Instruction::FMul,
1094 Instruction::UDiv, Instruction::FDiv, Instruction::SDiv,
1095 Instruction::URem, Instruction::SRem, Instruction::FRem,
1096 Instruction::Shl, Instruction::LShr, Instruction::AShr,
1097 Instruction::And, Instruction::Or, Instruction::Xor,
1098 Instruction::FNeg> {
1100
1112
1115
1116 StringRef getName() const override { return "numeric"; }
1117
1119 ConfigTy *UserConfig = nullptr);
1120
1121 static Value *getLeft(Value &V, Type &Ty, InstrumentationConfig &IConf,
1123 static Value *getRight(Value &V, Type &Ty, InstrumentationConfig &IConf,
1125
1128 auto *PreIO =
1130 PreIO->init(IConf, IIRB);
1131 auto *PostIO =
1133 PostIO->init(IConf, IIRB);
1134 }
1135};
1136
1137} // namespace instrumentor
1138
1139/// The Instrumentor pass.
1140class InstrumentorPass : public RequiredPassInfoMixin<InstrumentorPass> {
1141 using InstrumentationConfig = instrumentor::InstrumentationConfig;
1142 using InstrumentorIRBuilderTy = instrumentor::InstrumentorIRBuilderTy;
1143
1144 /// File system to be used for read operations.
1146
1147 /// The configuration and IR builder provided by the user.
1148 InstrumentationConfig *UserIConf;
1149 InstrumentorIRBuilderTy *UserIIRB;
1150
1151 PreservedAnalyses run(Module &M, InstrumentationConfig &IConf,
1152 InstrumentorIRBuilderTy &IIRB, bool ReadConfig);
1153
1154public:
1155 /// Construct an instrumentor pass that will use the instrumentation
1156 /// configuration \p IC and the IR builder \p IIRB. If an IR builder is not
1157 /// provided, a default builder is used. When the configuration is not
1158 /// provided, it is read from the config file if available and otherwise a
1159 /// default configuration is used.
1161 InstrumentationConfig *IC = nullptr,
1162 InstrumentorIRBuilderTy *IIRB = nullptr);
1163
1165};
1166
1167} // end namespace llvm
1168
1169#endif // LLVM_TRANSFORMS_IPO_INSTRUMENTOR_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
This file defines an array type that can be indexed using scoped enum values.
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
This file defines the RefCountedBase, ThreadSafeRefCountedBase, and IntrusiveRefCntPtr classes.
This file implements a map that provides insertion order iteration.
ModuleAnalysisManager MAM
Basic Register Allocator
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
This class represents a function call, abstracting a target machine's calling convention.
static LLVM_ABI Constant * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Class to represent function types.
const char * getOpcodeName() const
InstrumentorPass(IntrusiveRefCntPtr< vfs::FileSystem > FS=nullptr, InstrumentationConfig *IC=nullptr, InstrumentorIRBuilderTy *IIRB=nullptr)
Construct an instrumentor pass that will use the instrumentation configuration IC and the IR builder ...
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
Definition Allocator.h:390
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition StringSaver.h:22
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:313
LLVM Value Representation.
Definition Value.h:75
Changed
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::function< Value *( Value &, Value &, InstrumentationConfig &, InstrumentorIRBuilderTy &)> SetterCallbackTy
LLVM_ABI bool evaluateFilter(Value &V, bool &Changed, InstrumentationOpportunity &IO, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
Evaluate the filter expression against the current instrumentation opportunity.
std::function< Value *( Value &, Type &, InstrumentationConfig &, InstrumentorIRBuilderTy &)> GetterCallbackTy
Callback type for getting/setting a value for a instrumented opportunity.
This is an optimization pass for GlobalISel generic memory operations.
Op::Description Desc
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1916
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
@ Enable
Enable colors.
Definition WithColor.h:47
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:874
A CRTP mix-in for passes that should not be skipped.
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
}
AllocaIO(InstrumentationLocation::KindTy Kind)
BaseConfigTy< ConfigKind > ConfigTy
static Value * getSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * setSize(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
Boolean option bitset with a compile-time number of bits to store as many options as the enumeration ...
An option for the base configuration.
void setBool(bool B)
Set and get of the boolean value.
static std::unique_ptr< BaseConfigurationOption > createStringOption(InstrumentationConfig &IC, StringRef Name, StringRef Description, StringRef DefaultValue)
Create a string option with Name name, Description description and DefaultValue as string default val...
BaseConfigurationOption(StringRef Name, StringRef Desc, KindTy Kind)
}
KindTy
The possible types of options.
static std::unique_ptr< BaseConfigurationOption > createBoolOption(InstrumentationConfig &IC, StringRef Name, StringRef Description, bool DefaultValue)
Create a boolean option with Name name, Description description and DefaultValue as boolean default v...
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getPointerKind(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * setValueNoop(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
This is necessary to produce a return value that can be used by other IOs.
StringRef getName() const override
Get the name of the instrumentation opportunity.
BaseConfigTy< ConfigKind > ConfigTy
void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
CastIO {.
static Value * getResultTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getInputSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getResultSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getInput(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
BaseConfigTy< ConfigKind > ConfigTy
CastIO(InstrumentationLocation::KindTy Kind)
static Value * getInputTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
StringRef getName() const override
Get the name of the instruction.
std::function< bool(Argument &)> ArgFilter
llvm::instrumentor::FunctionIO::ConfigTy Config
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
StringRef getName() const override
Get the name of the instrumentation opportunity.
Value * setArguments(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getFunctionAddress(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * isMainFunction(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
FunctionIO(InstrumentationLocation::KindTy Kind)
Value * getArguments(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
Value * getNumArguments(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getFunctionName(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
FunctionIO {.
static Value * setAddress(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
static Value * getAS(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getInitialValue(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * isDefinition(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getDeclaredSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
StringRef getName() const override
Get the name of the instrumentation opportunity.
static Value * getSymbolName(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getAddress(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
GlobalVarIO(InstrumentationLocation::KindTy Kind)
BaseConfigTy< ConfigKind > ConfigTy
static Value * isConstant(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
GetterCallbackTy GetterCB
The callback for getting the value of the argument.
StringRef Description
A string with the description of the argument.
unsigned Flags
The flags that describe the properties of the argument.
Type * Ty
The type of the argument.
IRTArg(Type *Ty, StringRef Name, StringRef Description, unsigned Flags, GetterCallbackTy GetterCB, SetterCallbackTy SetterCB=nullptr, bool Enabled=true, bool NoCache=false)
Construct an argument.
bool Enabled
Whether the argument is enabled and should be passed to the function call.
SetterCallbackTy SetterCB
The callback for consuming the output value of the argument.
StringRef Name
A string with the name of the argument.
bool NoCache
Whether the argument value can be cached between the PRE and POST calls.
IRArgFlagTy
Flags describing the possible properties of an argument.
Helper to represent an instrumentation runtime function that is related to an instrumentation opportu...
bool isReplacable(IRTArg &IRTA) const
Return whether the IRTA argument can be replaced.
IRTCallDescription(InstrumentationOpportunity &IO, Type *RetTy=nullptr)
Construct an instrumentation function description linked to the IO instrumentation opportunity and Re...
bool MightRequireIndirection
Whether any argument may require indirection.
std::pair< std::string, std::string > createCBodies() const
Create a string representation of the function definition in C.
CallInst * createLLVMCall(Value *&V, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, const DataLayout &DL, InstrumentationCaches &ICaches)
Create a call instruction that calls to the instrumentation function and passes the corresponding arg...
Type * RetTy
The return type of the instrumentation function.
InstrumentationOpportunity & IO
The instrumentation opportunity which it is linked to.
FunctionType * createLLVMSignature(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, const DataLayout &DL, bool ForceIndirection)
Create the type of the instrumentation function.
std::pair< std::string, std::string > createCSignature(const InstrumentationConfig &IConf) const
Create a string representation of the function declaration in C.
unsigned NumReplaceableArgs
The number of arguments that can be replaced.
bool RequiresIndirection
Whether the function requires indirection in some argument.
bool isPotentiallyIndirect(IRTArg &IRTA) const
Return whether the function may have any indirect argument.
ArrayRef< unsigned > getAllOpcodes() const override
Get all opcodes for this instrumentation opportunity (override).
InstructionIO(InstrumentationLocation::KindTy Kind)
Construct an instruction opportunity.
static constexpr std::array< unsigned, sizeof...(Opcodes)> OpcodesArray
static constexpr size_t getNumOpcodes()
Get the number of opcodes.
virtual StringRef getName() const override
Get the name of the instruction.
Helper that represent the caches for instrumentation call arguments.
The class that contains the configuration for the instrumentor.
virtual void populate(InstrumentorIRBuilderTy &IIRB)
Populate the instrumentation opportunities.
void addChoice(InstrumentationOpportunity &IO, LLVMContext &Ctx)
Register instrumentation opportunity IO.
Constant * getGlobalString(StringRef S, InstrumentorIRBuilderTy &IIRB)
DenseMap< Value *, Value * > UnderlyingObjsMap
Map to remember underlying objects for pointers.
std::unique_ptr< BaseConfigurationOption > HostEnabled
std::unique_ptr< BaseConfigurationOption > DemangleFunctionNames
void init(InstrumentorIRBuilderTy &IIRB)
Initialize the config to a clean base state without loosing cached values that can be reused across c...
DenseMap< std::pair< Value *, Function * >, Value * > BasePointerInfoMap
Map to remember base pointer info for values in a specific function.
EnumeratedArray< MapVector< StringRef, InstrumentationOpportunity * >, InstrumentationLocation::KindTy > IChoices
The map registered instrumentation opportunities.
std::unique_ptr< BaseConfigurationOption > GPUEnabled
DenseMap< Constant *, GlobalVariable * > ConstantGlobalsCache
Mapping from constants to globals with the constant as initializer.
Value * getBasePointerInfo(Value &V, InstrumentorIRBuilderTy &IIRB)
Return the base pointer info for V.
BumpPtrAllocator StringAllocator
Utilities for allocating and building strings.
std::string getRTName(StringRef Prefix, StringRef Name, StringRef Suffix1="", StringRef Suffix2="") const
Get the instrumentation function name.
std::unique_ptr< BaseConfigurationOption > RuntimeStubsFile
StringRef getRTName() const
Get the runtime prefix for the instrumentation runtime functions.
void addBaseChoice(BaseConfigurationOption *BCO)
Add the base configuration option BCO into the list of base options.
static Ty * allocate(ArgsTy &&...Args)
Allocate an object of type Ty using a bump allocator and construct it with the Args arguments.
SmallVector< BaseConfigurationOption * > BaseConfigurationOptions
The list of enabled base configuration options.
InstrumentationConfig()
Construct an instrumentation configuration with the base options.
std::unique_ptr< BaseConfigurationOption > FunctionRegex
std::unique_ptr< BaseConfigurationOption > TargetRegex
std::unique_ptr< BaseConfigurationOption > RuntimePrefix
The base configuration options.
DenseMap< StringRef, Constant * > GlobalStringsMap
Mapping to remember global strings passed to the runtime.
Helper to represent an instrumentation location, which is composed of an instrumentation opportunity ...
KindTy getKind() const
Return the type and position.
InstrumentationLocation(KindTy Kind)
Construct an instrumentation location with the given kind.
static KindTy getKindFromStr(StringRef S)
Return the location kind described by a string.
static StringRef getKindStr(KindTy Kind)
Return the string representation given a location kind.
KindTy
The supported location kinds, which are composed of a opportunity type and position.
static bool isPRE(KindTy Kind)
Return whether a location kind is positioned before the event occurs.
bool isPRE() const
Return whether the instrumentation location is before the event occurs.
Base class for instrumentation opportunities.
InstrumentationLocation::KindTy getLocationKind() const
Get the location kind of the instrumentation opportunity.
bool Enabled
Whether the opportunity is enabled.
static Value * getIdPre(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
Get the opportunity identifier for the pre and post positions.
virtual ArrayRef< unsigned > getAllOpcodes() const
Get all opcodes for this instrumentation opportunity.
virtual Value * instrument(Value *&V, bool &Changed, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, InstrumentationCaches &ICaches)
}
static Value * forceCast(Value &V, Type &Ty, InstrumentorIRBuilderTy &IIRB)
Helpers to cast values, pass them to the runtime, and replace them.
static int32_t getIdFromEpoch(uint32_t CurrentEpoch)
}
std::function< bool(Value &)> CallbackTy
An optional callback that takes the value that is about to be instrumented and can return false if it...
static Value * getIdPost(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getValue(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * replaceValue(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
virtual StringRef getName() const =0
Get the name of the instrumentation opportunity.
InstrumentationLocation IP
The instrumentation location of the opportunity.
InstrumentationOpportunity(const InstrumentationLocation IP)
Construct an opportunity with location IP.
SmallVector< IRTArg > IRTArgs
The list of possible arguments for the instrumentation runtime function.
void addCommonArgs(InstrumentationConfig &IConf, LLVMContext &Ctx, bool PassId)
}
virtual Type * getRetTy(LLVMContext &Ctx) const
Get the return type for the instrumentation runtime function.
StringRef Filter
A filter expression to be matched against runtime property values.
An IR builder augmented with extra information for the instrumentor pass.
IRBuilder< ConstantFolder, IRBuilderCallbackInserter > IRB
The underlying IR builder with insertion callback.
static Value * getValueSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getSyncScopeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getAtomicityOrdering(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
virtual Type * getValueType(InstrumentorIRBuilderTy &IIRB) const
}
static Value * getValue(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
ConfigKind
The selector of arguments for load opportunities.
LoadIO(InstrumentationLocation::KindTy Kind)
Construct a load opportunity.
static Value * getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getPointer(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
Getters and setters for the arguments of the instrumentation function for the load opportunity.
static Value * isVolatile(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getBasePointerInfo(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * setPointer(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
BaseConfigTy< ConfigKind > ConfigTy
static Value * getPointerAS(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
}
static Value * getValueTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
Initialize the load opportunity using the instrumentation config IConf and the user config UserConfig...
static Value * getModuleName(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
ModuleIO(InstrumentationLocation::KindTy Kind)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getTargetTriple(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
BaseConfigTy< ConfigKind > ConfigTy
StringRef getName() const override
Get the name of the instrumentation opportunity.
StringRef getName() const override
Get the name of the instruction.
NumericIO(InstrumentationLocation::KindTy Kind)
static Value * getLeft(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
}
static Value * getRight(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
BaseConfigTy< ConfigKind > ConfigTy
static Value * getPointer(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
Getters and setters for the arguments of the instrumentation function for the store opportunity.
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
}
static Value * getValueTypeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
virtual Type * getValueType(InstrumentorIRBuilderTy &IIRB) const
}
static Value * getSyncScopeId(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getPointerAS(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
ConfigKind
The selector of arguments for store opportunities.
static Value * getAlignment(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getValue(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * setPointer(Value &V, Value &NewV, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
StoreIO(InstrumentationLocation::KindTy Kind)
Construct a store instruction opportunity.
static Value * isVolatile(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getValueSize(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
BaseConfigTy< ConfigKind > ConfigTy
void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
Initialize the store opportunity using the instrumentation config IConf and the user config UserConfi...
static Value * getBasePointerInfo(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static Value * getAtomicityOrdering(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
static void populate(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
void init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB, ConfigTy *UserConfig=nullptr)
UnreachableIO {.
BaseConfigTy< ConfigKind > ConfigTy
Helper union that holds any possible option type.