From 220c17ffd4e1b127bcc02b25980b7934184ee1da Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 21 May 2020 17:42:24 -0700 Subject: [PATCH 1/3] Print a warning when stopped in a frame LLDB has no plugin for. This patchs adds an optional warning that is printed when stopped at a frame that was compiled in a source language that LLDB has no plugin for. The motivational use-case is debugging Swift code on Linux. When the user accidentally invokes the system LLDB that was built without the Swift plugin, it is very much non-obvious why debugging doesnt work. This warning makes it easy to figure out what went wrong. --- lldb/include/lldb/Target/Process.h | 9 ++++- lldb/source/Target/Process.cpp | 35 ++++++++++++++++--- lldb/source/Target/TargetProperties.td | 3 ++ lldb/source/Target/Thread.cpp | 5 ++- lldb/test/Shell/Process/Inputs/true.c | 3 ++ lldb/test/Shell/Process/Optimization.test | 6 ++++ .../Shell/Process/UnsupportedLanguage.test | 8 +++++ 7 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 lldb/test/Shell/Process/Inputs/true.c create mode 100644 lldb/test/Shell/Process/Optimization.test create mode 100644 lldb/test/Shell/Process/UnsupportedLanguage.test diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index fe811deb7caa2b..6f31741b4ce6de 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -86,6 +86,7 @@ class ProcessProperties : public Properties { bool GetDetachKeepsStopped() const; void SetDetachKeepsStopped(bool keep_stopped); bool GetWarningsOptimization() const; + bool GetWarningsUnsupportedLanguage() const; bool GetStopOnExec() const; std::chrono::seconds GetUtilityExpressionTimeout() const; bool GetOSPluginReportsAllThreads() const; @@ -390,7 +391,7 @@ class Process : public std::enable_shared_from_this, }; /// Process warning types. - enum Warnings { eWarningsOptimization = 1 }; + enum Warnings { eWarningsOptimization = 1, eWarningsUnsupportedLanguage = 2 }; typedef Range LoadRange; // We use a read/write lock to allow on or more clients to access the process @@ -1319,6 +1320,12 @@ class Process : public std::enable_shared_from_this, /// pre-computed. void PrintWarningOptimization(const SymbolContext &sc); + /// Print a user-visible warning about a function written in a + /// language that this version of LLDB doesn't support. + /// + /// \see PrintWarningOptimization + void PrintWarningUnsupportedLanguage(const SymbolContext &sc); + virtual bool GetProcessInfo(ProcessInstanceInfo &info); public: diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 0eb9866e4a4b59..25a940b6643065 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -258,6 +258,12 @@ bool ProcessProperties::GetWarningsOptimization() const { nullptr, idx, g_process_properties[idx].default_uint_value != 0); } +bool ProcessProperties::GetWarningsUnsupportedLanguage() const { + const uint32_t idx = ePropertyWarningUnsupportedLanguage; + return m_collection_sp->GetPropertyAtIndexAsBoolean( + nullptr, idx, g_process_properties[idx].default_uint_value != 0); +} + bool ProcessProperties::GetStopOnExec() const { const uint32_t idx = ePropertyStopOnExec; return m_collection_sp->GetPropertyAtIndexAsBoolean( @@ -5779,9 +5785,6 @@ void Process::PrintWarning(uint64_t warning_type, const void *repeat_key, StreamSP stream_sp = GetTarget().GetDebugger().GetAsyncOutputStream(); if (!stream_sp) return; - if (warning_type == eWarningsOptimization && !GetWarningsOptimization()) { - return; - } if (repeat_key != nullptr) { WarningsCollection::iterator it = m_warnings_issued.find(warning_type); @@ -5806,8 +5809,11 @@ void Process::PrintWarning(uint64_t warning_type, const void *repeat_key, } void Process::PrintWarningOptimization(const SymbolContext &sc) { - if (GetWarningsOptimization() && sc.module_sp && - !sc.module_sp->GetFileSpec().GetFilename().IsEmpty() && sc.function && + if (!GetWarningsOptimization()) + return; + if (!sc.module_sp) + return; + if (!sc.module_sp->GetFileSpec().GetFilename().IsEmpty() && sc.function && sc.function->GetIsOptimized()) { PrintWarning(Process::Warnings::eWarningsOptimization, sc.module_sp.get(), "%s was compiled with optimization - stepping may behave " @@ -5816,6 +5822,25 @@ void Process::PrintWarningOptimization(const SymbolContext &sc) { } } +void Process::PrintWarningUnsupportedLanguage(const SymbolContext &sc) { + if (!GetWarningsUnsupportedLanguage()) + return; + if (!sc.module_sp) + return; + LanguageType language = sc.GetLanguage(); + if (language == eLanguageTypeUnknown) + return; + auto type_system_or_err = sc.module_sp->GetTypeSystemForLanguage(language); + if (auto err = type_system_or_err.takeError()) { + llvm::consumeError(std::move(err)); + PrintWarning(Process::Warnings::eWarningsUnsupportedLanguage, + sc.module_sp.get(), + "This version of LLDB has no plugin for the %s language. " + "Inspection of frame variables will be limited.\n", + Language::GetNameForLanguageType(language)); + } +} + bool Process::GetProcessInfo(ProcessInstanceInfo &info) { info.Clear(); diff --git a/lldb/source/Target/TargetProperties.td b/lldb/source/Target/TargetProperties.td index 8f3a6b04bb69ef..ae3abe3548566e 100644 --- a/lldb/source/Target/TargetProperties.td +++ b/lldb/source/Target/TargetProperties.td @@ -204,6 +204,9 @@ let Definition = "process" in { def WarningOptimization: Property<"optimization-warnings", "Boolean">, DefaultTrue, Desc<"If true, warn when stopped in code that is optimized where stepping and variable availability may not behave as expected.">; + def WarningUnsupportedLanguage: Property<"unsupported-language-warnings", "Boolean">, + DefaultTrue, + Desc<"If true, warn when stopped in code that is written in a source language that LLDB does not support.">; def StopOnExec: Property<"stop-on-exec", "Boolean">, Global, DefaultTrue, diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index e24024c37a47c7..35cde4015986c6 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -326,10 +326,13 @@ void Thread::FrameSelectedCallback(StackFrame *frame) { if (!frame) return; - if (frame->HasDebugInformation() && GetProcess()->GetWarningsOptimization()) { + if (frame->HasDebugInformation() && + (GetProcess()->GetWarningsOptimization() || + GetProcess()->GetWarningsUnsupportedLanguage())) { SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextModule); GetProcess()->PrintWarningOptimization(sc); + GetProcess()->PrintWarningUnsupportedLanguage(sc); } } diff --git a/lldb/test/Shell/Process/Inputs/true.c b/lldb/test/Shell/Process/Inputs/true.c new file mode 100644 index 00000000000000..5c2fa9bb6a78e2 --- /dev/null +++ b/lldb/test/Shell/Process/Inputs/true.c @@ -0,0 +1,3 @@ +int main(int argc, char **argv) { + return 0; +} diff --git a/lldb/test/Shell/Process/Optimization.test b/lldb/test/Shell/Process/Optimization.test new file mode 100644 index 00000000000000..10d241f698c0d0 --- /dev/null +++ b/lldb/test/Shell/Process/Optimization.test @@ -0,0 +1,6 @@ +Test warnings. +REQUIRES: shell +RUN: %clang_host -O3 %S/Inputs/true.c -std=c99 -g -o %t.exe +RUN: %lldb -o "b main" -o r -o q -b %t.exe | FileCheck %s + +CHECK: compiled with optimization diff --git a/lldb/test/Shell/Process/UnsupportedLanguage.test b/lldb/test/Shell/Process/UnsupportedLanguage.test new file mode 100644 index 00000000000000..28726abd6a1e05 --- /dev/null +++ b/lldb/test/Shell/Process/UnsupportedLanguage.test @@ -0,0 +1,8 @@ +Test warnings. +REQUIRES: shell +RUN: %clang_host %S/Inputs/true.c -std=c99 -g -c -S -emit-llvm -o - \ +RUN: | sed -e 's/DW_LANG_C99/DW_LANG_PLI/g' >%t.ll +RUN: %clang_host %t.ll -g -o %t.exe +RUN: %lldb -o "b main" -o r -o q -b %t.exe | FileCheck %s + +CHECK: This version of LLDB has no plugin for the pli language From 7e49dc6184ef3baf421a5bb0190466cbb1a87785 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 22 May 2020 15:18:05 -0700 Subject: [PATCH 2/3] [MC] Change MCCFIInstruction::createDefCfa to cfiDefCfa which does not negate Offset The negative Offset has caused a bunch of problems and confused quite a few call sites. Delete the unneeded negation and fix all call sites. --- llvm/include/llvm/MC/MCDwarf.h | 6 +++--- llvm/lib/CodeGen/CFIInstrInserter.cpp | 6 +++--- llvm/lib/CodeGen/MIRParser/MIParser.cpp | 3 +-- llvm/lib/MC/MCStreamer.cpp | 2 +- llvm/lib/Target/AArch64/AArch64FrameLowering.cpp | 4 ++-- .../Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp | 2 +- llvm/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp | 2 +- llvm/lib/Target/ARM/ARMFrameLowering.cpp | 4 ++-- llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp | 2 +- llvm/lib/Target/ARM/Thumb1FrameLowering.cpp | 4 ++-- llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp | 4 ++-- .../Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp | 5 ++--- llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp | 2 +- llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp | 2 +- llvm/lib/Target/RISCV/RISCVFrameLowering.cpp | 6 +++--- llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp | 4 ++-- .../Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp | 7 +++---- llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp | 2 +- llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp | 4 ++-- llvm/lib/Target/X86/X86FrameLowering.cpp | 4 ++-- llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp | 2 +- 21 files changed, 37 insertions(+), 40 deletions(-) diff --git a/llvm/include/llvm/MC/MCDwarf.h b/llvm/include/llvm/MC/MCDwarf.h index 2950a7b0b13a93..9d72e6b651e7c1 100644 --- a/llvm/include/llvm/MC/MCDwarf.h +++ b/llvm/include/llvm/MC/MCDwarf.h @@ -482,9 +482,9 @@ class MCCFIInstruction { public: /// .cfi_def_cfa defines a rule for computing CFA as: take address from /// Register and add Offset to it. - static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, - int Offset) { - return MCCFIInstruction(OpDefCfa, L, Register, -Offset, ""); + static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, + int Offset) { + return MCCFIInstruction(OpDefCfa, L, Register, Offset, ""); } /// .cfi_def_cfa_register modifies a rule for computing CFA. From now diff --git a/llvm/lib/CodeGen/CFIInstrInserter.cpp b/llvm/lib/CodeGen/CFIInstrInserter.cpp index 0269936d2f88c1..978cf4fa5ed43e 100644 --- a/llvm/lib/CodeGen/CFIInstrInserter.cpp +++ b/llvm/lib/CodeGen/CFIInstrInserter.cpp @@ -124,7 +124,7 @@ class CFIInstrInserter : public MachineFunctionPass { /// if needed. The negated value is needed when creating CFI instructions that /// set absolute offset. int getCorrectCFAOffset(MachineBasicBlock *MBB) { - return -MBBVector[MBB->getNumber()].IncomingCFAOffset; + return MBBVector[MBB->getNumber()].IncomingCFAOffset; } void reportCFAError(const MBBCFAInfo &Pred, const MBBCFAInfo &Succ); @@ -314,7 +314,7 @@ bool CFIInstrInserter::insertCFIInstrs(MachineFunction &MF) { // incoming offset and register of this block, add a def_cfa instruction // with the correct offset and register for this block. if (PrevMBBInfo->OutgoingCFARegister != MBBInfo.IncomingCFARegister) { - unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createDefCfa( + unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::cfiDefCfa( nullptr, MBBInfo.IncomingCFARegister, getCorrectCFAOffset(&MBB))); BuildMI(*MBBInfo.MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION)) .addCFIIndex(CFIIndex); @@ -324,7 +324,7 @@ bool CFIInstrInserter::insertCFIInstrs(MachineFunction &MF) { } else { unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createDefCfaOffset( - nullptr, getCorrectCFAOffset(&MBB))); + nullptr, -getCorrectCFAOffset(&MBB))); BuildMI(*MBBInfo.MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION)) .addCFIIndex(CFIIndex); } diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 0107e5e895a2b8..ce5d5c96412bcc 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -2256,9 +2256,8 @@ bool MIParser::parseCFIOperand(MachineOperand &Dest) { if (parseCFIRegister(Reg) || expectAndConsume(MIToken::comma) || parseCFIOffset(Offset)) return true; - // NB: MCCFIInstruction::createDefCfa negates the offset. CFIIndex = - MF.addFrameInst(MCCFIInstruction::createDefCfa(nullptr, Reg, -Offset)); + MF.addFrameInst(MCCFIInstruction::cfiDefCfa(nullptr, Reg, Offset)); break; case MIToken::kw_cfi_remember_state: CFIIndex = MF.addFrameInst(MCCFIInstruction::createRememberState(nullptr)); diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index 95dad6e28fc1cf..95b1dd5610c7cc 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -461,7 +461,7 @@ MCSymbol *MCStreamer::emitCFILabel() { void MCStreamer::emitCFIDefCfa(int64_t Register, int64_t Offset) { MCSymbol *Label = emitCFILabel(); MCCFIInstruction Instruction = - MCCFIInstruction::createDefCfa(Label, Register, Offset); + MCCFIInstruction::cfiDefCfa(Label, Register, -Offset); MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); if (!CurFrame) return; diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp index c29ae29e5c5ed9..e713f1bb97413c 100644 --- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp @@ -1349,8 +1349,8 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF, if (HasFP) { // Define the current CFA rule to use the provided FP. unsigned Reg = RegInfo->getDwarfRegNum(FramePtr, true); - unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createDefCfa( - nullptr, Reg, StackGrowth - FixedObject)); + unsigned CFIIndex = MF.addFrameInst( + MCCFIInstruction::cfiDefCfa(nullptr, Reg, FixedObject - StackGrowth)); BuildMI(MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION)) .addCFIIndex(CFIIndex) .setMIFlags(MachineInstr::FrameSetup); diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp index 7dc3665baabc58..209bff3a231175 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp @@ -254,7 +254,7 @@ static MCAsmInfo *createAArch64MCAsmInfo(const MCRegisterInfo &MRI, // Initial state of the frame pointer is SP. unsigned Reg = MRI.getDwarfRegNum(AArch64::SP, true); - MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 0); + MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, Reg, 0); MAI->addInitialFrameState(Inst); return MAI; diff --git a/llvm/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp b/llvm/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp index 997e95e1a35f85..3e3613ccb90fa9 100644 --- a/llvm/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp +++ b/llvm/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp @@ -57,7 +57,7 @@ static MCAsmInfo *createARCMCAsmInfo(const MCRegisterInfo &MRI, MCAsmInfo *MAI = new ARCMCAsmInfo(TT); // Initial state of the frame pointer is SP. - MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, ARC::SP, 0); + MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, ARC::SP, 0); MAI->addInitialFrameState(Inst); return MAI; diff --git a/llvm/lib/Target/ARM/ARMFrameLowering.cpp b/llvm/lib/Target/ARM/ARMFrameLowering.cpp index 00b310abb5473e..2237ce459de5d7 100644 --- a/llvm/lib/Target/ARM/ARMFrameLowering.cpp +++ b/llvm/lib/Target/ARM/ARMFrameLowering.cpp @@ -593,9 +593,9 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF, PushSize + FramePtrOffsetInPush, MachineInstr::FrameSetup); if (FramePtrOffsetInPush + PushSize != 0) { - unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createDefCfa( + unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::cfiDefCfa( nullptr, MRI->getDwarfRegNum(FramePtr, true), - -(FPCXTSaveSize + ArgRegsSaveSize - FramePtrOffsetInPush))); + FPCXTSaveSize + ArgRegsSaveSize - FramePtrOffsetInPush)); BuildMI(MBB, AfterPush, dl, TII.get(TargetOpcode::CFI_INSTRUCTION)) .addCFIIndex(CFIIndex) .setMIFlags(MachineInstr::FrameSetup); diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp index e84d53346d80b6..6ce5a19a5e7086 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp @@ -200,7 +200,7 @@ static MCAsmInfo *createARMMCAsmInfo(const MCRegisterInfo &MRI, MAI = new ARMELFMCAsmInfo(TheTriple); unsigned Reg = MRI.getDwarfRegNum(ARM::SP, true); - MAI->addInitialFrameState(MCCFIInstruction::createDefCfa(nullptr, Reg, 0)); + MAI->addInitialFrameState(MCCFIInstruction::cfiDefCfa(nullptr, Reg, 0)); return MAI; } diff --git a/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp b/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp index 8222ebce7d070b..02f1392e0fdd1a 100644 --- a/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp +++ b/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp @@ -308,8 +308,8 @@ void Thumb1FrameLowering::emitPrologue(MachineFunction &MF, .add(predOps(ARMCC::AL)); if(FramePtrOffsetInBlock) { CFAOffset += FramePtrOffsetInBlock; - unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createDefCfa( - nullptr, MRI->getDwarfRegNum(FramePtr, true), CFAOffset)); + unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::cfiDefCfa( + nullptr, MRI->getDwarfRegNum(FramePtr, true), -CFAOffset)); BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION)) .addCFIIndex(CFIIndex) .setMIFlags(MachineInstr::FrameSetup); diff --git a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp index 1a3a0af7dc5e61..010b7171ce1724 100644 --- a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp +++ b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp @@ -1056,9 +1056,9 @@ void HexagonFrameLowering::insertCFIInstructionsAt(MachineBasicBlock &MBB, // | +-- Old SP (before allocframe) // +-- New FP (after allocframe) // - // MCCFIInstruction::createDefCfa subtracts the offset from the register. + // MCCFIInstruction::cfiDefCfa adds the offset from the register. // MCCFIInstruction::createOffset takes the offset without sign change. - auto DefCfa = MCCFIInstruction::createDefCfa(FrameLabel, DwFPReg, -8); + auto DefCfa = MCCFIInstruction::cfiDefCfa(FrameLabel, DwFPReg, 8); BuildMI(MBB, At, DL, CFID) .addCFIIndex(MF.addFrameInst(DefCfa)); // R31 (return addr) = CFA - 4 diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp index 31f45001856933..7514d0e6774492 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp @@ -290,9 +290,8 @@ static MCAsmInfo *createHexagonMCAsmInfo(const MCRegisterInfo &MRI, MCAsmInfo *MAI = new HexagonMCAsmInfo(TT); // VirtualFP = (R30 + #0). - MCCFIInstruction Inst = - MCCFIInstruction::createDefCfa(nullptr, - MRI.getDwarfRegNum(Hexagon::R30, true), 0); + MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa( + nullptr, MRI.getDwarfRegNum(Hexagon::R30, true), 0); MAI->addInitialFrameState(Inst); return MAI; diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp index d8e1dd31b8481b..d492fd848c7ea4 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp @@ -95,7 +95,7 @@ static MCAsmInfo *createPPCMCAsmInfo(const MCRegisterInfo &MRI, // Initial state of the frame pointer is R1. unsigned Reg = isPPC64 ? PPC::X1 : PPC::R1; MCCFIInstruction Inst = - MCCFIInstruction::createDefCfa(nullptr, MRI.getDwarfRegNum(Reg, true), 0); + MCCFIInstruction::cfiDefCfa(nullptr, MRI.getDwarfRegNum(Reg, true), 0); MAI->addInitialFrameState(Inst); return MAI; diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp index 982a8d26aa30d4..a474224e1a4e55 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp @@ -57,7 +57,7 @@ static MCAsmInfo *createRISCVMCAsmInfo(const MCRegisterInfo &MRI, MCAsmInfo *MAI = new RISCVMCAsmInfo(TT); Register SP = MRI.getDwarfRegNum(RISCV::X2, true); - MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, SP, 0); + MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, SP, 0); MAI->addInitialFrameState(Inst); return MAI; diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp index 915889ac12715e..18a29577114fa8 100644 --- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp @@ -329,9 +329,9 @@ void RISCVFrameLowering::emitPrologue(MachineFunction &MF, RealStackSize - RVFI->getVarArgsSaveSize(), MachineInstr::FrameSetup); - // Emit ".cfi_def_cfa $fp, -RVFI->getVarArgsSaveSize()" - unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createDefCfa( - nullptr, RI->getDwarfRegNum(FPReg, true), -RVFI->getVarArgsSaveSize())); + // Emit ".cfi_def_cfa $fp, RVFI->getVarArgsSaveSize()" + unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::cfiDefCfa( + nullptr, RI->getDwarfRegNum(FPReg, true), RVFI->getVarArgsSaveSize())); BuildMI(MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION)) .addCFIIndex(CFIIndex); } diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp index 7eb27f55baacc7..173059f3ed60be 100644 --- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp +++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp @@ -37,7 +37,7 @@ static MCAsmInfo *createSparcMCAsmInfo(const MCRegisterInfo &MRI, const MCTargetOptions &Options) { MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT); unsigned Reg = MRI.getDwarfRegNum(SP::O6, true); - MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 0); + MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, Reg, 0); MAI->addInitialFrameState(Inst); return MAI; } @@ -47,7 +47,7 @@ static MCAsmInfo *createSparcV9MCAsmInfo(const MCRegisterInfo &MRI, const MCTargetOptions &Options) { MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT); unsigned Reg = MRI.getDwarfRegNum(SP::O6, true); - MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 2047); + MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, Reg, -2047); MAI->addInitialFrameState(Inst); return MAI; } diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp index eb2112674a12d1..4e4560c479f6d7 100644 --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp @@ -150,10 +150,9 @@ static MCAsmInfo *createSystemZMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options) { MCAsmInfo *MAI = new SystemZMCAsmInfo(TT); - MCCFIInstruction Inst = - MCCFIInstruction::createDefCfa(nullptr, - MRI.getDwarfRegNum(SystemZ::R15D, true), - SystemZMC::CFAOffsetFromInitialSP); + MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa( + nullptr, MRI.getDwarfRegNum(SystemZ::R15D, true), + -SystemZMC::CFAOffsetFromInitialSP); MAI->addInitialFrameState(Inst); return MAI; } diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp index 5b9c4c13a0a208..bf964782515ccb 100644 --- a/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp +++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp @@ -36,7 +36,7 @@ static MCAsmInfo *createVEMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options) { MCAsmInfo *MAI = new VEELFMCAsmInfo(TT); unsigned Reg = MRI.getDwarfRegNum(VE::SX11, true); - MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 0); + MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, Reg, 0); MAI->addInitialFrameState(Inst); return MAI; } diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp index b056cab7fa7641..2ba4c6db055a35 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -349,8 +349,8 @@ static MCAsmInfo *createX86MCAsmInfo(const MCRegisterInfo &MRI, // Initial state of the frame pointer is esp+stackGrowth. unsigned StackPtr = is64Bit ? X86::RSP : X86::ESP; - MCCFIInstruction Inst = MCCFIInstruction::createDefCfa( - nullptr, MRI.getDwarfRegNum(StackPtr, true), -stackGrowth); + MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa( + nullptr, MRI.getDwarfRegNum(StackPtr, true), stackGrowth); MAI->addInitialFrameState(Inst); // Add return address to move list diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp index e00a26049f1c80..99d8e0addc464c 100644 --- a/llvm/lib/Target/X86/X86FrameLowering.cpp +++ b/llvm/lib/Target/X86/X86FrameLowering.cpp @@ -1842,8 +1842,8 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF, if (NeedsDwarfCFI) { unsigned DwarfStackPtr = TRI->getDwarfRegNum(Is64Bit ? X86::RSP : X86::ESP, true); - BuildCFI(MBB, MBBI, DL, MCCFIInstruction::createDefCfa( - nullptr, DwarfStackPtr, -SlotSize)); + BuildCFI(MBB, MBBI, DL, + MCCFIInstruction::cfiDefCfa(nullptr, DwarfStackPtr, SlotSize)); if (!MBB.succ_empty() && !MBB.isReturnBlock()) { unsigned DwarfFramePtr = TRI->getDwarfRegNum(MachineFramePtr, true); BuildCFI(MBB, AfterPop, DL, diff --git a/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp b/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp index 46ebccee521e53..4de252548961da 100644 --- a/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp +++ b/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp @@ -60,7 +60,7 @@ static MCAsmInfo *createXCoreMCAsmInfo(const MCRegisterInfo &MRI, MCAsmInfo *MAI = new XCoreMCAsmInfo(TT); // Initial state of the frame pointer is SP. - MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, XCore::SP, 0); + MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, XCore::SP, 0); MAI->addInitialFrameState(Inst); return MAI; From a8a048ac7253ca92228d0862b6c1175f1613a840 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 22 May 2020 15:51:43 -0700 Subject: [PATCH 3/3] Restrict test for DW_AT_APPLE_optimized to Darwin --- lldb/test/Shell/Process/Optimization.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/test/Shell/Process/Optimization.test b/lldb/test/Shell/Process/Optimization.test index 10d241f698c0d0..1309a16aa98e2f 100644 --- a/lldb/test/Shell/Process/Optimization.test +++ b/lldb/test/Shell/Process/Optimization.test @@ -1,5 +1,5 @@ Test warnings. -REQUIRES: shell +REQUIRES: shell, system-darwin RUN: %clang_host -O3 %S/Inputs/true.c -std=c99 -g -o %t.exe RUN: %lldb -o "b main" -o r -o q -b %t.exe | FileCheck %s