LLVM 24.0.0git
DynamicDebugging.h
Go to the documentation of this file.
1//===- DynamicDebugging.h - Dynamic Debugging utils ------------*- C++ -*-===//
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#ifndef LLVM_TRANSFORMS_UTILS_DYNAMIC_DEBUGGING_H
10#define LLVM_TRANSFORMS_UTILS_DYNAMIC_DEBUGGING_H
11
12#include "llvm/ADT/StringRef.h"
13#include <memory>
14
15namespace llvm {
16class Module;
17
18/// Modify \p M to prepare it for dynamic debugging before running
19/// optimizations. Return a clone of the module which references global
20/// values in \p M. The names of the cloned function definitions in this
21/// module are prefixed with “__dyndbg.”.
22///
23/// \p M requires debug info. Note any instrumentation in \p M will be
24/// cloned into the returned module.
25///
26/// Aliases with external linkage are created for GlobalValues in \p M that
27/// have local (non-weak) linkage and are not in a COMDAT. These names of these
28/// aliases are appended with \p PromotionSuffix which should be unique to the
29/// translation unit. If it's not unique then linking may result in multiple
30/// definition errors.
31///
32/// Input pseudo-code:
33/// +----------------------------------------------+
34/// | internal global g |
35/// | internal function loc() { return g } |
36/// | exported function ext() { return loc() } |
37/// +----------------------------------------------+
38///
39/// M becomes:
40/// +----------------------------------------------+
41/// | internal global g |
42/// | internal function loc() { return g } |
43/// | exported function ext() { return loc() } |<---+
44/// | exported loc.promo = alias of loc |<--+|
45/// | exported g.promo = alias of g |<-+||
46/// +----------------------------------------------+ |||
47/// |||
48/// Returned Module: |||
49/// +----------------------------------------------+ |||
50/// | external global g.promo |--+||
51/// | external function loc.promo() |---+|
52/// | external function ext() |----+
53/// | exported function __dyndbg.loc.promo() { |
54/// | return g.promo |
55/// | } |
56/// | exported function __dyndbg.ext() { |
57/// | return loc.promo() |
58/// | } |
59/// +----------------------------------------------+
60LLVM_ABI std::unique_ptr<Module>
62} // namespace llvm
63
64#endif
#define LLVM_ABI
Definition Compiler.h:215
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::unique_ptr< Module > prepareForDynamicDebugging(Module *M, StringRef PromotionSuffix)
Modify M to prepare it for dynamic debugging before running optimizations.