Issue 164805
Summary [RISCV] llvm 21.1.3 creates invalid unwind info
Labels new issue
Assignees
Reporter andreas-schwab
    
The compiler creates this prologue for _ZN4llvm15runPassPipelineENS_9StringRefERNS_6ModuleEPNS_13TargetMachineEPNS_21TargetLibraryInfoImplEPNS_14ToolOutputFileES8_S8_S0_NS_8ArrayRefINS_10PassPluginEEENS9_ISt8functionIFvRNS_11PassBuilderEEEEENS_8opt_tool10OutputKindENSI_12VerifierKindEbbbbbbb (aka llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)> >, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool)) from tools/opt/NewPMDriver.cpp:

000000000001ce60 <_ZN4llvm15runPassPipelineENS_9StringRefERNS_6ModuleEPNS_13TargetMachineEPNS_21TargetLibraryInfoImplEPNS_14ToolOutputFileES8_S8_S0_NS_8ArrayRefINS_10PassPluginEEENS9_ISt8functionIFvRNS_11PassBuilderEEEEENS_8opt_tool10OutputKindENSI_12VerifierKindEbbbbbbb@@Base>:
 1ce60:	7141                	addi	sp,sp,-496
   1ce62:	f786 	sd	ra,488(sp)
   1ce64:	f3a2                	sd	s0,480(sp)
 1ce66:	efa6                	sd	s1,472(sp)
   1ce68:	ebca 	sd	s2,464(sp)
   1ce6a:	e7ce                	sd	s3,456(sp)
 1ce6c:	e3d2                	sd	s4,448(sp)
   1ce6e:	ff56 	sd	s5,440(sp)
   1ce70:	fb5a                	sd	s6,432(sp)
 1ce72:	f75e                	sd	s7,424(sp)
   1ce74:	f362 	sd	s8,416(sp)
   1ce76:	ef66                	sd	s9,408(sp)
 1ce78:	eb6a                	sd	s10,400(sp)
   1ce7a:	e76e 	sd	s11,392(sp)
   1ce7c:	6285                	lui	t0,0x1
 1ce7e:	40510133          	sub	sp,sp,t0
   1ce82:	e002 	sd	zero,0(sp)
   1ce84:	80010113          	addi	sp,sp,-2048
 1ce88:	d4010113          	addi	sp,sp,-704

At 1ce8c the CFA is at sp + 496 + 4096 + 2048 + 704 = sp+7344.  But the unwind info for that function starts like this:

00000ed8 0000000000000050 00000eb4 FDE cie=00000028 pc=000000000001ce60..0000000000020368
  DW_CFA_advance_loc: 2 to 000000000001ce62
  DW_CFA_def_cfa_offset: 496
  DW_CFA_advance_loc: 26 to 000000000001ce7c
  DW_CFA_offset: r1 (ra) at cfa-8
  DW_CFA_offset: r8 (s0) at cfa-16
  DW_CFA_offset: r9 (s1) at cfa-24
  DW_CFA_offset: r18 (s2) at cfa-32
  DW_CFA_offset: r19 (s3) at cfa-40
  DW_CFA_offset: r20 (s4) at cfa-48
  DW_CFA_offset: r21 (s5) at cfa-56
  DW_CFA_offset: r22 (s6) at cfa-64
  DW_CFA_offset: r23 (s7) at cfa-72
  DW_CFA_offset: r24 (s8) at cfa-80
  DW_CFA_offset: r25 (s9) at cfa-88
  DW_CFA_offset: r26 (s10) at cfa-96
  DW_CFA_offset: r27 (s11) at cfa-104
  DW_CFA_advance_loc: 8 to 000000000001ce84
  DW_CFA_def_cfa_offset: 4096
  DW_CFA_advance_loc: 8 to 000000000001ce8c
  DW_CFA_def_cfa_offset: 6848

This places the CFA at sp + 6848, off by the initial 496 frame offset.

Later in the function:

 1fec4:	6589                	lui	a1,0x2
   1fec6:	ac058593 	addi	a1,a1,-1344 # 1ac0 <_ZN4llvm41initializeExpandLargeDivRemLegacyPassPassERNS_12PassRegistryE@plt-0x118d0>
 1feca:	912e                	add	sp,sp,a1

This adds 6848 to sp, which sets the frame offset back to 496.  The unwind info records that correctly again:

  DW_CFA_advance_loc2: 12352 to 000000000001fecc
 DW_CFA_def_cfa_offset: 496

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to