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 {