diff options
author | Zoltan Varga <vargaz@gmail.com> | 2016-02-20 02:38:02 +0300 |
---|---|---|
committer | Imran Hameed <imhameed@microsoft.com> | 2021-04-15 18:27:26 +0300 |
commit | f36eaa9f60ddca1b7562d6b29b3b6c5ec1e1fb02 (patch) | |
tree | f9ab891036252dbfb75575859e627653adfb9439 /llvm | |
parent | 973cb6cd1cedd6c5f079972999e2a9319aed9674 (diff) |
Add a 'mono.this' custom metadata, this is used to mark an 'alloca' whose associated stack slot index will be saved in MachineFunction, and later can be saved in the mono specific EH tables.
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/CodeGen/MachineFunction.h | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp | 11 |
3 files changed, 19 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index 809c21dd26fc..4664d86e3f3e 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -371,6 +371,9 @@ class MachineFunction { /// \pre Fn, Target, MMI, and FunctionNumber are properly set. void init(); + // Stack slot containing the this pointer for mono compiled functions + int MonoThisSlot; + public: struct VariableDbgInfo { const DILocalVariable *Var; @@ -476,6 +479,9 @@ public: PseudoSourceValueManager &getPSVManager() const { return *PSVManager; } + int getMonoThisSlot() const { return MonoThisSlot; } + void setMonoThisSlot(int Slot) { MonoThisSlot = Slot; } + /// Return the DataLayout attached to the Module associated to this MF. const DataLayout &getDataLayout() const; diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 6d45f08804ed..e8248263b278 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -205,6 +205,8 @@ void MachineFunction::init() { PSVManager = std::make_unique<PseudoSourceValueManager>(*(getSubtarget(). getInstrInfo())); + + MonoThisSlot = -1; } MachineFunction::~MachineFunction() { diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index 5cf83cff3a90..f1d6de2de18c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -184,6 +184,17 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf, for (int *CatchObjPtr : Iter->second) *CatchObjPtr = FrameIndex; } + + // + // The mono exception handling code needs to location of the 'this' pointer + // to handle stack traces containing generic shared methods. + // To implement this, it saves the this pointer to an alloca which is marked with + // the 'mono.this' custom metadata. We save the stack slot used by this alloca + // in MachineFunction, so the dwarf exception info emission code can use it to + // compute the reg+offset for it, and save it into the LSDA. + // + if (AI->getMetadata("mono.this")) + MF->setMonoThisSlot(StaticAllocaMap[AI]); } else { // FIXME: Overaligned static allocas should be grouped into // a single dynamic allocation instead of using a separate |