[clang] [llvm] [win][x64] Add support for Windows x64 unwind v3 (PR #200249)
Mészáros Gergely via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 1 07:23:03 PDT 2026
================
@@ -106,6 +106,25 @@ static void EmitAbsDifference(MCStreamer &Streamer, const MCSymbol *LHS,
Streamer.emitValue(Diff, 1);
}
+/// Emit a 16-bit (2-byte LE) label difference. If the difference is
+/// evaluatable at this point, validate that it fits in [0, UINT16_MAX]
+/// and emit it as a constant; otherwise emit a 16-bit fixup.
+static void EmitAbsDifference16(MCStreamer &Streamer, const MCSymbol *LHS,
+ const MCSymbol *RHS) {
+ MCContext &Context = Streamer.getContext();
+ const MCExpr *Diff =
+ MCBinaryExpr::createSub(MCSymbolRefExpr::create(LHS, Context),
+ MCSymbolRefExpr::create(RHS, Context), Context);
+ int64_t Value;
+ if (Diff->evaluateAsAbsolute(
+ Value, static_cast<MCObjectStreamer &>(Streamer).getAssembler())) {
+ if (Value < 0 || Value > UINT16_MAX)
+ report_fatal_error(
+ "Label difference out of 16-bit unsigned range for V3 unwind info");
----------------
Maetveis wrote:
There are a lot of new intances of `report_fatal_error` introduced in this patch, which is a deprecated API:
> /// @deprecated Use `reportFatalInternalError()` or `reportFatalUsageError()`
> /// instead.
https://github.com/llvm/llvm-project/blob/2d046bd62066067a1de8cb65752f1dd9404c4121/llvm/include/llvm/Support/ErrorHandling.h#L61-L79
Places where we have a way to continue should use recoverable errors ([`LLVMContext::diagnose()`](https://github.com/llvm/llvm-project/blob/2d046bd62066067a1de8cb65752f1dd9404c4121/llvm/include/llvm/IR/LLVMContext.h#L274-L284)) or other similar APIs.
Error paths that there is a programming error in LLVM should use `reportFatalInternalError()`.
And finally only places where we have absolutely no way to continue and have to terminate the whole process, but the error condition does not indicate a bug in LLVM should use `reportFatalUsageError`.
https://github.com/llvm/llvm-project/pull/200249
More information about the cfe-commits
mailing list