diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index 7f4a3a8c2f972d..1ec1b4b2864f9c 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -983,10 +983,14 @@ class MachineFunction { return VariableDbgInfos; } + /// Start tracking the arguments passed to the call \p CallI. void addCallArgsForwardingRegs(const MachineInstr *CallI, CallSiteInfoImpl &&CallInfo) { - assert(CallI->isCall()); - CallSitesInfo[CallI] = std::move(CallInfo); + assert(CallI->isCandidateForCallSiteEntry()); + bool Inserted = + CallSitesInfo.try_emplace(CallI, std::move(CallInfo)).second; + (void)Inserted; + assert(Inserted && "Call site info not unique"); } const CallSiteInfoMap &getCallSitesInfo() const { diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h index 8c4d16419fa260..18c4173cc97e6e 100644 --- a/llvm/include/llvm/CodeGen/MachineInstr.h +++ b/llvm/include/llvm/CodeGen/MachineInstr.h @@ -683,6 +683,10 @@ class MachineInstr return hasProperty(MCID::Call, Type); } + /// Return true if this is a call instruction that may have an associated + /// call site entry in the debug info. + bool isCandidateForCallSiteEntry() const; + /// Returns true if the specified instruction stops control flow /// from executing the instruction immediately following it. Examples include /// unconditional branches and return instructions. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 3a8252e8b320c6..fd27f241d808ae 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -764,7 +764,7 @@ void DwarfDebug::constructCallSiteEntryDIEs(const DISubprogram &SP, // Skip instructions which aren't calls. Both calls and tail-calling jump // instructions (e.g TAILJMPd64) are classified correctly here. - if (!MI.isCall()) + if (!MI.isCandidateForCallSiteEntry()) continue; // TODO: Add support for targets with delay slots (see: beginInstruction). diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 08d786f8f12cc3..7d4a474a7858bf 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -696,6 +696,20 @@ void MachineInstr::eraseFromBundle() { getParent()->erase_instr(this); } +bool MachineInstr::isCandidateForCallSiteEntry() const { + if (!isCall(MachineInstr::IgnoreBundle)) + return false; + switch (getOpcode()) { + case TargetOpcode::PATCHABLE_EVENT_CALL: + case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL: + case TargetOpcode::PATCHPOINT: + case TargetOpcode::STACKMAP: + case TargetOpcode::STATEPOINT: + return false; + } + return true; +} + unsigned MachineInstr::getNumExplicitOperands() const { unsigned NumOperands = MCID->getNumOperands(); if (!MCID->isVariadic()) diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp index 0e4d783e3505d6..a297db17883583 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp @@ -863,7 +863,8 @@ EmitSchedule(MachineBasicBlock::iterator &InsertPos) { MI = &*std::next(Before); } - if (MI->isCall() && DAG->getTarget().Options.EnableDebugEntryValues) + if (MI->isCandidateForCallSiteEntry() && + DAG->getTarget().Options.EnableDebugEntryValues) MF.addCallArgsForwardingRegs(MI, DAG->getSDCallSiteInfo(Node)); return MI; diff --git a/llvm/test/CodeGen/AArch64/arm64-anyregcc.ll b/llvm/test/CodeGen/AArch64/arm64-anyregcc.ll index 10989a07990c5a..33bbfa2d81d9fc 100644 --- a/llvm/test/CodeGen/AArch64/arm64-anyregcc.ll +++ b/llvm/test/CodeGen/AArch64/arm64-anyregcc.ll @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=arm64-apple-darwin | FileCheck %s +; RUN: llc < %s -debug-entry-values -mtriple=arm64-apple-darwin | FileCheck %s ; Stackmap Header: no constants - 6 callsites ; CHECK-LABEL: .section __LLVM_STACKMAPS,__llvm_stackmaps diff --git a/llvm/test/CodeGen/AArch64/arm64-patchpoint.ll b/llvm/test/CodeGen/AArch64/arm64-patchpoint.ll index 2f9004bb22e67a..b64f2455908e0a 100644 --- a/llvm/test/CodeGen/AArch64/arm64-patchpoint.ll +++ b/llvm/test/CodeGen/AArch64/arm64-patchpoint.ll @@ -1,5 +1,5 @@ -; RUN: llc -mtriple=arm64-apple-darwin -enable-misched=0 -mcpu=cyclone < %s | FileCheck %s -; RUN: llc -mtriple=arm64-apple-darwin -enable-misched=0 -mcpu=cyclone -fast-isel -fast-isel-abort=1 < %s | FileCheck %s +; RUN: llc -mtriple=arm64-apple-darwin -debug-entry-values -enable-misched=0 -mcpu=cyclone < %s | FileCheck %s +; RUN: llc -mtriple=arm64-apple-darwin -debug-entry-values -enable-misched=0 -mcpu=cyclone -fast-isel -fast-isel-abort=1 < %s | FileCheck %s ; Trivial patchpoint codegen ; diff --git a/llvm/test/CodeGen/X86/statepoint-allocas.ll b/llvm/test/CodeGen/X86/statepoint-allocas.ll index c7bae8ff18c109..e469f38b311eb3 100644 --- a/llvm/test/CodeGen/X86/statepoint-allocas.ll +++ b/llvm/test/CodeGen/X86/statepoint-allocas.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -verify-machineinstrs < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -debug-entry-values < %s | FileCheck %s ; Check that we can lower a use of an alloca both as a deopt value (where the ; exact meaning is up to the consumer of the stackmap) and as an explicit spill ; slot used for GC. diff --git a/llvm/test/CodeGen/X86/xray-custom-log.ll b/llvm/test/CodeGen/X86/xray-custom-log.ll index 3a3d6a5df0d02e..f53e6c676c3b7b 100644 --- a/llvm/test/CodeGen/X86/xray-custom-log.ll +++ b/llvm/test/CodeGen/X86/xray-custom-log.ll @@ -1,5 +1,5 @@ -; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s -; RUN: llc -verify-machineinstrs -filetype=asm -o - \ +; RUN: llc -verify-machineinstrs -debug-entry-values -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -debug-entry-values -filetype=asm -o - \ ; RUN: -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC define i32 @fn() nounwind noinline uwtable "function-instrument"="xray-always" { diff --git a/llvm/test/CodeGen/X86/xray-typed-event-log.ll b/llvm/test/CodeGen/X86/xray-typed-event-log.ll index 0ed8ed7f65933c..aa7e19947f9524 100644 --- a/llvm/test/CodeGen/X86/xray-typed-event-log.ll +++ b/llvm/test/CodeGen/X86/xray-typed-event-log.ll @@ -1,5 +1,5 @@ -; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s -; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu \ +; RUN: llc -verify-machineinstrs -debug-entry-values -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -debug-entry-values -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu \ ; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC define i32 @fn() nounwind noinline uwtable "function-instrument"="xray-always" {