Skip to content

Commit f769284

Browse files
committed
Merged origin/amd-debug:7e613bd98fe8 into origin/amd-gfx:f79889daa683 Local branch origin/amd-gfx f79889d Merged origin/amd-debug:22d8dc4320f6 into origin/amd-gfx:70bfbfab17ec Remote branch origin/amd-debug 7e613bd Cleanup compiler warnings and fix failing NVPTX tests (#3238)
2 parents f79889d + 7e613bd commit f769284

File tree

7 files changed

+55
-30
lines changed

7 files changed

+55
-30
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ void DwarfExpression::addExpression(DIExpression::NewElementsRef Expr,
756756
IsFragment = false;
757757
ASTRoot.reset();
758758
this->TRI = nullptr;
759-
this->ArgLocEntries = std::nullopt;
759+
this->ArgLocEntries = {};
760760
}
761761

762762
/// add masking operations to stencil out a subregister.

llvm/lib/DWARFCFIChecker/DWARFCFIState.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ dwarf::CFIProgram DWARFCFIState::convert(MCCFIInstruction Directive) {
161161
CFIP.addInstruction(dwarf::DW_CFA_val_offset, Directive.getRegister(),
162162
Directive.getOffset());
163163
break;
164+
case MCCFIInstruction::OpLLVMRegisterPair:
165+
case MCCFIInstruction::OpLLVMVectorRegisters:
166+
case MCCFIInstruction::OpLLVMVectorOffset:
167+
case MCCFIInstruction::OpLLVMVectorRegisterMask:
168+
// TODO: These should be pretty straightforward to support, but is low
169+
// priority. Similarly the implementation of OpLLVMDefAspaceCfa above
170+
// seem incomplete and should be fixed.
171+
Context->reportWarning(Directive.getLoc(),
172+
"this directive is not supported, ignoring it");
173+
break;
164174
}
165175

166176
return CFIP;

llvm/lib/Target/AMDGPU/SIFrameLowering.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ static MCRegister findUnusedRegister(MachineRegisterInfo &MRI,
4848
return MCRegister();
4949
}
5050

51+
static bool needsFrameMoves(const MachineFunction &MF) {
52+
// FIXME: There are some places in the compiler which are sensitive to the CFI
53+
// pseudos and so using MachineFunction::needsFrameMoves has the unintended
54+
// effect of making enabling debug info affect codegen. Once we have
55+
// identified and fixed those cases this should be replaced with
56+
// MF.needsFrameMoves()
57+
return true;
58+
}
59+
5160
static void encodeDwarfRegisterLocation(int DwarfReg, raw_ostream &OS) {
5261
assert(DwarfReg >= 0);
5362
if (DwarfReg < 32) {
@@ -485,8 +494,7 @@ class PrologEpilogSGPRSpillBuilder {
485494
SplitParts = TRI.getRegSplitParts(RC, EltSize);
486495
NumSubRegs = SplitParts.empty() ? 1 : SplitParts.size();
487496

488-
// FIXME: Switch to using MF.needsFrameMoves() later.
489-
NeedsFrameMoves = true;
497+
NeedsFrameMoves = needsFrameMoves(MF);
490498

491499
assert(SuperReg != AMDGPU::M0 && "m0 should never spill");
492500
}
@@ -923,8 +931,7 @@ void SIFrameLowering::emitEntryFunctionPrologue(MachineFunction &MF,
923931
if (FrameInfo.getStackSize() > 0 && MFI->ldsSpillingEnabled(MF))
924932
setupLDSSpilling(MF, MBB, I, DL);
925933

926-
// FIXME: Switch to using MF.needsFrameMoves() later
927-
const bool NeedsFrameMoves = true;
934+
const bool NeedsFrameMoves = needsFrameMoves(MF);
928935

929936
if (NeedsFrameMoves) {
930937
// On entry the SP/FP are not set up, so we need to define the CFA in terms
@@ -1595,8 +1602,7 @@ void SIFrameLowering::emitPrologue(MachineFunction &MF,
15951602
uint32_t NumBytes = MFI.getStackSize();
15961603
uint32_t RoundedSize = NumBytes;
15971604

1598-
// FIXME: Switch to using MF.needsFrameMoves() later
1599-
const bool NeedsFrameMoves = true;
1605+
const bool NeedsFrameMoves = needsFrameMoves(MF);
16001606

16011607
if (NeedsFrameMoves)
16021608
emitPrologueEntryCFI(MBB, MBBI, DL);
@@ -1786,8 +1792,7 @@ void SIFrameLowering::emitEpilogue(MachineFunction &MF,
17861792
FramePtrRegScratchCopy);
17871793
}
17881794

1789-
// FIXME: Switch to using MF.needsFrameMoves() later
1790-
const bool NeedsFrameMoves = true;
1795+
const bool NeedsFrameMoves = needsFrameMoves(MF);
17911796
if (hasFP(MF)) {
17921797
if (NeedsFrameMoves)
17931798
emitDefCFA(MBB, MBBI, DL, StackPtrReg, /*AspaceAlreadyDefined=*/false,

llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,11 @@ Value *InferAddressSpacesImpl::cloneValueWithNewAddressSpace(
873873
NewI->setDebugLoc(I->getDebugLoc());
874874
}
875875
}
876-
if (NewV) {
876+
// Move debug markers to the inferred aspace, unless they already refer
877+
// directly to an alloca. The alloca should reflect the "true" location
878+
// anyway, and if it is optimized out later and infer-address-spaces runs
879+
// again we should be no worse off.
880+
if (NewV && !isa<AllocaInst>(I)) {
877881
Instruction *DomPoint =
878882
isa<Instruction>(NewV) ? cast<Instruction>(NewV) : I;
879883
replaceAllDbgUsesWith(*I, *NewV, *DomPoint, *DT);

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,11 +2817,6 @@ bool llvm::replaceAllDbgUsesWith(Instruction &From, Value &To,
28172817
if (FromTy->isPointerTy() && ToTy->isPointerTy()) {
28182818
// Non-bitcast address space conversions are only supported on
28192819
// DIOp-DIExpressions.
2820-
auto IdentityNew = [&](DbgVariableIntrinsic &DII) -> DbgValReplacement {
2821-
if (DII.getExpression()->holdsNewElements())
2822-
return updateNewDIExpressionArgType(DII, &From, ToTy);
2823-
return std::nullopt;
2824-
};
28252820
auto IdentityNewDVR = [&](DbgVariableRecord &DVR) -> DbgValReplacement {
28262821
if (DVR.getExpression()->holdsNewElements())
28272822
return updateNewDIExpressionArgType(DVR, &From, ToTy);

llvm/test/DebugInfo/NVPTX/debug-info.ll

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -585,12 +585,12 @@ if.end: ; preds = %if.then, %entry
585585
; CHECK-NEXT: }
586586
; CHECK-NEXT: .section .debug_info
587587
; CHECK-NEXT: {
588-
; CHECK-NEXT: .b32 2404 // Length of Unit
588+
; CHECK-NEXT: .b32 2417 // Length of Unit
589589
; CHECK-NEXT: .b8 2 // DWARF version number
590590
; CHECK-NEXT: .b8 0
591591
; CHECK-NEXT: .b32 .debug_abbrev // Offset Into Abbrev. Section
592592
; CHECK-NEXT: .b8 8 // Address Size (in bytes)
593-
; CHECK-NEXT: .b8 1 // Abbrev [1] 0xb:0x95d DW_TAG_compile_unit
593+
; CHECK-NEXT: .b8 1 // Abbrev [1] 0xb:0x96a DW_TAG_compile_unit
594594
; CHECK-NEXT: .b8 0 // DW_AT_producer
595595
; CHECK-NEXT: .b8 4 // DW_AT_language
596596
; CHECK-NEXT: .b8 0
@@ -2480,7 +2480,7 @@ if.end: ; preds = %if.then, %entry
24802480
; CHECK-NEXT: .b8 4 // DW_AT_byte_size
24812481
; CHECK-NEXT: .b8 12 // Abbrev [12] 0x83d:0x5 DW_TAG_pointer_type
24822482
; CHECK-NEXT: .b32 2100 // DW_AT_type
2483-
; CHECK-NEXT: .b8 23 // Abbrev [23] 0x842:0xe5 DW_TAG_subprogram
2483+
; CHECK-NEXT: .b8 23 // Abbrev [23] 0x842:0xf2 DW_TAG_subprogram
24842484
; CHECK-NEXT: .b64 $L__func_begin0 // DW_AT_low_pc
24852485
; CHECK-NEXT: .b64 $L__func_end0 // DW_AT_high_pc
24862486
; CHECK-NEXT: .b8 1 // DW_AT_frame_base
@@ -2521,7 +2521,7 @@ if.end: ; preds = %if.then, %entry
25212521
; CHECK-NEXT: .b8 0
25222522
; CHECK-NEXT: .b8 1 // DW_AT_decl_file
25232523
; CHECK-NEXT: .b8 5 // DW_AT_decl_line
2524-
; CHECK-NEXT: .b32 2400 // DW_AT_type
2524+
; CHECK-NEXT: .b32 2413 // DW_AT_type
25252525
; CHECK-NEXT: .b8 25 // Abbrev [25] 0x87d:0xd DW_TAG_formal_parameter
25262526
; CHECK-NEXT: .b32 $L__debug_loc0 // DW_AT_location
25272527
; CHECK-NEXT: .b8 97 // DW_AT_name
@@ -2563,7 +2563,7 @@ if.end: ; preds = %if.then, %entry
25632563
; CHECK-NEXT: .b8 0
25642564
; CHECK-NEXT: .b8 1 // DW_AT_decl_file
25652565
; CHECK-NEXT: .b8 6 // DW_AT_decl_line
2566-
; CHECK-NEXT: .b32 2400 // DW_AT_type
2566+
; CHECK-NEXT: .b32 2413 // DW_AT_type
25672567
; CHECK-NEXT: .b8 27 // Abbrev [27] 0x8b9:0x18 DW_TAG_inlined_subroutine
25682568
; CHECK-NEXT: .b32 691 // DW_AT_abstract_origin
25692569
; CHECK-NEXT: .b64 $L__tmp3 // DW_AT_low_pc
@@ -2585,7 +2585,7 @@ if.end: ; preds = %if.then, %entry
25852585
; CHECK-NEXT: .b8 1 // DW_AT_call_file
25862586
; CHECK-NEXT: .b8 6 // DW_AT_call_line
25872587
; CHECK-NEXT: .b8 37 // DW_AT_call_column
2588-
; CHECK-NEXT: .b8 28 // Abbrev [28] 0x901:0x25 DW_TAG_inlined_subroutine
2588+
; CHECK-NEXT: .b8 28 // Abbrev [28] 0x901:0x32 DW_TAG_inlined_subroutine
25892589
; CHECK-NEXT: .b32 2050 // DW_AT_abstract_origin
25902590
; CHECK-NEXT: .b64 $L__tmp11 // DW_AT_low_pc
25912591
; CHECK-NEXT: .b64 $L__tmp12 // DW_AT_high_pc
@@ -2601,19 +2601,29 @@ if.end: ; preds = %if.then, %entry
26012601
; CHECK-NEXT: .b8 149
26022602
; CHECK-NEXT: .b8 1
26032603
; CHECK-NEXT: .b32 2079 // DW_AT_abstract_origin
2604+
; CHECK-NEXT: .b8 29 // Abbrev [29] 0x925:0xd DW_TAG_formal_parameter
2605+
; CHECK-NEXT: .b8 2 // DW_AT_address_class
2606+
; CHECK-NEXT: .b8 6 // DW_AT_location
2607+
; CHECK-NEXT: .b8 144
2608+
; CHECK-NEXT: .b8 183
2609+
; CHECK-NEXT: .b8 200
2610+
; CHECK-NEXT: .b8 201
2611+
; CHECK-NEXT: .b8 171
2612+
; CHECK-NEXT: .b8 2
2613+
; CHECK-NEXT: .b32 2088 // DW_AT_abstract_origin
26042614
; CHECK-NEXT: .b8 0 // End Of Children Mark
26052615
; CHECK-NEXT: .b8 0 // End Of Children Mark
2606-
; CHECK-NEXT: .b8 30 // Abbrev [30] 0x927:0xd DW_TAG_namespace
2616+
; CHECK-NEXT: .b8 30 // Abbrev [30] 0x934:0xd DW_TAG_namespace
26072617
; CHECK-NEXT: .b8 115 // DW_AT_name
26082618
; CHECK-NEXT: .b8 116
26092619
; CHECK-NEXT: .b8 100
26102620
; CHECK-NEXT: .b8 0
2611-
; CHECK-NEXT: .b8 31 // Abbrev [31] 0x92c:0x7 DW_TAG_imported_declaration
2621+
; CHECK-NEXT: .b8 31 // Abbrev [31] 0x939:0x7 DW_TAG_imported_declaration
26122622
; CHECK-NEXT: .b8 4 // DW_AT_decl_file
26132623
; CHECK-NEXT: .b8 202 // DW_AT_decl_line
2614-
; CHECK-NEXT: .b32 2356 // DW_AT_import
2624+
; CHECK-NEXT: .b32 2369 // DW_AT_import
26152625
; CHECK-NEXT: .b8 0 // End Of Children Mark
2616-
; CHECK-NEXT: .b8 32 // Abbrev [32] 0x934:0x1b DW_TAG_subprogram
2626+
; CHECK-NEXT: .b8 32 // Abbrev [32] 0x941:0x1b DW_TAG_subprogram
26172627
; CHECK-NEXT: .b8 95 // DW_AT_MIPS_linkage_name
26182628
; CHECK-NEXT: .b8 90
26192629
; CHECK-NEXT: .b8 76
@@ -2629,12 +2639,12 @@ if.end: ; preds = %if.then, %entry
26292639
; CHECK-NEXT: .b8 0
26302640
; CHECK-NEXT: .b8 4 // DW_AT_decl_file
26312641
; CHECK-NEXT: .b8 44 // DW_AT_decl_line
2632-
; CHECK-NEXT: .b32 2383 // DW_AT_type
2642+
; CHECK-NEXT: .b32 2396 // DW_AT_type
26332643
; CHECK-NEXT: .b8 1 // DW_AT_declaration
2634-
; CHECK-NEXT: .b8 7 // Abbrev [7] 0x949:0x5 DW_TAG_formal_parameter
2635-
; CHECK-NEXT: .b32 2383 // DW_AT_type
2644+
; CHECK-NEXT: .b8 7 // Abbrev [7] 0x956:0x5 DW_TAG_formal_parameter
2645+
; CHECK-NEXT: .b32 2396 // DW_AT_type
26362646
; CHECK-NEXT: .b8 0 // End Of Children Mark
2637-
; CHECK-NEXT: .b8 10 // Abbrev [10] 0x94f:0x11 DW_TAG_base_type
2647+
; CHECK-NEXT: .b8 10 // Abbrev [10] 0x95c:0x11 DW_TAG_base_type
26382648
; CHECK-NEXT: .b8 108 // DW_AT_name
26392649
; CHECK-NEXT: .b8 111
26402650
; CHECK-NEXT: .b8 110
@@ -2651,7 +2661,7 @@ if.end: ; preds = %if.then, %entry
26512661
; CHECK-NEXT: .b8 0
26522662
; CHECK-NEXT: .b8 5 // DW_AT_encoding
26532663
; CHECK-NEXT: .b8 8 // DW_AT_byte_size
2654-
; CHECK-NEXT: .b8 10 // Abbrev [10] 0x960:0x7 DW_TAG_base_type
2664+
; CHECK-NEXT: .b8 10 // Abbrev [10] 0x96d:0x7 DW_TAG_base_type
26552665
; CHECK-NEXT: .b8 105 // DW_AT_name
26562666
; CHECK-NEXT: .b8 110
26572667
; CHECK-NEXT: .b8 116

llvm/tools/llvm-dwarfdump/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
77
Object
88
Support
99
TargetParser
10+
BinaryFormat
1011
)
1112

1213
add_llvm_tool(llvm-dwarfdump

0 commit comments

Comments
 (0)