Index: include/llvm/MC/MCExpr.h =================================================================== --- include/llvm/MC/MCExpr.h +++ include/llvm/MC/MCExpr.h @@ -45,6 +45,7 @@ private: ExprKind Kind; SMLoc Loc; + mutable bool Fixed; bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm, const MCAsmLayout *Layout, @@ -55,7 +56,8 @@ const SectionAddrMap *Addrs, bool InSet) const; protected: - explicit MCExpr(ExprKind Kind, SMLoc Loc) : Kind(Kind), Loc(Loc) {} + explicit MCExpr(ExprKind Kind, SMLoc Loc) + : Kind(Kind), Loc(Loc), Fixed(false) {} bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCAsmLayout *Layout, @@ -71,6 +73,8 @@ ExprKind getKind() const { return Kind; } SMLoc getLoc() const { return Loc; } + bool getFixed() const { return Fixed; } + void setFixed() const { Fixed = true; } /// @} /// \name Utility Methods Index: lib/MC/MCDwarf.cpp =================================================================== --- lib/MC/MCDwarf.cpp +++ lib/MC/MCDwarf.cpp @@ -1570,6 +1570,7 @@ // Length const MCExpr *Length = MakeStartMinusEndExpr(Streamer, *sectionStart, *sectionEnd, 4); + Length->setFixed(); emitAbsValue(Streamer, Length, 4); // CIE ID @@ -1686,6 +1687,7 @@ // Length const MCExpr *Length = MakeStartMinusEndExpr(Streamer, *fdeStart, *fdeEnd, 0); + Length->setFixed(); emitAbsValue(Streamer, Length, 4); Streamer.EmitLabel(fdeStart); @@ -1695,6 +1697,7 @@ if (IsEH) { const MCExpr *offset = MakeStartMinusEndExpr(Streamer, cieStart, *fdeStart, 0); + offset->setFixed(); emitAbsValue(Streamer, offset, 4); } else if (!asmInfo->doesDwarfUseRelocationsAcrossSections()) { const MCExpr *offset = Index: lib/MC/MCExpr.cpp =================================================================== --- lib/MC/MCExpr.cpp +++ lib/MC/MCExpr.cpp @@ -646,7 +646,7 @@ const MCFixup *Fixup) const { MCAssembler *Assembler = Layout ? &Layout->getAssembler() : nullptr; return evaluateAsRelocatableImpl(Res, Assembler, Layout, Fixup, nullptr, - false); + Fixed); } bool MCExpr::evaluateAsValue(MCValue &Res, const MCAsmLayout &Layout) const { Index: test/DebugInfo/RISCV/relax-debug-frame.ll =================================================================== --- test/DebugInfo/RISCV/relax-debug-frame.ll +++ test/DebugInfo/RISCV/relax-debug-frame.ll @@ -2,10 +2,12 @@ ; RUN: | llvm-readobj -r | FileCheck -check-prefix=RELAX %s ; ; RELAX: .rela.{{eh|debug}}_frame { -; RELAX: R_RISCV_ADD32 -; RELAX: R_RISCV_SUB32 -; RELAX: R_RISCV_SET6 -; RELAX: R_RISCV_SUB6 +; RELAX-NOT: 0x0 R_RISCV_ADD32 +; RELAX-NOT: 0x0 R_RISCV_SUB32 +; RELAX: 0x20 R_RISCV_ADD32 +; RELAX: 0x20 R_RISCV_SUB32 +; RELAX: 0x25 R_RISCV_SET6 +; RELAX: 0x25 R_RISCV_SUB6 source_filename = "frame.c" ; Function Attrs: noinline nounwind optnone