Eugene Zelenko | 5df3d89 | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 1 | //===- LiveDebugVariables.h - Tracking debug info variables -----*- C++ -*-===// |
Jakob Stoklund Olesen | d4900a6 | 2010-11-30 02:17:10 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame^] | 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 |
Jakob Stoklund Olesen | d4900a6 | 2010-11-30 02:17:10 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file provides the interface to the LiveDebugVariables analysis. |
| 10 | // |
| 11 | // The analysis removes DBG_VALUE instructions for virtual registers and tracks |
| 12 | // live user variables in a data structure that can be updated during register |
| 13 | // allocation. |
| 14 | // |
| 15 | // After register allocation new DBG_VALUE instructions are emitted to reflect |
| 16 | // the new locations of user variables. |
| 17 | // |
| 18 | //===----------------------------------------------------------------------===// |
| 19 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 20 | #ifndef LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H |
| 21 | #define LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H |
Jakob Stoklund Olesen | d4900a6 | 2010-11-30 02:17:10 +0000 | [diff] [blame] | 22 | |
| 23 | #include "llvm/CodeGen/MachineFunctionPass.h" |
Eugene Zelenko | 5df3d89 | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 24 | #include "llvm/Support/Compiler.h" |
Jakob Stoklund Olesen | d4900a6 | 2010-11-30 02:17:10 +0000 | [diff] [blame] | 25 | |
| 26 | namespace llvm { |
| 27 | |
Mehdi Amini | b550cb1 | 2016-04-18 09:17:29 +0000 | [diff] [blame] | 28 | template <typename T> class ArrayRef; |
Mark Lacey | f9ea885 | 2013-08-14 23:50:04 +0000 | [diff] [blame] | 29 | class LiveIntervals; |
Jakob Stoklund Olesen | afc2bc2 | 2010-12-03 21:47:10 +0000 | [diff] [blame] | 30 | class VirtRegMap; |
| 31 | |
Benjamin Kramer | f4c2025 | 2015-07-01 14:47:39 +0000 | [diff] [blame] | 32 | class LLVM_LIBRARY_VISIBILITY LiveDebugVariables : public MachineFunctionPass { |
Eugene Zelenko | 5df3d89 | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 33 | void *pImpl = nullptr; |
Duncan P. N. Exon Smith | ed557b5 | 2015-04-17 23:20:10 +0000 | [diff] [blame] | 34 | |
Jakob Stoklund Olesen | d4900a6 | 2010-11-30 02:17:10 +0000 | [diff] [blame] | 35 | public: |
| 36 | static char ID; // Pass identification, replacement for typeid |
| 37 | |
| 38 | LiveDebugVariables(); |
Alexander Kornienko | f817c1c | 2015-04-11 02:11:45 +0000 | [diff] [blame] | 39 | ~LiveDebugVariables() override; |
Jakob Stoklund Olesen | d4900a6 | 2010-11-30 02:17:10 +0000 | [diff] [blame] | 40 | |
Jakob Stoklund Olesen | f8da028 | 2011-05-06 18:00:02 +0000 | [diff] [blame] | 41 | /// splitRegister - Move any user variables in OldReg to the live ranges in |
| 42 | /// NewRegs where they are live. Mark the values as unavailable where no new |
| 43 | /// register is live. |
Mark Lacey | f9ea885 | 2013-08-14 23:50:04 +0000 | [diff] [blame] | 44 | void splitRegister(unsigned OldReg, ArrayRef<unsigned> NewRegs, |
| 45 | LiveIntervals &LIS); |
Jakob Stoklund Olesen | f8da028 | 2011-05-06 18:00:02 +0000 | [diff] [blame] | 46 | |
Jakob Stoklund Olesen | d4900a6 | 2010-11-30 02:17:10 +0000 | [diff] [blame] | 47 | /// emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes |
| 48 | /// that happened during register allocation. |
Jakob Stoklund Olesen | afc2bc2 | 2010-12-03 21:47:10 +0000 | [diff] [blame] | 49 | /// @param VRM Rename virtual registers according to map. |
| 50 | void emitDebugValues(VirtRegMap *VRM); |
Jakob Stoklund Olesen | d4900a6 | 2010-11-30 02:17:10 +0000 | [diff] [blame] | 51 | |
Jakob Stoklund Olesen | 9ec2011 | 2010-12-02 18:15:44 +0000 | [diff] [blame] | 52 | /// dump - Print data structures to dbgs(). |
Sam Clegg | 705f798 | 2017-06-21 22:19:17 +0000 | [diff] [blame] | 53 | void dump() const; |
Jakob Stoklund Olesen | 9ec2011 | 2010-12-02 18:15:44 +0000 | [diff] [blame] | 54 | |
Jakob Stoklund Olesen | d4900a6 | 2010-11-30 02:17:10 +0000 | [diff] [blame] | 55 | private: |
Craig Topper | 4584cd5 | 2014-03-07 09:26:03 +0000 | [diff] [blame] | 56 | bool runOnMachineFunction(MachineFunction &) override; |
| 57 | void releaseMemory() override; |
| 58 | void getAnalysisUsage(AnalysisUsage &) const override; |
David Blaikie | 2f04011 | 2014-07-25 16:10:16 +0000 | [diff] [blame] | 59 | bool doInitialization(Module &) override; |
Jakob Stoklund Olesen | d4900a6 | 2010-11-30 02:17:10 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
Eugene Zelenko | 5df3d89 | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 62 | } // end namespace llvm |
Jakob Stoklund Olesen | d4900a6 | 2010-11-30 02:17:10 +0000 | [diff] [blame] | 63 | |
Eugene Zelenko | 5df3d89 | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 64 | #endif // LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H |