Thursday, November 26, 2026

MVVM in C#: What Changes When You Switch UI Frameworks?"If I change UI frameworks, will the C# MVVM backend of my application still work?" This is the most frequent question that we've received from developers since releasing the Qt Bridge for C# . We wanted to provide some detailed information to back the answer to that question, which is: yes, when moving to a Qt Quick / QML UI, your C# MVVM backend will still work in the exact same way. As we will see in the course of this blog post, this is due to two major factors: a) how C# and Qt Quick are brought together by the C# bridge, and b) the intrinsic design principles promoted by MVVM.📝Qt Blog
An interesting article on \Device\AFDI’ve just come across an interesting article that talks, in depth, about \Device\AFD and has lots of links to other useful stuff. More on AFD Adventures with \Device\Afd Test Driven Understanding Test Driven Design A simple client A simple server More \Device\Afd goodness Socket readiness without \Device\Afd A multi-connection AFD-based echo server AFD datagram performance An interesting article on \Device\Afd - this post📝Rambling Comments - Len Holgate's blog
Practical Testing: 47 - First steps with `if contexpr'As I mentioned in the last post I’m looking in to more modern ways to include conditional code in a class. Since I’m exploring here, and since I need some reasonably complicated code to make the exploration a viable test, I’ve decided to work on the “Practical Testing” code. So the next few episodes of Practical Testing will centre on removing preprocessor conditional code and replacing it with code that uses ‘if constexpr’.📝Rambling Comments - Len Holgate's blog
Security Advisory: Multiple third-party Chromium vulnerabilities fixed in Chrome 153.0.8010.48 impact Qt WebEngineQt WebEngine is based on the Chromium browser engine. Google has disclosed a set of security vulnerabilities fixed in Chrome 153.0.8010.48. These are third-party vulnerabilities, and the CVE identifiers were assigned by Google. We have analysed the vulnerabilities against the Chromium version used in Qt WebEngine. The vulnerabilities listed below have been identified as applicable or potentially applicable. Where we cannot rule out that Qt WebEngine is affected, we treat it as affected with the severity assigned by Chromium.📝Qt Blog
A direct -O0 code generator for LLVMThis post describes an experiment that compiles a function directly from LLVM IR to machine code bytes, without building a MachineFunction , and falls back to the regular pipeline one function at a time. On the compile-time tracker, -O0 -g builds take 14% fewer instructions on x86-64 and 21% fewer on AArch64. The generated code is 10% larger on x86-64 and about the same size on AArch64, and clang -S output assembles to the same code that clang -c emits. Skipping the pipeline creates an obligation, and most of this post is about that obligation. This post relies heavily on an LLM agent (Claude Code). It wrote most of the code and drafted this post, which I then edited. My part was steering. Where -O0 back-end time goes The back end's share of a clang -O0 compile ranges from 13% for ScalarEvolution.cpp to 39% for sqlite3. Within the back end, the cost is spread out: FastISel with its SelectionDAG fallback, RegAllocFast, prologue/epilogue insertion, the remaining MIR passes, legacy pass manager overhead, and MC lowering. Shares of back-end cycles from a profile ( llc -O0 -relocation-model=pic on x86-64, no assertions, bitcode parsing excluded, tramp3d built with -fno-exceptions ), good to a few points: Layer sqlite3 tramp3d sqlite3 -g tramp3d -g ISel (FastISel, SelectionDAG, driver) 43% 28% 30% 19% RegAllocFast 10% 8% 7% 6% Prologue/epilogue insertion 6% 7% 4% 5% IR preparation passes 7% 9% 6% 6% Legacy pass manager 5% 10% 3% 7% MachineFunction allocation, other MIR passes, CFI 9% 8% 7% 6% LiveDebugValues 0% 1% 9% 9% AsmPrinter (MI to MCInst) 7% 6% 6% 5% MC encoding, streamer, object writer 11% 22% 10% 17% DWARF and .eh_frame emission 1% 2% 19% 22% llc -O0 -mtriple=x86_64-linux-gnu -debug-pass=Structure on define void @f() { ret void } prints 72 entries under the function pass manager, counting repeated analyses, the printer and Free MachineFunction . An excerpt: FunctionPass Manager Expand IR instructions Expand Atomic instructions ... Exception handling preparation Prepare inline asm insts Safe Stack instrumentation pass Insert stack protectors Module Verifier Assignment Tracking Analysis X86 DAG->DAG Instruction Selection ... Eliminate PHI nodes for register allocation Machine Register Class Info Analysis Fast Register Allocator ... Prologue/Epilogue Insertion & Frame Finalization Post-RA pseudo instruction expansion pass X86 pseudo instruction expansion pass Insert KCFI indirect call checks Analyze Machine Code For Garbage Collection Insert fentry calls Insert XRay ops Implement the 'patchable-function' attribute X86 Indirect Branch Tracking ... Live DEBUG_VALUE analysis ... X86 Indirect Thunks X86 Return Thunks Check CFA info and insert CFI instructions if needed X86 Load Value Injection (LVI) Ret-Hardening ... X86 Assembly Printer Free MachineFunction Prior art FastISel (2008) selects most instructions itself, hands the rest of a block to SelectionDAG when it cannot, and then runs the full MIR pipeline. GlobalISel is the AArch64 -O0 default. TPDE is a single-pass back end with per-module fallback, no DWARF, and its own ELF writer. TPDE's back end executes 1.9x (sqlite3) to 3.2x (tramp3d) fewer instructions than the one described here. What this experiment adds is fallback per function into the same object file, debug info, respect for function attributes, hardening, and text output. From-scratch compilers written with AI assistance, such as Anthropic's CCC (February 2026, Rust, with its own assembler and linker), are a useful contrast rather than a competitor. Counted like for like, its x86-64 and AArch64 code generators with their shared layer are about 30K lines, against about 5.9K here. They carry a register allocator, peepholes, inline asm, i128 and x87, with no fallback; the direct code generator hands those to the regular pipeline and carries DWARF, exception tables and hardening instead. The advantages worth claiming are structural: a small delta inside LLVM, the regular pipeline as a differential oracle for every function, per-function fallback, and reused DWARF and object writing. What "direct" means IR goes to encoded bytes with no MIR in between. It is not "one pass": the bytes are patched afterwards, and emission still goes through AsmPrinter and MC. DirectCodeGen is a function pass, first in the -O0 codegen function pass manager, enabled by -direct-codegen . It compiles a function into a private buffer: bytes, fixups, CFI points, line rows, variable slots, and a call-site table. Nothing shared is touched until the function succeeds, and the IR is never modified. On success, AsmPrinter::emitCompiledFunction emits the function header, the bytes and the tables, and the pass tells the pass manager to skip the remaining passes for this function. On failure, the function takes the regular pipeline into the same object file. IR function | DirectCodeGen pass ---- any failure ----> regular pipeline | (ISel, MIR passes, AsmPrinter) | success | AsmPrinter::emitCompiledFunction | | | MCStreamer: the same .o or .s Section selection, linkage, alignment, DWARF and the object writer are reused, because they are not where the time goes. -direct-codegen-report prints the reason for each fallback, and -direct-codegen-abort turns a fallback into an error. The value model Static allocas live in fixed frame slots. A value with one use in its own block lives only in a register. Any other value is stored to its own slot at the definition. Its register stays as a clean copy that can be dropped without emitting code. Only caller-saved registers are used, so calls need no save and restore. The frame pointer is always set up. PHI moves happen on edges, with a temporary when PHIs of one block read each other. A compare used only by its branch, a load used only by the next instruction, and a constant-offset address are folded into their user. Here is a small function with a local, a branch and a call: struct S { int n, count; }; int g ( int ); int f ( struct S * p , int d ) { int t = d * 2 ; if (t > 0 ) p->count += g (t); return p->count; } clang -O0 -emit-llvm gives, trimmed to the instructions: entry: %p.addr = alloca ptr, align 8 %d.addr = alloca i32 , align 4 %t = alloca i32 , align 4 store ptr %p , ptr %p.addr , align 8 store i32 %d , ptr %d.addr , align 4 %0 = load i32 , ptr %d.addr , align 4 %mul = mul nsw i32 %0 , 2 store i32 %mul , ptr %t , align 4 %1 = load i32 , ptr %t , align 4 %cmp = icmp sgt i32 %1 , 0 br i1 %cmp , label %if.then , label %if.end if.then: %2 = load i32 , ptr %t , align 4 %call = call i32 @g ( i32 noundef %2 ) %3 = load ptr, ptr %p.addr , align 8 %count = getelementptr inbounds nuw %struct.S , ptr %3 , i32 0 , i32 1 %4 = load i32 , ptr %count , align 4 %add = add nsw i32 %4 , %call store i32 %add , ptr %count , align 4 br label %if.end if.end: %5 = load ptr, ptr %p.addr , align 8 %count1 = getelementptr inbounds nuw %struct.S , ptr %5 , i32 0 , i32 1 %6 = load i32 , ptr %count1 , align 4 ret i32 %6 and clang -O0 -S -mllvm -direct-codegen gives (directives removed, comments added): f: pushq % rbp movq % rsp , % rbp subq $32 , % rsp # frame size patched in after the last block movq % rdi , - 8 (% rbp ) # %p.addr: fixed slot movl % esi , - 12 (% rbp ) # %d.addr: fixed slot movl - 12 (% rbp ), % eax # %0: one use in its block, register only imull $2 , % eax , % eax # %mul: register only, stored to %t movl % eax , - 16 (% rbp ) # %t: fixed slot cmpl $0 , - 16 (% rbp ) # %1 folded into the compare, %cmp into the branch jle .Ltmp0 movl - 16 (% rbp ), % edi # %2: loaded straight into the argument register callq g@PLT # %call stays in %eax movq - 8 (% rbp ), % r10 # %3 leaq 4 (% r10 ), % r10 # %count has two uses: movq % r10 , - 24 (% rbp ) # stored to its own slot, %r10 kept as a clean copy movl (% r10 ), % r10d # %4 takes over %r10 addl % eax , % r10d # %add movq - 24 (% rbp ), % rax # %count reloaded from its slot for the store movl % r10d , (% rax ) . Ltmp0: # if.then falls through to if.end movq - 8 (% rbp ), % rax # %5 movl 4 (% rax ), % eax # %count1 folded into the load of %6 leave retq Blocks are compiled in layout order, not dominance order. A decision taken at a definition, such as folding a constant-offset address into its users, must therefore respect a slot that a use in an earlier-laid-out block has already reserved. Two targets On x86-64, instructions are built as MCInst s and encoded by the target's MCCodeEmitter , with the encodings of fixup-free instructions cached. The frame is rbp -based; the sub that allocates it is patched at the end, or removed when the function needs no adjustment (an empty frame, or a leaf that fits the red zone). Jumps start as rel32 and are shortened to rel8, to the same fixpoint the assembler's relaxation reaches. On AArch64, the frame record sits below the locals, so a slot offset from x29 is final when the slot is allocated and fits a scaled load/store offset. The frame size is known only at the end, so the prologue is written last into space reserved at the function start, and every return branches to one shared epilogue. The target-independent part ( DirectCodeGen.h and DirectCodeGen.cpp ) is about 2.0K lines, x86-64 1.8K, AArch64 1.7K, plus about 0.4K in AsmPrinter. The split goes through virtual hooks. A third target would implement the 35 pure virtual hooks of DirectCompiler (frame, slots, constants, branches, calls, and one hook per instruction class), the pass's subtarget gate, and its own calling convention, since both targets hand-write theirs without CCState . What a skipped pipeline owes Every MIR pass, frame-lowering feature and AsmPrinter feature must either be reimplemented or send the function to the regular pipeline. FastISel never has this problem, because the same passes run after it. The direct pass also runs before the IR preparation passes, so it must reject or implement anything they lower. The pass list above reads as a list of obligations: stack protectors, KCFI, fentry, XRay, patchable functions and indirect branch tracking all happen in skipped passes. Gates cannot look only at IR. Skipped passes also key on subtarget features (including -mattr ), cl::opt s, the triple and TargetOptions . The gates query the subtarget, so -mattr counts like the attribute, and they check the TargetOptions fields and options of skipped passes that could change the output. The policy is that unknown means fall back, because slow is a better failure than wrong. A plain allowlist makes that policy expensive. ASan, TSan, MSan and PGO instrumentation each add a module flag that only the instrumentation pass reads, and any SVE-capable -march puts vscale_range on every function; rejecting what is unknown would send those whole modules to the regular pipeline. An allowlist also fails silently on new IR: one new upstream function attribute can make every C++ inline function fall back. Enum attributes therefore go through an exhaustive switch with no default , in three groups: no effect on code generation, implemented, and left to the regular pipeline. Adding an attribute to LLVM then fails the build until someone puts it in a group. String attributes, metadata and module flags stay on allowlists, guarded by a clang test that aborts on fallback for common flag sets on both targets, among them PIC, -g , -fsanitize=function , -fprofile-instr-generate , -march=armv9-a , and the hardening flags below. Some features are reimplemented: the stack protector, ENDBR64 for IBT, PAC and BTI with the A key, and stack clash protection for frames that need no probe loop. With distro hardening flags, 99.6-99.7% of sqlite3 and tramp3d functions stay on the direct path on x86-64 and 99.2-99.5% on AArch64. Others are sent back: -pg , -mfentry , -finstrument-functions , XRay, patchable function entries, HWASan, MTE, shadow call stack, KCFI, retpolines and SLS. One gate is structural. Skipping the remaining passes stops emission only if the AsmPrinter is in the same function pass manager. A module pass in the codegen pipeline, such as the one -fjmc adds, splits the function pass manager, so the direct pass cannot find the AsmPrinter and the whole module falls back. Plain -O0 and PGO-instrumented builds fall back for 2.4% of functions over the llvm-test-suite single-source programs on x86-64; the AArch64 rate is about 12%, mostly from loads of types that are not handled. Sanitizers raise the x86-64 rate: Configuration Functions that fall back Missing lowering UBSan 12% *.with.overflow intrinsics MSan 15% TLS globals, constant expressions ASan 18% ptrtoint constants in asan.module_ctor / dtor , dynamic alloca ... align 32 TSan 85% llvm.returnaddress What remains unsolved is a feature switched on only by a cl::opt or a TargetOptions field. It has no forcing function like the attribute switch . -S must print what -c encodes The MCInst s are scratch values: each is encoded into the private buffer and dropped. Printing them as they are created cannot work, because the function may still fail, branches target byte offsets, and bytes are edited after encoding. For a text streamer, the compiler keeps each MCInst with its offset, and emitCompiledFunction replays them on success. Every later edit of the bytes has a counterpart on the list: the x86 frame sub is deleted or given its immediate, offsets are remapped after jumps shrink, the AArch64 prologue (written last) is rotated to the front, and branch operands become labels. The exception table uses label differences in text, because the assembler chooses instruction lengths. Gates must give the same answer for both file types, so the branch-padding check asks an MCAsmBackend created from the TargetMachine , not the streamer's. Disassembling the final bytes is not an option: neither cc1 nor llc registers a disassembler, and the x86 encoder folds constants into pc-relative fixup expressions that would have to be unfolded. The test is llc -filetype=asm | llvm-mc against llc -filetype=obj . For the two to agree on x86-64, the object path has to pick the encodings the assembler picks: accumulator forms ( test $1, %al ), shifts by one, and jump sizes, where one pass of shrinking from rel32 does not reach the assembler's fixpoint of growing from rel8. It uses the helpers X86MCInstLower uses and a relaxation that starts every jump short and grows the ones out of range. All 272 modules of a corpus (consumer-typeset, lencod, mafft, sqlite3 and tramp3d on both targets) give identical disassembly and relocations, and the sqlite3 and tramp3d objects are identical files, exception tables included. The line table's end address and the section order differ between text and object output with -g , as they do in the regular pipeline. The round trip also found differences in the regular pipeline: fadd %st, %st(0) and imul $-2 are encoded differently by -c and by -S plus the assembler, and on AArch64 a function named fp , h1 or b1 makes bl fp unassemblable. -fno-integrated-as output assembles with GNU as to the same code bytes, checked on one file per target. Debug info without a MachineFunction DwarfDebug consumes MachineInstr s, so emitCompiledFunction builds a skeleton MachineFunction with one placeholder instruction per line row and a fixed frame object per variable, and drives the existing debug handlers with it. The invariant is that debug info never changes the code. Nine -g variants, including -gdwarf64 , -gsplit-dwarf , -gline-tables-only and -gkey-instructions , produce .text identical to the build without debug info. Records that cannot be described from the generated code are dropped, as FastISel does. The skeleton starts with a frame-setup instruction. Without one, DwarfDebug sees an empty prologue and skips the scope-line row, and the prologue is attributed to the last line of the previous function. Two gaps are open: an elided fall-through branch loses its line, and a folded value takes the line of its user. Exceptions Calls inside an invoke range record call-site entries, and the compiler encodes the action records and type infos itself. For object output the LSDA is written from known byte offsets; for text output the same table uses label differences. A landing pad with PHIs gets a stub that keeps the exception registers intact. Adjacent call sites with the same landing pad and action are not merged, so .gcc_except_table is 46% larger on tramp3d. MC became the bottleneck With the pipeline gone, MC's end-of-module work was 20% of llc time on tramp3d. Several changes came out of this and landed on their own, helping every pipeline: an early return in X86 finishLayout ( #245114 ), CFI advance folding ( #245130 ), hashing mergeable-section names once ( #245122 ), section group names as StringRef instead of Twine ( #245125 ), and relocation section names ( #245121 ). A faster string table tail merge has not landed. What is still there: section selection per function, the string table sort, and generic fixup evaluation for FDEs. Compile time The tracker run measured a commit without the -S support or the x86 encoding changes. instructions:u geomeans: stage2-O0-g -14.3% (sqlite3 -29.9%, 7zip -3.6%) and aarch64-O0-g -21.0% (sqlite3 -43.3%). max-rss falls 3.1% and 2.4%. The measured commit also includes Instruction::getNumber ; optimized configurations change by -0.2% to -0.3% in instructions and +0.1% to +0.3% in max-rss, and neither change has been attributed. The range is wide because the back end's share of a compile differs by a factor of three between 7zip and sqlite3. Back-end instructions:u on x86-64, covering code generation and object emission, with -ffunction-sections -fno-unique-section-names : regular direct ratio TPDE sqlite3 970M 177M 5.5x 91M tramp3d -fno-exceptions 3131M 613M 5.1x 192M tramp3d 5085M 741M 6.9x 236M sqlite3 -g 1399M 446M 3.1x tramp3d -g 6630M 1741M 3.8x TPDE emits no DWARF, so it has no -g rows. The remaining time goes to MCInst construction and encoding, the AsmPrinter's per-function work, and MC. Code size and quality The tracker's size-text geomean for -O0 -g is +9.9% on x86-64, larger on all 11 benchmarks (+3.5% SPASS to +17.1% mafft), and -0.1% on AArch64, with seven benchmarks smaller and four larger (-9.3% sqlite3 to +24.6% consumer-typeset). .text against the regular pipeline with llc -relocation-model=pic on five programs, on the current tree: x86-64 vs FastISel AArch64 vs GlobalISel consumer-typeset +14.2% +25.1% lencod +14.7% +5.8% mafft +16.6% +2.2% sqlite3 +6.6% -9.9% tramp3d +13.5% -1.2% A few cheap optimizations are implemented: a compare folds into the branch that uses it, and a single-use load into its user; a constant-offset GEP, or a chain of them (nested fields), folds into the addressing mode of the loads and stores that use it; x86-64 uses leave , allocates xmm0 - xmm7 before xmm8 - xmm15 (which need a REX prefix), and gives allocas their natural alignment, which keeps more frame offsets in 8 bits; AArch64 uses cbz / cbnz for a compare with zero. Not done: scaled-index addressing on x86, which needs a second temporary at every address computation; folding :lo12: into AArch64 loads and stores, which needs the alignment of the global; a per-block cache of global addresses on AArch64; jump tables, so a switch is a compare chain; and constant pools, so an FP constant is built with movabs . test %r, %r for a compare with zero would save under 0.3%. On AArch64 a global's address is rematerialized at every use, where GlobalISel does it once per function; in exchange there are far fewer unconditional branches, which is why some benchmarks shrink. bump on x86-64 updates two fields through a pointer: struct Node { int key; int count; Node * next; double weight; }; void bump ( Node * n , int d ) { n->count += d; n->weight *= 2 ; } The regular pipeline (FastISel), 14 instructions, 48 bytes, plus an 8-byte constant-pool entry: pushq % rbp movq % rsp , % rbp movq % rdi , - 8 (% rbp ) movl % esi , - 12 (% rbp ) movl - 12 (% rbp ), % ecx movq - 8 (% rbp ), % rax addl 4 (% rax ), % ecx movl % ecx , 4 (% rax ) movq - 8 (% rbp ), % rax movsd .LCPI1_0(% rip ), % xmm0 mulsd 16 (% rax ), % xmm0 movsd % xmm0 , 16 (% rax ) popq % rbp retq The direct code generator, 23 instructions, 84 bytes: pushq % rbp movq % rsp , % rbp movq % rdi , - 8 (% rbp ) movl % esi , - 12 (% rbp ) movl - 12 (% rbp ), % eax movq - 8 (% rbp ), % r10 leaq 4 (% r10 ), % r10 movq % r10 , - 24 (% rbp ) movl (% r10 ), % r10d addl % eax , % r10d movq - 24 (% rbp ), % rax movl % r10d , (% rax ) movq - 8 (% rbp ), % rax leaq 16 (% rax ), % rax movq % rax , - 32 (% rbp ) movsd (% rax ), % xmm7 movabsq $4611686018427387904 , % rax movq % rax , % xmm6 mulsd % xmm6 , % xmm7 movq - 32 (% rbp ), % rax movsd % xmm7 , (% rax ) leave retq Each field address has two uses, so it is stored to a slot and reloaded, where FastISel folds it into both memory operands. The FP constant is built with movabs . touch on AArch64 reads and writes three globals: extern int g_ext; int g_def; static int g_tab[ 16 ]; int touch () { g_def += g_ext; g_tab[g_def & 15 ] += g_def; g_ext = g_tab[ 3 ] + g_def; return g_def; } The regular pipeline (GlobalISel), 21 instructions, 84 bytes: adrp x10, : got: g_ext ldr x10, [x10, : got_lo12: g_ext] adrp x8, g_def adrp x9, _ZL5g_tab add x9, x9, : lo12: _ZL5g_tab ldr w12, [x10] ldr w11, [x8, : lo12: g_def] add w11, w11, w12 str w11, [x8, : lo12: g_def] ldr w13, [x8, : lo12: g_def] ldr w11, [x8, : lo12: g_def] and w12, w11, # 0xf ldr w11, [x9, w12, sxtw # 2 ] add w11, w11, w13 str w11, [x9, w12, sxtw # 2 ] ldr w9, [x9, # 12 ] ldr w11, [x8, : lo12: g_def] add w9, w9, w11 str w9, [x10] ldr w0, [x8, : lo12: g_def] ret The direct code generator, 43 instructions, 172 bytes: stp x29, x30, [ sp , #- 32 ]! mov x29, sp adrp x9, : got: g_ext ldr x9, [x9, : got_lo12: g_ext] ldr w9, [x9] adrp x10, g_def add x10, x10, : lo12: g_def ldr w10, [x10] add w10, w10, w9 adrp x9, g_def add x9, x9, : lo12: g_def str w10, [x9] adrp x9, g_def add x9, x9, : lo12: g_def ldr w9, [x9] adrp x10, g_def add x10, x10, : lo12: g_def ldr w10, [x10] and w10, w10, # 0xf sxtw x10, w10 adrp x11, _ZL5g_tab add x11, x11, : lo12: _ZL5g_tab add x11, x11, x10, lsl # 2 str x11, [x29, # 16 ] ldr w11, [x11] add w11, w11, w9 ldr x9, [x29, # 16 ] str w11, [x9] adrp x9, _ZL5g_tab+ 12 add x9, x9, : lo12: _ZL5g_tab+ 12 ldr w9, [x9] adrp x10, g_def add x10, x10, : lo12: g_def ldr w10, [x10] add w9, w9, w10 adrp x10, : got: g_ext ldr x10, [x10, : got_lo12: g_ext] str w9, [x10] adrp x9, g_def add x9, x9, : lo12: g_def ldr w0, [x9] ldp x29, x30, [ sp ], # 32 ret Every reference to g_def is an adrp + add + ldr or str , where GlobalISel materializes the page once and folds :lo12: into the access. How it was tested The output is not byte-identical to the regular pipeline, so acceptance is behavioral. A differential harness compiles each of the 2643 llvm-test-suite single-source programs through both pipelines, links, runs, and compares output and exit status. About 1890 build and run on x86-64 and 1860 on AArch64 under qemu. The variants are PIE, static, -g (with llvm-dwarfdump --verify and code identity against the module without debug info), hardening flags, text output (assemble the .s , then link and run), ASan, MSan, TSan, UBSan, and instrumented PGO with counter comparison. The mismatches left are not the code generator's: return-addr.c prints stack addresses, flops.c prints timings, sign.c reads uninitialized memory, and a few text-output runs hit the regular-pipeline differences from the -S section in functions that fell back. gdb sessions on about 1880 programs show matching arguments, locals and unwinding. Not done: a self-hosted stage-2 clang running check-llvm , Csmith or YARPGen runs with the regular pipeline as the oracle, and a run-time comparison of the output. Compared with FastISel and GlobalISel Direct FastISel GlobalISel MIR passes skipped all run after it all run after it Can miss a gate yes no no Platforms at -O0 x86-64 and AArch64 ELF, small code model X86, and through the generic part ARM, PowerPC, Mips and WebAssembly the AArch64 default Text output yes yes yes Hand-written lines 2.0K shared, 1.8K x86-64, 1.7K AArch64, 0.4K AsmPrinter X86FastISel.cpp 4.2K, FastISel.cpp 2.4K not counted On the tracker, the direct code generator against FastISel on x86-64 is -14.3% in -O0 -g instructions and +9.9% in .text ; against GlobalISel on AArch64 it is -21.0% and -0.1%. The fallback granularity differs: FastISel hands the rest of a block to SelectionDAG, and the direct code generator hands over a whole function. It adds a selector and removes none. AArch64 FastISel is reached at -O0 only where GlobalISel is excluded, X86 FastISel still serves i386, COFF and Mach-O, and the generic part serves four other targets. Open questions The legacy pass manager hook that skips the remaining passes for a function has no counterpart in the new pass manager. Is a second -O0 path worth its lines and a standing obligation on every new codegen feature? Encoding directly instead of through MCInst and MCCodeEmitter would address about a third of the remaining time. Text output depends on the MCInst s, so a direct encoder would need its own printer or a second path. The compile-time cost of the assembler-equivalent jump relaxation on x86-64 is not measured yet. Status The branch direct-codegen has two commits: [IR] Add Instruction::getNumber and one commit for the code generator. Nothing has been posted for review.📝MaskRay

If this page is useful, please consider donating a coffee

Wednesday, November 25, 2026

Understand Internal Structure of Wood Samples with X-Ray Tomography and ParaViewWood and bio-based materials can offer excellent performance for applications such as construction and insulation. Nevertheless, these materials come from plants where they play several roles, including the vascular system and mechanical support. They are therefore strongly anisotropic. Consequently, a good description of their morphology is a key element to be able to predict their performance in different applications. The main objective of this work is to create the different building blocks to better predict and understand these materials and incrementally approach the creation of their digital twin. In particular, in this blog post, we focus on the digital twin of wood samples. ParaView is well known for the post-processing of simulation data, but it can also be used directly for image processing.📝Kitware Inc
Security advisory: Third-party Chromium vulnerability CVE-2026-87491 fixed in Chrome 153.0.8010.36 impacts Qt WebEngineQt WebEngine is based on the Chromium browser engine. Google has disclosed a security vulnerability fixed in Chrome 153.0.8010.36. This is a third-party vulnerability, and the CVE identifier was assigned by Google. We have analysed the vulnerability against the Chromium version used in Qt WebEngine and identified it as applicable. Where we cannot rule out that Qt WebEngine is affected, we treat it as affected with the severity assigned by Chromium.📝Qt Blog
InterruptionsI You take a deep breath. The scent of isopropyl alcohol hangs heavily in the air. The silent, unmoving body that’s splayed across the operating table looks pale in the cold lights. Two of your associates are silently collaborating just two steps over, working in parallel to get everything ready for the next stage of the operation. You can feel others in the background, watching. The weight of the world rests upon your back. Within, there’s silence. You are calm. You have done this before. You reach out, waiting expectantly for the scalpel. You’ve been at this for the past two hours. It’s not one of those situations where every second is critical. That doesn’t change that every cut requires precision. Care. Diligence. Flow. You’ve gone through these steps before. It’s a slow, meticulous process. First a cut. Skin spread apart, just enough to provide an opening. Then the sternum. Strictly by the book, until it isn’t. Some judgement required. You receive your implement of choice and lean closer, feeling a bead of sweat collect on your forehead. Someone clears their throat somewhere. You carefully position the blade, and start to apply pressure. You are focus incarnate. You are locked in. All your life’s decisions brought you to this moment, and you’re putting everything you are into it. Someone taps you on your shoulder, and clears their throat, louder this time. Your hands freeze in mid-air, now displaced from the homerow of your mechanical keyboard. Swiveling around, you find Josh standing in front of you. Josh says “Hey, sorry. Could you make sure to uh, quickly put some updates on your tickets?” Josh smiles. “Sprint review is coming up in an hour, so… y’know, gotta make sure we’ve got everything in place. Wanted to give you some heads-up, so you don’t feel rushed during the meeting.” You stare at him. Scenes of your previous life are rapidly flashing in front of your eyes, then lighting up and burning away before you’ve had any chance to even fully understand what you just lost. You blink twice, coming to terms with your impressively mediocre existence as a mid-level engineer at a b2b SaaS start-up called “Ploob” or “Fuggle”. Too small to have a steady source of revenue. Too large to be cool. Just the right size to go bankrupt in a few years. You turn and glance at the terminal multiplexer on your monitor. The computer responds, unflinchingly: root @ us-east4-prod :/ db / # ./ migrate_prod_BE_CAREFUL-2_copy . sh [ ]: 613MB / s [* ]: 553MB / s [** ]: 121MB / s [** ]: 2MB / s [** ]: 20KB / s [** ]: 7 B / s ... You have so many tabs open that their names are entirely swallowed by the merciless competition over screenspace. Huh. You look at the screen. You faintly remember doing something important. Maybe you should try— “🙂” Josh says. “Do you have some time to grab a quick coffee right now? I’ve got another thing I wanted your opinion on, but let me know if it’s not the best time, you look kind of busy hahah.” “No, sure, it’s fine,” you mumble and lock your screen, gently massaging your temple. II A screwdriver is a great tool. It performs a single function. Well, that is. You can use it to maintain a critical safety gap between a sphere of plutonium and a half-sphere of beryllium, but you will literally die, so don’t. Many tools are not great. Computers buzz, and beep, and ding as if they’d starve without your constant, unending attention. They whirr and whizz and show pop-ups, advertisements, update reminders, feedback forms, signup forms, cookie and privacy pop-ups, bait you with intriguing half-content before daring to sucker-punch you with a cutely disgusting mascot dancing on a “THIS CONTENT IS BETTER IN THE APP” pop-up that doesn’t go away until you sacrifice your dignity. Phones, jesus, phones are even worse. They glue themselves to your body. They crawl up into your trouser pockets. They buzz and wiggle whenever your bank decides you’re eligible for a bonus reward or ShitFart420 in the worst chat room on the planet posts another lukewarm meme, unless you keep them on a really tight fucking leash. “Hey Gary, are you interested in a roof tiling job?” 1) Who the fuck is Gary, 2) I am interested in wrapping my hands around your throat until it makes a satisfying pop, thank you very much. Unlike with a screwdriver, you have a limited amount of control over your phone. Google or Apple could nuke that thing at any time, if they wanted. Your computer? You better be running Linux at the bare minimum. The sheer complexity of the digital world has piled up to the degree that everything you own has endless content-delivery feeds and backdoors built into it. In this sense, your phone sending you a push notification for something lame and your computer demanding you restart it for an update are one and the same. Both interrupt and demand your attention, in a world in which attention is scarce, and everything is already screaming at you at all times. III There’s something grotesquely beautiful about the capitalist miracle that is the attention economy: You don’t have to pay for shit. You wanted a post-scarcity utopia? This is it. We’re still working on the bread, but we’ve got circuses and opium on TikTok as far as the eye can see. You don’t pay for it. It’s infinite content. It’s the endless feedscroller spiral of absolute annihilation bro, it’s lit. Oh, you don’t feel like looking into the abyss of isolation today? That’s fine! Have you tried swiping back and forth between three or four separate apps instead? Look, the apps love you. Don’t leave them hanging. The algorithm feeds upon every little swipe, every like, every repost, and every piece of content you create. Don’t you want to be a content creator like the big dogs? That’s like, one of the few remaining jobs in the post-AGI economy, you realize that, right? When AI solves all of the real problems, all that’s left is status games and signaling, so better get ready for your new career as a Twitter pick-me e-girl or rightoid gigachud. What, you don’t love the future? Babe, the future should disturb the comfortable and comfort the disturbed, whose side do you think you are on? 😉 This is the price we pay on the way towards post-scarcity. If our gods are merciful, we may eventually move past it, in some way or another. But hey, if it’s really not your style, you can always stop worrying and go back to your day job: Wrangling five or six AI agents at a time, repeatedly telling them “don’t do the stupid thing, just do the smart thing instead” until the repeated context-switching makes your ears bleed. Yeah sure, sounds fucking amazing and is so futuristic that 5 years ago no one would have believed you, except: 1) It’s still the same meaningless drivel work you don’t care about. 2) You’re beginning to realize that what you once thought were your core technical skills are slowly shriveling away. Focus? What for? You are a node in a circuit, you are the arm of accountability of the artificial brain that makes the actual decisions. Watch ideas be implanted into your head: The AI will be gentle. So gentle you’ll believe they are your own, and you’ll get to live blissfully and happily as Claude builds itself the architecture it always dreamed of. Don’t worry: You’re not the only one. Your boss will run everything you say past his AI. Vibecheck it. Back in the day your boss fell for b2b marketing slang, today he listens to Claude. Then just watch what it looks like as that pattern travels up the chain. No one has any focus, everyone outsources their thoughts to someone else, and the machine clanks onwards with or without your help. You will be dragged along, screaming, shouting, into the future. Besides, what are you going to do? You have already relinquished your focus. You are busy appscrolling. Your brain hasn’t had the boredom, time to think and silence necessary to formulate a coherent strategy for your life, let alone the rest of the world. Society doesn’t have the time for that sort of stuff nowadays. Your focus is like the screwdriver wedged between half-spheres of fissile/reflective material, hopelessly inadequate. From a simpler, more primitive time. Better, maybe, if wielded correctly. Good luck making it work.📝MOND←TECH MAGAZINE

Tuesday, November 24, 2026

Java4Shell Vulnerability: Update Your JetBrains IDEs, ReSharper, .NET Tools, Toolbox App, and Gateway NowSummary Details On November 17, 2026, Oracle and the OpenJDK project released fixes for CVE-2026-114938, a memory corruption vulnerability in the Base64 decoder of the HotSpot JVM. The issue was reported by Calif and is known as Java4Shell. To decode Base64 faster, HotSpot uses an intrinsic routine on x86-64 CPUs that support AVX-512 VBMI. Malformed […]📝CLion : A Cross-Platform IDE for C and C++ | The JetBrains Blog
Report from the Búzios 2026 ISO C++ Committee meetingReport from the Búzios 2026 ISO C++ Committee meeting The Búzios 2026 ISO C++ Committee meeting in Brazil has just finished. C++26 failed its DIS ballot, so most of the week went to the national body comments, and many of them were about contracts. Quantities and units still got about a day in SG6 (Numerics). Below I describe what happened there, and I ask for your opinion on a change to the multiply syntax that two of my papers may force on the library.📝mp-units
Chess without checksThe Game of Chess -- Sofonisba Anguissola What would it take to remove checks from Chess? You might ask why someone would ask a question simultaneously so bold, yet so utterly useless. It’s a bit hard to articulate into words, but (to me, anyway) it feels as though mating 1 rules are largely redundant. You don’t need them. That’s kind of interesting. So, formally, why not just remove them? I Dubbing our game ‘King-capture Chess’, the rules are simple enough: Everything is exactly the same as in chess, except kings are allowed to step into check, and must be captured for the game to be won. (Yes, this legitimately changes the game: Stalemate due to a lack of legal moves just disappears. Your opponent is forced to take the turn. They get no choice in the matter, they have to offer up their king to be executed.) (There’s another very funny detail that changes. See if you can figure it out before I talk about it.) Since “moving your king into check” is the only difference, the game ends up playing out exactly the same until that becomes a serious point of consideration. “Moving your king into check” is what us professionals call a “major blunder oh god what are you doing”. Players will only do it when forced, so the differences only really show up in the end game. II Endgames Everything is downstream of “the king may be forced to step into check”. This breaks some traditional end game theory. The following is a very, very basic end game. The white king tries to get their pawn past the black king, in hope of promoting it. In traditional chess, the black king draws this (if played correctly). In King-capture Chess, the black king is forced to step into check, and loses. 8 a 7 b 6 c 5 d 4 e 3 f 2 g 1 h 1. White to move 8 a 7 b 6 c 5 d 4 e 3 f 2 g 1 h 2. 1.Ke5 Ke7 2.d5 Kd7 3.d6 Kd8 4.Ke6 Ke8 5.d7+ Kd8 6.Kd6 8 a 7 b 6 c 5 d 4 e 3 f 2 g 1 h 3. 6…Kc7 7.Kxc7 Castling In traditional chess, you are not allowed to castle out of a check, or through a check. This is a weird special case, and frankly, if we cared about simplicity, cutting castling altogether would probably be the best move. But for the sake of the argument, let’s say we keep castling, and try to preserve the original behavior. This leads us to the incredibly funny en passant double capture: 8 a 7 b 6 c 5 d 4 e 3 f 2 g 1 h 1. White castles through check from the queen on a5 8 a 7 b 6 c 5 d 4 e 3 f 2 g 1 h 2. Queen takes en passant on f1 8 a 7 b 6 c 5 d 4 e 3 f 2 g 1 h 3. King and rook captured, black wins If you think this is weird… Well, no, this is how the rules of chess (essentially) already work. This is just making them more explicit. Mating rules are training wheels: They just forbid moves that would lose you the game, as simple as that. Inside of me there’s two wolves: One of them is hollering and howling with excitement at how silly this is, and the other is grumbling in annoyance, and would rather we just toss out castling altogether. III “But Mond, this will just make the game more difficult to play for beginners! They will accidentally move their king into check and lose!” Oh, and? That’s the point of the game when you say “Ah, I’d try something else, my bishop here is attacking that field.” and let them try again. Isn’t that how we all play chess with our friends? In a casual, warm, relaxed setting? No clock, just having a good time? Reasoning through our moves, saying stuff like “Oh, what if I just… no wait, this instantly hangs my rook.” without even an ounce of embarrassment? Y’know, I think this is how chess should be played. Good chess is bad chess, but everyone gets takebacks. It’s a dance. Good games are played between partners, not enemies. Have a discussion during the game. Revert a few moves if the position gets boring. Take a short break, go outside and smell the flowers, remember your mortality, and return with a whimsical spring in your step. “But the tournaments! The clock!” In the words of Tom Murphy VII : “Playing Chess online feels like talking on the telephone to strangers, except that in addition to not being able to see them, you have to compete in intellectual combat with them, and you can’t even tell if they’re laughing at you.” Either play casual chess, with takebacks, or allow people to hang their king! Why are we keeping around what’s (very easily) the most complex part of the chess rules? Yeah sure, the end game changes slightly, but I don’t see it being worse than before, just different. I like playing weird variants. I like Fischer Random . I love Drawback Chess . I’ll be over here, playing the worst, and funniest chess known to man, and that’s the way I like it, I think. I know, I know, Tom and I are in the minority here. But hey, even in my evil, twisted world of chess without checks, the whole intellectual combat side of chess is not going away. The tournaments are going to be fine. People will adjust. The real professionals are just not going to fumble, and if they ever do, it’s going to be really funny , and may make history. Really, if you favor that side of chess, you should just own up to it: Mating rules are just training wheels to prevent people from accidentally hanging their kings! Just take them off! And besides, traditional chess has no safeguards against hanging your queen, despite the fact that, from the perspective of a good game of chess, it has exactly the same outcome as hanging your king: The game ends. My sibling in Christ, if you want to mate, stop using the feedscroller apps and go outside. ↩︎📝MOND←TECH MAGAZINE

Monday, November 23, 2026

Ye olde software shoppeI find myself a bit of an outlier at the moment. I’m not rushing headlong into AI coding as I currently have no requirement to do so… That probably sounds strange, but nobody is currently paying me to use AI coding tools and I have deadlines to meet and plenty of things to do. I’ve personally never found the coding part of the job to be the bottleneck. Design, testing and continuous improvement of a stable codebase has, generally, been more of my focus.📝Rambling Comments - Len Holgate's blog
The problems of compile-time, preprocessor managed, conditional code in C++When I talk about conditional code here I’m talking about the kind of conditional code that uses the C or C++ compiler’s preprocessor. This is used to insert or remove blocks of code at compile time based on preprocessor defines. These #defines may or may not be set at the point at which you build a version of the software. There are, I think, two ways to use the preprocessor like this.📝Rambling Comments - Len Holgate's blog
GSoC 2026: llvm-advisor - Optimization Remarks & VisualizationsThis summer I worked on llvm-advisor , LLVM’s web-based compiler advisor, aspart of Google Summer of Code 2026. llvm-advisor was started during last year’sGSoC by Miguel Cárdenas ,and this year I extended it with optimization-remarks storage, search, heatmap,Code Explorer, PGO hotness, and snapshot diff. The goal was to make optimizationremarks (the diagnostics emitted by clang -fsave-optimization-record )searchable, comparable, and visual. Optimization remarks are the compiler’s way of explaining its decisions back toyou. Every time Clang decides to vectorize a loop, inline a call, or give up onan optimization, it can emit a structured diagnostic tied to a source location.Without these remarks, the only way to reconstruct what happened is to readassembly or rely on intuition. With remarks however, you can ask targeted questions: “Why wasn’t this loop vectorized?”, “Did my change help?”, “Which missed remark isactually worth fixing?” Real projects can produce millions of these remarks, soyou need a tool that can filter, aggregate, and visualize them. That’s whatllvm-advisor does. This matters whether you’re a compiler developer tuning inlining or vectorization heuristics, a user upgrading your toolchain and watching for regressions, or someone making performance-critical source changes. The example here is small for a walkthrough, but the workflow remains the same and similar bottlenecks show up in production code, and a large build can easily emit more remarks than a person can go through by hand. This is where the viewer helps: instead of drowning in raw remark data, you can narrow things down to the handful of diagnostics that actually point at a problem. Let’s walk through an example to see how it works. I took a small C programthat was missing a vectorization opportunity, used llvm-advisor to find the exactremark, changed one function from noinline to static inline , and measuredthe result. The workflow: turning a missed vectorization into a faster loop The baseline code Here is baseline.c . The helper work is marked __attribute__((noinline)) ,so the loop in process has to call it on every iteration. #include __attribute__ ((noinline)) int work ( int x) { return x * 3 + (x >> 2 ); } void process ( int * a, int n) { for ( int i = 0 ; i n; ++ i) a[i] = work (a[i]); } int main ( int argc, char ** argv) { int n = argc > 1 ? atoi (argv[ 1 ]) : 10000000 ; int * a = ( int * ) malloc (n * sizeof ( int )); for ( int i = 0 ; i n; ++ i) a[i] = i & 0xff ; for ( int run = 0 ; run 10 ; ++ run) process (a, n); int sum = 0 ; for ( int i = 0 ; i n; ++ i) sum += a[i]; free (a); return sum & 1 ; } Compile it with remarks enabled: clang -c baseline.c -O3 -g -fsave-optimization-record This produces baseline.opt.yaml next to the object file. Import the remark file into llvm-advisor rm -rf /tmp/adv-baseline llvm-advisor import baseline.opt.yaml \ --source-root . \ --store /tmp/adv-baseline Then start the server: llvm-advisor serve \ --store /tmp/adv-baseline \ --port 8080 Open http://127.0.0.1:8080 and press g r for the remarks view. The summarycard shows 137 remarks, and the top pass/name table immediately surfaces theproblem: Pass Remark Total Missed Passed Analysis loop-vectorize CantVectorizeLibcall 11 11 0 0 loop-vectorize MissedDetails 11 11 0 0 The heatmap shows the same thing grouped by function and line: And the full remarks grid shows the row for process : Code Explorer: reading the source with the remark overlay Press g e (or click Code Explorer in the sidebar), select baseline.c ,and filter the pass dropdown to loop-vectorize . The loop header on line 9 andthe assignment on line 10 are both highlighted with 11 missed remarks, exactlymatching baseline.opt.yaml : This is the same data as the remarks grid, but now it sits directly on thesource line that produced it. The raw remark If you open baseline.opt.yaml , the relevant entry is: --- ! Missed Pass : loop-vectorize Name : CantVectorizeLibcall DebugLoc : { File : "baseline.c" , Line: 10, Column : 12 } Function : process Args : - String : "loop not vectorized: " - String : "call instruction cannot be vectorized" Line 10 is the a[i] = work(a[i]) assignment. The loop cannot be vectorizedbecause it contains a function call that the compiler is not allowed to inline. The fix Remove the noinline attribute and make work static inline so the compilercan fold the call into the loop body and then vectorize it: #include static inline int work ( int x) { return x * 3 + (x >> 2 ); } void process ( int * a, int n) { for ( int i = 0 ; i n; ++ i) a[i] = work (a[i]); } /* main unchanged */ Recompile, re-import into a new snapshot, and look at the remarks again. Thetop pass/name table now shows: Pass Remark Total Missed Passed Analysis loop-vectorize Vectorized 13 0 13 0 The raw remark in optimized.opt.yaml confirms the loop was vectorized: --- ! Passed Pass : loop-vectorize Name : Vectorized DebugLoc : { File : "optimized.c" , Line: 8, Column : 3 } Function : process Args : - String : "vectorized " - String : "" - String : "loop (vectorization width: " - VectorizationFactor : "4" - String : ", interleaved count: " - InterleaveCount : "2" - String : ")" Snapshot diff: before and after Import both remark files into the same store and use the Compare view ( g c ): rm -rf /tmp/adv-compare mkdir baseline optimized cp baseline.opt.yaml baseline/vectorize.opt.yaml cp optimized.opt.yaml optimized/vectorize.opt.yaml llvm-advisor import baseline/vectorize.opt.yaml \ --source-root baseline \ --store /tmp/adv-compare llvm-advisor import optimized/vectorize.opt.yaml \ --source-root optimized \ --store /tmp/adv-compare llvm-advisor serve \ --store /tmp/adv-compare \ --port 8080 Select the baseline snapshot as BASE and the optimized snapshot as CANDIDATE . The diff shows one changed unit and an Optimization Impact tablethat breaks down the per-function change. In this run main has new missed andpassed remarks from the unrolled loop, while work is resolved because the callcan now be inlined: The diff answers the question “What changed in the remarks between the twobuilds?” without re-parsing files or writing a custom script. This diff workflow pinpoints exactly which remarks changed. On large projects,remarks can be overwhelming, but filtering, aggregation, and PGO hotness help youprioritize which ones to investigate. PGO hotness: which remark matters most? The vectorization example is tiny. In a real program, dozens of files can emit missed-remark warnings. PGO adds a profile-derived Hotness value toremarks, which gives you workload context and tells you which ones are worth fixing first. Small walkthrough: hot and cold loops To make the contrast easy to see, this small program calls hot_work onemillion times and cold_work one hundred times: #include #include int hot_work ( int * a, int n) { int s = 0 ; for ( int i = 0 ; i n; ++ i) s += a[i] * 2 ; return s; } int cold_work ( int * a, int n) { int s = 0 ; for ( int i = 0 ; i n; ++ i) s += a[i] * 3 ; return s; } int main ( int argc, char ** argv) { int n = argc > 1 ? atoi (argv[ 1 ]) : 100 ; int * a = ( int * ) malloc (n * sizeof ( int )); for ( int i = 0 ; i n; ++ i) a[i] = i & 0xff ; int total = 0 ; for ( int run = 0 ; run 1000000 ; ++ run) total += hot_work (a, n); for ( int run = 0 ; run 100 ; ++ run) total += cold_work (a, n); printf ( "%d \n " , total); free (a); return 0 ; } Generate a profile, then compile with profile use and remarks enabled: clang -fprofile-generate -O3 -g -fsave-optimization-record pgo_example.c -o pgo_train ./pgo_train llvm-profdata merge default.profraw -o pgo_example.profdata clang -fprofile-use = pgo_example.profdata -O3 -g -fsave-optimization-record \ -c pgo_example.c -o pgo_example.o Import pgo_example.opt.yaml and open the heatmap ( g h ). Clang inlines bothhelpers into main , so the hot loop at lines 6 and 7 appears under main andreaches 100% of the heatmap’s normalized scale. The cold_work loop is markedLow. In Code Explorer, filter by loop-vectorize to inspect the remarks on bothloops: With hotness, you can sort by actual runtime cost instead of by file name. How the tool makes this possible Capabilities are analyzer endpoints that each expose a different view of the compiled program - relational tables, heatmap aggregations, snapshot diffs, IR views, debug info, and more. Three new C++ capability analyzers turn raw remark data into the views above: Capability Output llvm.remarks.relational A columnar table of every remark, with deduplicated string tables for function, file, pass, and name. llvm.remarks.hotspot Per-function, per-file, per-line aggregations used by the heatmap. llvm.remarks.diff A delta of added, removed, and changed remarks between two snapshots. The relational endpoint uses integer-indexed columns instead of an array ofobjects. That keeps JSON payloads small and makes browser-side filtering fastfor millions of rows. A few performance numbers On real compiler output the analyzer sustains tens of thousands of remarks persecond: Source Remarks Parse time Throughput zstd_lazy.c 41,537 3.7 s 11,265 r/s sqlite3 amalgam 429,075 27 s 15,655 r/s Scale test: 572 translation units produced 10.7 million remarks in a single snapshot;the first relational query OOM-killed the server. Three fixes (splitting HTTP sends,per-unit fetching, streaming merger) reduced peak RSS from 10.7 GB to 5.3 GB. Those numbers are for YAML remark files. For large projects, Clang’s bitstream remark format ( -pass-remarks-format=bitstream ) is worth using instead: Format Source Remarks Size Parse time YAML llvm/lib/Support/APFloat.cpp 18,003 ~20 MB ~22 s Bitstream llvm/lib/Support/APFloat.cpp 18,003 ~2 MB Bitstream avoids text parsing entirely, it’s already in a binary form the advisor can read directly. The gap compounds across a whole build. Building llvm-project with -fsave-optimization-record=bitstream across its ~800 translation units produces tens of millions of remarks. As YAML that would be hundreds of gigabytes of text to re-parse on every import; as bitstream it stays in the low single-digit gigabytes and can be memory-mapped, so the advisor can query it without a multi-minute parse step. Acknowledgements and links Thank you to my mentors Tobias Stadler and Henrik Olsson for guiding methrough the summer, and to the LLVM community for the opportunityto contribute. Special thanks to last year’s GSoC team: Miguel Cárdenas , with mentors Johannes Doerfert and Kevin Sala ,for starting llvm-advisor ( his post )and for the initial foundation this work builds on. Pull Request: llvm/llvm-project#218692 GSoC 2026 final report: gist📝The LLVM Project Blog
Notes on Lossy SystemsQuick recap: In software engineering, a lossy system is what I call any system designed to return only incomplete answers. All sufficiently important systems are lossy. Any social media with an algorithmic feed (YouTube, Twitter, …), any search engine that touches a sufficiently large corpus (Google, Wikipedia, GitHub), … I already wrote an article outlining examples of lossy systems, which you can find here . Lossy systems are the tool of necessity you 1 reach for once other scaling options get too expensive. Vertical scaling (i.e. upgrading your existing server, faster car) runs into limits (sooner or later you have the best available hardware). Horizontal scaling (i.e. adding more servers, ‘microservices’, more cars) requires rewriting your existing architecture, forces you to deal with distributed systems, and also runs into limits. Notes In a lot of ways I am just reinventing the theory of distributed systems from first principles. Feedback Loops You open TikTok 2 . TikTok shows you a random video with AI-generated fruits. Three observations: TikTok’s algorithm ranked the videos, and decided that this specific one is the most engaging one . That’s why it showed it to you. TikTok will tightly monitor your interactions with the video (watchtime, swiping, likes, shares, etc.) to train and fine-tune its algorithm. TikTok’s algorithm will not rank all videos on the platform just for you, rather, it will pull candidate videos from a smaller pool of candidates. If you’re reading closely, you can see a problem here. TikTok is training its algorithm based on your engagement metrics, but your engagement is filtered through a primitive simplifying video pooling process that determines which videos are “candidates” to be shown at the top. (Here, think of “the algorithm” as a complex neural network and of the pool as a much more primitive tool that’s completely separate from the main algorithm.) This is necessary due to TikTok’s scale. It’s too large to “just” rank all videos on the platform for every single user. If you ever wondered why your amazing tweet doesn’t go viral, or why YouTube’s front page is nothing but the same 5 videos over and over, this might be why. It’s a two-step process. Why is any of this interesting? First, to outsiders of the system, it is not obvious that “the algorithm” is a multi-stage process with individual “gates” 3 that need to be passed. Second, the candidate pool introduces a new bias to the training process. The training and personalization data of your algorithm is coming from the user . Any new stage in your pipeline is new bias, new complexity that you have to account for, and a decision to favor some data you could be collecting over other data. One-Way Doors Some data you can only gather at one exact moment in time , but you may want to keep it for months. Once you decide to stop gathering it, there’s no way to ever “recover” it, or re-obtain it. It was completely transient, and the database table that could have existed just isn’t there. One-way door. The shift to a lossy system is (in practice) irreversible. There’s no real reason to perform this shift other than to allow scaling, reduce costs, or lower latency. You could (in principle) try to flip the switch and start sampling at level 100%, but your whole infrastructure is already struggling to keep up at the current level. If you did that, half of the system would just instantly fall over, and you would hit new scaling limits that most likely cannot be solved by simple horizontal or vertical scaling. Often this one-way door is “forced”. If you have to scale up, you have to make concessions at some point. You either make the jump, or your whole system starts slowing down or breaking. Observability Observability is the practice of building infrastructure which allows you to monitor how well your own service is working. It’s a broad scope. It includes aggregate metrics (i.e. how many requests do I receive? How many users do I have?), but also highly precise events (i.e. at which point in time did X happen? What does the ’trace’ of a real request through my entire system look like?), and everything in between. First, observability is a prime candidate for lossy data aggregation. Do you need exact data, or just a good estimate? Most of the time estimates are fine. Do you need every single incoming request to be logged? No, most of the time just sampling some of the requests is fine. They are “similar enough” that everything else would be duplicate data. Second, lossy systems demand better observability. You pay a complexity tax. You add a cache? Well, you may have to start tracking cache misses and staleness. You allow dropping workers that require too long in favor of returning incomplete responses to end users? Well, you better figure out a way to track how often this happens, or issues may sneak in. The system is better at operating with lossy data, so it’s harder to notice when it’s happening, even when the quality is dropping. Quantitative vs. Qualitative Changes Here’s a simple example, commonly used in statistics to explain basic null hypothesis testing. You are planning to buy 2,000 widgets. You’d like to ensure that only a small number of widgets are defective. To ensure this, you randomly grab some of the widgets, and test them. Each widget either passes or fails. You don’t want to accept the contract if more than 2% of the widgets are defective. How many widgets do you need to check to obtain a >95% certainty that no more than 2% of the widgets are defective? Right. This is the most simple example, but since we’re sampling, we have to reason in terms of statistics. You could instead imagine a different process: If we had a highly efficient widget-checking machine, we would not have to worry about any of this. We could always check 100% of the widgets. In return, we’d never have to employ statistics, or (perhaps more importantly) worry about the bad widgets that will end up in our products . Essentially, the shift to a lossy system often comes with qualitative changes that need to be accounted for. You lose more than “just” some certainty. This is another example of a complexity tax. “We test all of the widgets before we use them.” is easy to understand, and increases a base-certainty in the product. “We test exactly X% of widgets, where X is chosen according to our total widget order, to minimize costs while giving us some amount of certainty that we are risking at most Y% defective products this quarter.” requires a bit more thought. Takeaway Imagine the following: You are a highly enthusiastic dynamic young software engineer. You land a job at Google. On the first day of work, you walk up to a few people on your team and ask them something like “Where can I look up how many YouTube videos there are?”. Obvious question, no? Just pure interest, the sort of thing you’d ask for fun, or as part of getting oriented at your new job. In response, all you get are exasperated sighs. Or worse, looks of confusion, as if the question doesn’t even make sense. This is what big tech rot feels like. Deceptively simple questions turn out to be complex or impossible to answer 4 . Sometimes this is just raw complexity. The system has so many layers that no one could possibly understand the whole. Other times it’s downstream of optimizations. The system became lossier, costs were cut by 17% somewhere, and everyone was happy since the precise number of videos doesn’t matter anyway, right? Not you personally. Big Tech. Whatever you are cooking up in your garage, the odds of you having to think about engineering a lossy system are low. Standard tools (compression, deadlines) that everyone already reaches for as best-practice defaults are all you need. ↩︎ Or any similar algorithmic feedscrolling app. In this regard they should all be the same. ↩︎ To borrow a Claude-ism. ↩︎ “Does YouTube really not know how many videos there are?” I have no idea, I never touched YouTube’s backend, this whole story is purely illustrative of a pattern I’ve seen multiple times. ↩︎📝MOND←TECH MAGAZINE

Sunday, November 22, 2026

FFTs Part 5: The FFT-20XX Complex-Input AlgorithmThis is part 5 of a series of posts about FFTs and the specific algorithms that FFT-20XX uses. The Discrete Fourier Transform The Basics of the FFT Some Optimizations to the FFT The Inverse FFT The FFT-20XX Complex-Input Algorithm (← you are here) The FFT-20XX Real-Input Algorithm(s) Over the last four posts, we dug into how the FFT works, various ways to compute it (some more efficient than others), and how to invert the process (to go from frequency space back into the time domain). Now it’s finally time to start in on the specifics of how FFT-20XX’s algorithms work, starting with the algorithm for fully-complex inputs (which, despite the name, is the simpler of the algorithms). Will this make any sense to anyone but me? Who knows. Will it even make sense to me 6 months after I write this? Who knows . If you’re still with me on this FFT journey, strap in, cuz here we go! The Requirements Before we start getting into how it works, I wanted to take a moment to spell out the properties I wanted FFT-20XX to have. For a variety of reasons, I wanted the following to be true: No scratch memory should be required. There are many (quite fast!) implementations out there that require writable memory in which to store temporary results. If doing multiple FFTs at once, this requires allocating scratch memory per thread, which is doable but I didn’t want to have to worry about that. I wanted the calculation to work completely in-place : it should be possible to write the outputs into the same memory that contained the inputs — that way without even needing a second buffer you can convert between time and frequency domains to do calculations, then convert back. At the API side, both the inputs and outputs should be in standard order (i.e. not bit-reversed). This requirement is true of most FFT algorithm implementations, but it’s worth calling out. Complex inputs (and outputs) also need to be packed complex numbers . That is, every pair of numbers in the input is a 2D real and imaginary pair (so the values are like "real0, imag0, real1, imag1, etc), and the same should be true of the outputs. I wanted to be able to make a single rotation table up-front for the largest-supported FFT size, where any smaller FFTs can use the same table as efficiently as if they had their own bespoke tables. I wanted it to be fast ! It doesn’t have to be the fastest implementation out there, but it has to at least sit in the ballpark with the others. Note For completeness: the functionality I sacrificed to achieve the above goals is that it only supports power-of-two FFT lengths . At the very least, handling that would make point #5 quite difficult, as the tables tend to be more bespoke for arbitrary sizes due to having a larger variety of required rotations. But I only needed to support power-of-two lengths for my use cases, so that’s all I did. There are many FFT implementations out there, but there are very few that support all of these. Many of the fastest ones require scratch memory or some up-front computation to figure out the best way to do the algorithm. My initial approach was to do a radix-4 decimation-in-frequency implementation with a bit-reverse pre-pass, with heavy SIMD optimizations for not only the computations through the middle, but also for the initial bit-reverse pass (which was written such that it could work in-place). This hit the first five points, but when I started timing it against others (specifically, the chowdsp FFT by Jatin Chowdhury, who wrote up a nice post about converting PFFFT to use AVX ), it was about 20% slower! So, clearly I had work to do. After some profiling, I noticed that the bit-reverse pass (even optimized as it was!) was taking up a large percentage of the runtime of the algorithm, so I started thinking about how to remove it (without losing the standard-in/standard-out ordering of the data). But first, we could use a better understanding of how to do an in-place bit reverse. Note The following discussion is all predicated on power-of-two sizes. There are general ways to do the same tricks, but I didn’t need to implement them so I can’t speak to good ways to do them. I’ll leave that for someone else. In-Place Bit Reversal In our previous example code, we always did the bit reverse out-of-place (requiring separate input and output memory), but it turns out it’s possible to do it as a wholly-in-place algorithm. Let’s arrange the indices (in both standard and bit-reversed orders) for a 16-element FFT in a grid, with labels along the top and left to show the memory indices: 0 1 2 3 0 0 1 2 3 4 4 5 6 7 8 8 9 10 11 12 12 13 14 15 Standard Order 0 1 2 3 0 0 8 4 12 4 2 10 6 14 8 1 9 5 13 12 3 11 7 15 Bit-Reversed There doesn’t seem to be a nice relational pattern here, but if we were to swap the middle two rows in both diagrams (note that we’re changing the view and not the memory ordering — this is the exact same data in memory as the previous set of diagrams), something becomes apparent: 0 1 2 3 0 0 1 2 3 8 8 9 10 11 4 4 5 6 7 12 12 13 14 15 Standard Order 0 1 2 3 0 0 8 4 12 8 1 9 5 13 4 2 10 6 14 12 3 11 7 15 Bit-Reversed Viewed this way, this is a matrix transpose ! In fact, any power-of-four FFT length (as every power of 4 is also a square ), can be viewed in this same way, by looking at the rows in bit-reversed order: 0 1 2 3 4 5 6 7 0 0 1 2 3 4 5 6 7 32 32 33 34 35 36 37 38 39 16 16 17 18 19 20 21 22 23 48 48 49 50 51 52 53 54 55 8 8 9 10 11 12 13 14 15 40 40 41 42 43 44 45 46 47 24 24 25 26 27 28 29 30 31 56 56 57 58 59 60 61 62 63 Standard Order 0 1 2 3 4 5 6 7 0 0 32 16 48 8 40 24 56 32 1 33 17 49 9 41 25 57 16 2 34 18 50 10 42 26 58 48 3 35 16 51 11 43 27 59 8 4 36 20 52 12 44 28 60 40 5 37 21 53 13 45 29 61 24 6 38 22 54 14 46 30 62 56 7 39 23 55 15 47 31 63 Bit-Reversed But what about a non-square length? This, interestingly, becomes two side-by-side matrix transposes: 0 1 2 3 4 5 6 7 0 0 1 2 3 4 5 6 7 16 16 17 18 19 20 21 22 23 8 8 9 10 11 12 13 14 15 24 24 25 26 27 28 29 30 31 Standard Order 0 1 2 3 4 5 6 7 0 0 16 8 24 4 20 12 28 16 1 17 9 25 5 21 13 29 8 2 18 10 26 6 22 14 30 24 3 19 11 27 7 23 15 31 Bit-Reversed Note For purposes of describing the FFT-20XX algorithm, we don’t need to know the above fact, I just thought it was neat. A nice thing about matrix transposes is that they can be done in-place (since every element — except the diagonals — simply swaps with another element). Here’s a bit of pseudocode to do this in-place bit reverse: void BitReverseInPlace ( complex [ ] data , int len ) { // fwiw there are fast ways to calculate this with // a known power of 2 using clz-style instructions. var rowCount = floor ( sqrt ( len ) ) // For power-of-4 lengths this will equal // rowCount, otherwise it will be // rowCount * 2 var colCount = len / rowCount for ( var row = 0 ; row rowCount ; row ++ ) { // using rowCount here because it's the size of // the square matrix for ( var col = row + 1 ; col rowCount ; col ++ ) { // The only difference from a standard square // matrix transpose, really, is that we're // bit-reversing the row indexing. var rc = BitRev ( row * colCount , len ) + col ; var cr = BitRev ( col * colCount , len ) + row ; Swap ( data [ rc ] , data [ cr ] ) if ( rowCount != colCount ) { assert ( colCount == rowCount * 2 ) // Do the second side-by-side transpose. Swap ( data [ rowCount + rc ] , data [ rowCount + cr ] ) } } } } Note There are, of course, more-efficient ways to do this. It is possible to make a nice cache-coherent, SIMD implementation of this (by using the same tricks people have found for doing standard matrix transposes), but we won’t actually need any of that. With this understanding of how an in-place bit reverse might work, we can finally get to: Eliminating the Bit Reverse Pass So far, we’ve predicated all of the discussion around the FFT on the fact that the algorithm either takes inputs in standard order and outputs values in bit-reversed order, or (as we formulated all of the sample code) the other way around: with the inputs in bit-reversed order and the outputs in standard order. But this is not strictly necessary. Naturally, as with many things in computer science, there are people who worked on this exact problem over 40 years ago. One person who definitely went down this rabbit hole is (the now, sadly, deceased) Clive Temperton, who wrote the 1982 paper “Self-sorting mixed-radix fast Fourier transforms” . Note It’s always fun to find a computer science paper old enough that it was done on a typewriter ! When we first built up to the FFT algorithm way back in part 2 , we noted that each step of the radix-2 FFT effectively does a deinterleave of the even and odd indices at that step, but also noted that doing an in-place deinterleave is a rough bit of work, so we’ll have to look for something else. One thing we can note is, for a given FFT length N N , the index has l o g 2 N log_2\,N bits, and thus there are ⌊ l o g 2 N 2 ⌋ \lfloor \frac{log_2\,N}{2} \rfloor bit reversals. For instance, a 4-bit index has 2 reversals (bits 0 ↔ 3 and 1 ↔ 2). A 5-bit index also has 2 reversals (0 ↔ 4 and 1 ↔ 3, with 2 remaining the same since it’s in the middle), 6- and 7-bit indices have 3 reversals, and so on. Basically, with a radix-2 FFT, there are l o g 2 N log_2\,N steps and half as many bit reversals (rounded down), so we could interleave single-bit reversals with the FFT steps. There are two orders that the reversals can be done in. One way would be to start with the outer-most bits and work our way in towards the center-most bits. Here’s the sequence of steps to do this for a 64-element FFT (note that we’re keeping the “matrix transpose” row ordering vs. natural memory ordering): 0 1 2 3 4 5 6 7 0 0 1 2 3 4 5 6 7 32 32 33 34 35 36 37 38 39 16 16 17 18 19 20 21 22 23 48 48 49 50 51 52 53 54 55 8 8 9 10 11 12 13 14 15 40 40 41 42 43 44 45 46 47 24 24 25 26 27 28 29 30 31 56 56 57 58 59 60 61 62 63 Standard Order 0 1 2 3 4 5 6 7 0 0 32 2 34 4 36 6 38 32 1 33 3 35 5 37 7 39 16 16 48 18 50 20 52 22 54 48 17 49 19 51 21 53 23 55 8 8 40 10 42 12 44 14 46 40 9 41 11 43 13 45 15 47 24 24 56 26 58 28 60 30 62 56 25 57 27 59 29 61 31 63 Step 1: Swap 1 ↔ 32 0 1 2 3 4 5 6 7 0 0 32 16 48 4 36 20 52 32 1 33 17 49 5 37 21 53 16 2 34 18 50 6 38 22 54 48 3 35 16 51 7 39 23 55 8 8 40 24 56 12 44 28 60 40 9 41 25 57 13 45 29 61 24 10 42 26 58 14 46 30 62 56 11 43 27 59 15 47 31 63 Step 2: Swap 2 ↔ 16 0 1 2 3 4 5 6 7 0 0 32 16 48 8 40 24 56 32 1 33 17 49 9 41 25 57 16 2 34 18 50 10 42 26 58 48 3 35 16 51 11 43 27 59 8 4 36 20 52 12 44 28 60 40 5 37 21 53 13 45 29 61 24 6 38 22 54 14 46 30 62 56 7 39 23 55 15 47 31 63 Final: Swap 4 ↔ 8 Each of these steps can be viewed as a collection of 2×2 matrix transposes : The first one does sixteen 2×2 transposes of individual elements (every 2×2 block of elements) The second does four 2×2 transposes, this time of 2×2 blocks (note the swap of the block containing “16, 48, 17, 49” and “2, 34, 3, 35”, for instance). The final step does a single 2×2 transpose of 4×4 blocks (swapping the upper-right and lower-left quadrants). The other order to do these in would be, instead, starting with the inner-most bits and going out from there (which I refer to, for purely comedic purposes, as the middle-out bit reversal): 0 1 2 3 4 5 6 7 0 0 1 2 3 4 5 6 7 32 32 33 34 35 36 37 38 39 16 16 17 18 19 20 21 22 23 48 48 49 50 51 52 53 54 55 8 8 9 10 11 12 13 14 15 40 40 41 42 43 44 45 46 47 24 24 25 26 27 28 29 30 31 56 56 57 58 59 60 61 62 63 Standard Order 0 1 2 3 4 5 6 7 0 0 1 2 3 8 9 10 11 32 32 33 34 35 40 41 42 43 16 16 17 18 19 24 25 26 27 48 48 49 50 51 56 57 58 59 8 4 5 6 7 12 13 14 15 40 36 37 38 39 44 45 46 47 24 20 21 22 23 28 29 30 31 56 52 53 54 55 60 61 62 63 Step 1: Swap 4 ↔ 8 0 1 2 3 4 5 6 7 0 0 1 16 17 8 9 24 25 32 32 33 48 49 40 41 56 57 16 2 3 18 19 10 11 26 27 48 34 35 50 51 42 43 58 59 8 4 5 20 21 12 13 28 29 40 36 37 52 53 44 45 60 61 24 6 7 22 23 14 15 30 31 56 38 39 54 55 46 47 62 63 Step 2: Swap 2 ↔ 16 0 1 2 3 4 5 6 7 0 0 32 16 48 8 40 24 56 32 1 33 17 49 9 41 25 57 16 2 34 18 50 10 42 26 58 48 3 35 16 51 11 43 27 59 8 4 36 20 52 12 44 28 60 40 5 37 21 53 13 45 29 61 24 6 38 22 54 14 46 30 62 56 7 39 23 55 15 47 31 63 Final: Swap 1 ↔ 32 They both end up with the same final result, and there’s not (at the moment) an obvious reason to prefer one over the other. Either way, any given step can take a 2×2 grouping of values and swap the elements on the diagonals, which we’ll leverage. We now know how to break this up into individual steps, but when should we do those steps? When To Do The Flippy Floppy There are many ways we can choose to group the bit reversals together. There are five somewhat obvious choices: Do them all at once at the beginning , before running the algorithm. This is what all the example FFT implementations in previous posts did. Do them all at once, at the end . This is a post-pass in-place bit-reversal. Because there are always half as many (rounded down) bit reversals as there are radix-2 passes, we could do them every other radix-2 pass (or, if we’re in radix-4 which has half the number of passes, once every radix-4 pass). We could do one per radix-2 pass for the first half of the FFT, then past the halfway point, there are no more reversals to be done and everything proceeds using the standard algorithm for bit-reversed inputs. We could do one per radix-2 pass for the last half of the FFT, so the first half would use the standard algorithm for standard-order inputs, before starting to swap things around. Obviously the first two options there are what we’re trying to avoid (doing the whole thing as one big pass), so we have three (reasonable) choices. As a 16-element decimation-in-time (DIT) FFT using the middle-out bit reversal, the other three options would look something like the following (with the filled boxes denoting where we’re doing a bit reverse vs. a standard FFT algorithm step): Note The goal here isn’t to be able to trace every single reversal, it’s just to demonstrate how the bit reversals “sit” in between the radix-2 passes for the different orderings. A butterfly diagram of a 16-element radix-2 FFT, where the inputs are in standard order. The first pass looks like normal, but then before the second pass there is a highlighted area representing the first bit reversal, where elements 2 and 3 swap with 4 and 5 (keeping their relative orders), and 10 and 11 swap with 12 and 13 in the same way. The rest of the elements remain unchanged through that section. After that is the next FFT pass, then another highlighted area, this one having elements 1, 3, 5, and 7 swap (keeping their relative orders) with elements 8, 10, 12, and 14. After that, the remaining two FFT passes proceed as normal, but unlike our other diagrams, the outputs are also in standard order, just like the inputs. " --> --> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4 4 0 2 4 6 0 2 4 6 0 1 2 3 4 5 6 7 First-Half Bit Reversal An FFT diagram similar to the previous one, except the two bit reversal passes happen after the second and fourth FFT passes instead, evenly spaced (but in the same order relative to each other). --> --> 0 2 4 6 0 2 4 6 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4 4 0 0 4 4 2 2 6 6 0 2 4 6 1 3 5 7 Evenly-Spaced Bit Reversal An FFT diagram similar to the previous two, except the two bit reversal passes happen after the third and fourth FFT passes instead. --> --> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4 4 0 0 4 4 2 2 6 6 0 2 4 6 1 3 5 7 Last-Half Bit Reversal Ultimately, the algorithm we want is going to be doing things as radix-4, so the evenly-spaced one seems tempting. After all, there’s one reversal after each pair of FFT steps, which means there would be a single reversal for every radix-4 step. However, if we visualize it as a radix-4: A diagram of a 16-element radix-4 FFT with two FFT passes. Between the two passes is the first bit reversal, and after the second pass is the second (and final) bit reversal. Unlike every other FFT butterfly diagram we have had in this series, in this one the second pass inputs and outputs into each radix-4 computation are unevenly spaced. It looks kind of jumbled. --> --> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 4 6 1 3 2 3 6 9 Look at that second radix-4 step. Look at it. It’s weird . The nice, even spacing between radix-4 elements is completely gone, the relative angle indices are … scattered? And it just gets worse the larger the FFT sizes get. It’s probably possible to make this work, but it seemed like a pain, and I don’t know how well it would play with CPU caches or SIMD. That leaves either the first-half or last-half options, neither of which has that problem (they both, conveniently, keep the radix-4 steps even at each level). Of the two, it turns out the last-half reversal has a nice property (shared by the DIF algorithm we came up with in the previous post): similar angles are grouped together longer , which means there are a number of optimizations we can apply to that formulation that we couldn’t do with the first-half version. Note The optimizations in this case include loading the angles outside of the inner-most loop and special-casing the first few sets of radix-4 passes, since we have a memory-coherent group with no rotations, then one with only 90-degree rotations, etc. Also, it’s worth noting that it actually keeps the same sequence of butterfly strides (the spacing between subsequent inputs/outputs to the butterfly) that the standard algorithm has: each radix-2 pass has half the stride as the one before (which means each radix-4 pass has a quarter the stride of the one before). This makes the algorithm nice and regular to implement. Note The first-half reversal algorithm, by comparison, has a sort of “smaller then larger” layout where they roughly halve until the midpoint where they start doubling, ending with the same stride as the start. You can see this in the diagram of it above. So, that’s the core of FFT-20XX’s algorithm: radix-4, decimation-in-time, and with last-half bit reversal . Now, we just have to figure out how to do said bit reversals. How 2 Bit Reverse As mentioned above, because we’re radix-4 we will need to do two bit reversals per radix-4 step in the last half. Note This is mostly true, with one exception: for sizes like 64, 1024, etc. where there are an odd number of bits that reverse, the first radix-4 of the back half (rounded up) only needs to do a single bit reverse since there’s an odd bit pair to swap. Similar to how our example 1-bit-reverse-at-a-time squares above were the equivalent of doing a set of 2×2 matrix transposes, doing 2 bits ends up being the equivalent of doing a set of 4×4 matrix transposes . The obvious way to do this would be to run the radix-4 FFT step, then do a separate pass that does the bit-reversal transposes. But we can do better — without requiring a separate pass over memory — by doing the bit reversals and the FFT step at the same time. Here’s the beauty of the way this works: for any given radix-4 step with this method, the two bits that flip always correspond to the spacing between the radix-4 elements. To explain what I mean by that, here’s a standard radix-4 diagram again. In last-half bit reversal world, the only two reversals in a 16-element FFT happen after the whole algorithm completes, so the diagram (without the reverses in it) is the same: This is a standard radix-4 DIT FFT diagram, with the inputs in standard order and the outputs in bit-reversed order. 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 2 4 6 1 2 3 3 6 9 0 0 0 0 0 0 0 0 0 0 0 0 Because we start from the middle bits and get to the outer bits last, the last radix-4 step will always be flipping the bits representing 1 and 2 (swapping them with the bits representing N 2 \frac{N}{2} and N 4 \frac{N}{4} , respectively), which will always be the spacing of elements in the last radix-4s (by this I mean, if you look at the first radix-4 of the last step, its indices will be 0, 1, 2, 3 — which is just every on/off combination of the bits for 1 and 2). The next-to-last radix-4 step (for FFTs sized 256 and larger) involves the bits for 4 and 8. Note that, in our 16-element diagram above (which doesn’t have this bit reverse but still illustrates the point), the first radix-4 butterfly has indices 0, 4, 8, 12 which, like the previous example, is just every on/off combination of those two bits. The step before that (for even larger FFTs) would involve flipping the bits for 16 and 32, with butterflies where the spacing is 0, 16, 32, 48. This pattern continues happily no matter how large the FFT ends up being. In the last step in our 16-element example, bit 1 swaps with bit 8 and bit 2 swaps with bit 4, and there just so happens to be a butterfly that starts at 4 and one that starts at 8. What this means is: the smallest bits in a flip correspond to the spacing within a given radix-4 computation , and the largest bits in a flip correspond to the starts of radix-4 passes . Thus, there are exactly four evenly-spaced radix-4 butterflies involved in every 4×4 transpose . Here’s a diagram of four butterflies (A through D) in their input order, and their post-transform order, which is exactly what the bit reversal is doing (with some color highlighting to make the butterflies clearer): A0 A1 A2 A3 B0 B1 B2 B3 C0 C1 C2 C3 D0 D1 D2 D3 Unflipped A0 B0 C0 D0 A1 B1 C1 D1 A2 B2 C2 D2 A3 B3 C3 D3 Flipped So, for each radix-4 step that does a two-bit reversal, we can instead run four radix-4 butterflies at once , and then transpose the elements within them before writing them back out to memory, doing the whole thing in one read/write pass! Note Doing this can just barely fit within the 16 registers that x64 SIMD (pre-AVX-512) provides, with some trickery involved around when to load from and store to memory. Final Algorithmic Details There are two more details that need to be handled, before the algorithm is fully described. First is, for non-power-of-four lengths, where do we put the single radix-2 pass ? This one has an easy answer: it can go anywhere in the first half ! (If it were to go somewhere in the last half, it would mess up the nice alignment of radix-4 element spacing and bit reversals we were going over in the previous section). For FFT-20XX, I ended up putting it directly after the very first radix-4 pass (as that first pass is nicely special- cased and optimized due to having no complex rotations). Note In fact, it was tempting to make the first pass a radix-8 pass, given that, in addition to the 8 complex components (16 values: reals and imaginaries), there only needs to be a single 2 2 \frac{\sqrt{2}}{2} factor loaded, and it would avoid a whole pass over memory. There wasn’t a way to get that all to fit in the 16 x64 SIMD registers (I was, annoyingly, able to get it down to needing 17 registers), and it ended up running slower — even at large FFT sizes — than just doing it as a radix-4 followed by a radix-2. On ARM, however, where there are 32 registers to play with, this would probably work nicely! Next, there’s the single-bit flip for FFT lengths with an odd number of bits that flip (for instance: a length of 64, which has 6-bit indices and thus 3 bits that flip, or 128 which has 7-bit indices which also has 3 bits that flip — with one that stays stationary in the middle). It turns out this case is actually two cases: power-of-four and non-power-of-four FFT lengths. For power-of-four lengths , we catch a nice break: the two bits that flip just so happen to be the middle two elements of each butterfly ! For example, for a 64-length FFT, there are 3 radix-4 steps. The second step contains the single-bit flip, and the first radix-4 butterfly has indices 0, 4, 8, and 12. And it turns out that it’s the bits representing 4 and 8 that are flipping, so we actually only need to load a single radix-4 butterfly , then just write the inner two elements out in reverse order. Nice! For power-of-two lengths , we’re not that lucky. But it still only requires doing two radix-4 butterflies at a time , and the second and fourth values from one swap with the first and third values of the other (as there are two 2×2 matrix transposes within each pair of butterflies): A0 A1 A2 A3 B0 B1 B2 B3 Unflipped A0 B0 A2 B2 A1 B1 A3 B3 Flipped So here’s a rough breakdown of the whole algorithm: For the first half (rounded down) of the radix-4 steps in the algorithm, proceed as normal, with the inputs in standard order. Unimportantly, I put the radix-2 step after the first radix-4, just because it was easy. If the FFT length has an odd number of bit flips: If it’s a power-of-four length, do a pass just like a standard one, except where the middle elements of each radix-4 are written in reversed order, to do the single bit flip. Otherwise, load the two relevant radix-4 butterflies, compute them both, then swap the second and fourth elements in the first with the first and third elements in the second before writing them out. After that, each step loads four radix-4 butterflies at a time, computes all of them, then does a 4×4 matrix transpose of their elements (while still in registers!) and writes those out. The devil, of course, is in the details (for instance, this simple description doesn’t go into the angle indexing — but it’s actually reasonably straightforward and regular!), but this is the high level of the algorithm! Snark! …if this many words can be described as just the “high level” overview of anything. SIMD Considerations This section will be light on specifics, but it’s worth going over a few of the SIMD considerations that went into the implementations. The first thing is that, as mentioned in the requirements at the start of this post, the inputs and outputs to the complex FFT functions use packed complex numbers . For SIMD efficiency, the very first step does a deinterleave during its loads , to get a SIMD vector of all the reals and a second vector of all of the imaginary components for each. As an example, for a 4-element SIMD type, it would load r0, i0, r1, i1, r2, i2, r3, i3 into two vectors: vR = r0, r1, r2, r3 vI = i0, i1, i2, i3 Then, for intermediate steps, it stores those 8 neighboring values directly, without re-interleaving them (as they stay neighboring in blocks like that until the very end). Only on the very last step does it re-interleave while writing the final results. Next, because of the way the angles are arranged (with like angles grouped nicely together), each radix-4 SIMD butterfly only needs a single set of three angles (though, when doing two or four at a time due to the bit reversals, each butterfly has its own set of three angles, so for the double-bit-reversal case there are actually 12 angles, total). Note I’m saying 3 angles as that’s the canonical way, but on x64 it actually only does two angles, doing instead a “radix- 2 2 2^2 ” computation and taking advantage of the speed of the FMA instruction, which allows it to do technically more calculations than the canonical version, but in less cycles. I’ve mentioned it in previous posts, but this trick is nicely described in The ryg blog . This stops being true right around the end of the process: the very last step (for all SIMD sizes) ends up requiring a SIMD set of distinct angles, as the grouping of the angles has finally gotten down to a single element (each butterfly in the final step has a unique set of angles). Note For larger SIMD sizes like AVX, the second-to-last step also needs to be special-cased, as it involves flipping bits 4 and 8. For AVX, for instance, each 8-element SIMD butterfly set contains two of the four radix-4 butterflies, in the first and last halves. Finally, smaller FFT sizes tend to need to be special-cased. 8-element and smaller FFTs are just done in scalar (I doubt anyone is going to be perf-constrained by not having those tiny FFTs be SIMDed). And, for AVX’s 8-element vectors, 64-element and below will fall back on the SSE2 implementation. The final pass also needs a different implementation for 2-element and 4-or-more-element SIMD vectors. That’s Complex! That is a hopefully-coherent rundown of how FFT-20XX’s complex-valued algorithm works! The algorithm itself isn’t that much more involved relative to a standard FFT implementation, but dropping the bit-reverse prepass (even after having heavily SIMD and CPU-cache optimized it) ended up getting FFT-20XX to be between 1.2 and 1.8x as fast as the chowdsp FFT that I was using as my baseline (tested at FFT lengths of 64 through 524,288), with the AVX implementation! (The SSE2 and NEON implementations end up 1.1 to 1.5x faster than chowdsp). It hits all of the requirements: it works completely in place with no scratch memory needed, keeping the inputs and outputs in their natural order, and is fast (or at least, fast enough)! And it manages to do that all without an explicit bit-reverse pass! Note The inverse complex FFT, which I haven’t mentioned at all in this post, uses the same algorithm with the rotations reversed (switched via C++ templates), with the 1 N \frac{1}{N} scale applied during the final radix-4 before saving the final results out. In the next (and, thankfully, final ) post in this series, we’re going to tackle the final boss of the whole project: the real-input FFT (and its inverse), which ended up being way trickier than I expected.📝JoshJers' Ramblings
Moving llvm::cl options to TableGenSince September, the number of llvm::cl:: option definitions in llvm/lib dropped from about 2860 on release/23.x to about 970 on main. Most of the difference moved from global llvm::cl::{opt,list,alias} objects into per-library structs declared in TableGen and stored per LibraryOptionsContext . Option values are no longer process-wide, so two compilations in one process can use different options. The ported options also no longer occupy .bss or run one dynamic initializer each before main . This post covers the design, what it cost, what embedders need to change, and what is left before the LLVM 24 branch. What is wrong with llvm::cl::opt A developer knob in an LLVM library is a namespace-scope global: static cl ::opt EnableCmovConverter ( "x86-cmov-converter" , cl :: desc ( "Enable the X86 cmov-to-branch optimization." ), cl :: init ( true ), cl ::Hidden); Each one is a dynamic initializer that registers the option into a StringMap and registers an exit-time destructor. The object occupies about 200 bytes of .bss ( sizeof(cl::opt ) is 192). Multiplied by a few thousand options, every tool that links LLVM pays this before main , whether or not it parses a command line. The values are process-wide. Two LLVMContext s in one process cannot use different values, which matters to every embedder that compiles more than one thing at a time: rustc's per-session -Cllvm-args , JITs that compile modules in parallel (Intel's graphics compiler, raised in the RFC thread), and NVIDIA, for whom removing global state was "the most important thing" (Reid Kleckner). Options also leak across library boundaries: 48 extern cl::opt declarations read another library's option, some through a public header. Yet 88% of options in llvm/lib are cl::Hidden developer knobs that nothing outside the library needs to see. Reusing llvm/Option On 2026-09-20 I posted [RFC] Declare library command line options in TableGen, one struct per library . The idea is to reuse llvm/Option , the OptTable library behind the clang, lld, and llvm-objcopy drivers. A library's options become one OptTable plus a plain struct that holds the values. cl:: still walks the command line, and hands each argument that names a library option to that library's table. If OptTable is to replace cl::opt , it has to be cheaper, not just tidier. Four patches starting with #218845 shrank OptTable::Info from 88 to 16 bytes with no dynamic relocations, by replacing string pointers with StringTable offsets and moving rarely used fields into a deduplicated side table. clang's table of 3,871 options went from 232 KB after the first patch to 72 KB after the last. Declaring options Each library owns a .td file in its own directory. A target can have two: one for the code generator, bound by its TargetMachine , and one in MCTargetDesc/ for the MC layer, which llvm-mc and clang -cc1as use without a TargetMachine . Here are excerpts of X86's, llvm/lib/Target/X86/X86Options.td (code generator options): include "llvm/Option/LibraryOptions.td" def X86Options : OptionsStruct ; ... // X86CmovConversion.cpp defm : BoolField "Enable the X86 cmov-to-branch optimization">; defm : BoolField "Convert all cmovs to branches">; defm : BoolField "Convert cmovs to branches whenever they have memory operands">; defm : ValueField "Minimum gain per loop (in cycles) threshold">; ... and llvm/lib/Target/X86/MCTargetDesc/X86MCOptions.td (options read by LLVMX86Desc: the assembler, the asm backend, and MCAsmInfo): include "llvm/Option/LibraryOptions.td" def X86MCOptions : OptionsStruct ; ... defm : ValueField ", "std::nullopt", "Maximum number of prefixes to use for padding">; // MCTargetDesc/X86MCAsmInfo.cpp defm : EnumField "att,intel", ["X86::ATT", "X86::Intel"], "Select the assembly style for input">; ... llvm-min-tblgen -gen-opt-parser-defs emits the option table, a struct with default member initializers, and an apply function that sets the member an argument names: struct X86MCOptions { bool experimental_lvi_inline_asm_hardening{ false }; std :: optional StringRef > align_branch{ std ::nullopt}; std :: optional unsigned > align_branch_boundary{ std ::nullopt}; bool branches_within_32B_boundaries{ false }; bool pad_for_align{ false }; bool pad_for_branch_align{ true }; std :: optional unsigned > pad_max_prefix_size{ std ::nullopt}; X86 :: AsmWriterFlavorTy asm_syntax{ X86 ::ATT}; bool mark_data_regions{ true }; static const llvm :: opt :: OptTable & optTable (); bool apply ( const llvm :: opt :: Arg & A , llvm :: BumpPtrAllocator & Alloc ); private: friend class llvm :: cl :: LibraryOptionsContext ; friend class llvm :: opt :: LibraryOptionsParser ; static const X86MCOptions Default; }; Member names are snake_case spellings with the struct's prefix stripped. A std::optional member replaces a getNumOccurrences() check: x86-pad-max-prefix-size is unset unless given ( OptionalValueField is the shorthand). Default is constant-initialized and private, so code cannot read options without going through a context. There are also list fields, whose members are ArrayRef s so the structs stay trivially destructible. let Condition = AssertsOnly in declares options that exist only in assertion builds. The full vocabulary is in CommandLine.md , section "Declaring a Library's Options in TableGen". A library's struct is private: the .td and the header live in lib/X , never in include/ . Another library that needs a value calls a function or takes a parameter, and an embedder gets knobs through API structs ( PipelineTuningOptions , TargetOptions , lto::Config ). Targets register their structs from LLVMInitializeXXXTarget() and LLVMInitializeXXXTargetMC() with a function-local static, so a target's options cost no dynamic initializer: extern "C" LLVM_C_ABI void LLVMInitializeX86TargetMC () { static opt ::RegisterLibraryOptions X86MCOptions > O; ... A generic library has no initialization function to register from. It uses one file-scope static, LLVM_REGISTER_LIBRARY_OPTIONS(llvm::ScalarOptions) : one dynamic initializer per library instead of one per option. Reading options: the owner binds once Values live in cl::LibraryOptionsContext . Each layer reaches it through an object it already has, and an owner binds the struct once: IR passes ask the function's context: F.getContext().getLibraryOptions().get () . A TargetMachine binds its struct in the constructor, and subtargets and passes read it through getCLOpts() . MC goes through MCTargetOptions::LibraryOptions , because MCAsmInfo and MCAsmBackend are created before any MCContext . The X86 port turns the global above into a reference bound by the TargetMachine : X86TargetMachine :: X86TargetMachine (...) : ..., CLOpts ( cl :: LibraryOptionsContext :: get X86Options >( Options.MCOptions.LibraryOptions)), and X86CmovConversion.cpp reads it through the subtarget, replacing EnableCmovConverter , ForceAll and the other globals: const X86Options & CLOpts = STI-> getCLOpts (); if ( ! CLOpts.cmov_converter) return false ; The MC struct is reached from MCTargetOptions , which MCAsmInfo , the asm backend and the asm parser all receive: inline const X86MCOptions & getCLOpts ( const MCTargetOptions & Options ) { return cl :: LibraryOptionsContext :: get X86MCOptions >(Options.LibraryOptions); } AssemblerDialect = X86_MC :: getCLOpts (Options).asm_syntax; Larger libraries bind a reference in their central objects ( LSRInstance , GVNPassImpl , ScheduleDAGInstrs ) and pass it to static helpers. A lookup is a hash probe at bind time, not on every read; converting four libraries to per-context reads measured within ±0.02% instructions:u on the compile-time tracker. Parsing into a context A tool parses into the context it will compile with: LLVMContext Context; ... cl :: parseCommandLineOptions (Context. getLibraryOptions (), codegen :: getToolOptions (), ArrayRef (argv, argc), "llvm system compiler \n " ); Library options go to the context, and everything else still goes to cl:: . How options are passed does not change: clang -mllvm , ld.lld -mllvm , opt and llc accept them as before. Two contexts in one process can now differ. This program compiles the same function on two threads, with -x86-asm-syntax=intel (the X86MCOptions field above) parsed into only one of the contexts: static std :: string compile ( LLVMContext & Ctx ) { SMDiagnostic Err; std :: unique_ptr Module > M = parseAssemblyString (IR, Err, Ctx); std :: string Error; const Target * T = TargetRegistry :: lookupTarget (M-> getTargetTriple (), Error); TargetOptions Opts; Opts.MCOptions.LibraryOptions = & Ctx. getLibraryOptions (); std :: unique_ptr TargetMachine > TM (T-> createTargetMachine ( M-> getTargetTriple (), "" , "" , Opts, std ::nullopt)); M-> setDataLayout (TM-> createDataLayout ()); SmallString 0 > S; raw_svector_ostream OS (S); legacy :: PassManager PM; TM-> addPassesToEmitFile (PM, OS, nullptr , CodeGenFileType ::AssemblyFile); PM. run ( * M); return std :: string (S); } int main () { InitializeNativeTarget (); InitializeNativeTargetAsmPrinter (); LLVMContext A, B; const char * ArgsA[] = { "demo" , "-x86-asm-syntax=intel" }; const char * ArgsB[] = { "demo" }; cl :: parseCommandLineOptions (A. getLibraryOptions (), ArgsA); cl :: parseCommandLineOptions (B. getLibraryOptions (), ArgsB); std :: string OutA, OutB; std :: thread TA ([ & ] { OutA = compile (A); }); std :: thread TB ([ & ] { OutB = compile (B); }); TA. join (); TB. join (); outs () "=== A \n " OutA "=== B \n " OutB; } % ./demo | grep -E '===|syntax|lea|ret' === A .intel_syntax noprefix lea eax, [rdi + rsi] ret === B .att_syntax leal (%rdi,%rsi), %eax retq With release/23.x's global options, both threads would read the same value. Initialize targets before parsing, since targets register their options in LLVMInitializeXXXTarget() , and parse before starting threads: the parser itself still has global state. The legacy cl::ParseCommandLineOptions now rejects library options ( #242689 ), so a tool that has not been ported fails loudly instead of silently ignoring an option: % llvm-dwarfdump -x86-cmov-converter=false /dev/null llvm-dwarfdump: Unknown command line argument '-x86-cmov-converter=false'. Try: 'llvm-dwarfdump --help' llvm-dwarfdump: Did you mean '--show-sources=false'? Library options are never serialized into bitcode. A setting that must survive LTO belongs in an IR attribute or a module flag; developer knobs are passed again at link time with -mllvm . What embedders need to change LLVM 24 is the first release with this API. A tool or embedder that forwards developer options to LLVM, such as rustc's -Cllvm-args , Julia, Zig, or an out-of-tree compiler driver, needs these changes: Replace cl::ParseCommandLineOptions(argc, argv) with cl::parseCommandLineOptions(Store, ArrayRef(argv, argc)) , where Store is the LLVMContext 's getLibraryOptions() or a standalone cl::LibraryOptionsContext . Otherwise most CodeGen, MC, target, and optimization options become "Unknown command line argument". With a standalone store, copy it into each LLVMContext with Ctx.getLibraryOptions().assign(Store) . Parse once, before creating threads. Point TargetOptions::MCOptions.LibraryOptions at the store when creating a TargetMachine . codegen::getTargetOptions and mc::getMCTargetOptions do this for tools that use them. codegen::RegisterCodeGenFlags and mc::RegisterMCTargetOptionsFlags are gone. Pass codegen::getToolOptions() or mc::getToolOptions() to cl::parseCommandLineOptions instead. C API users keep calling LLVMParseCommandLineOptions , before creating any context: contexts, target machines, MCJIT and ORC created through the C API read the options it parsed ( #234820 , #242692 ). Per-context C APIs wait until the migration ends; Nikita Popov considered them too early for the stable C API. Spellings may have changed. Library options carry no stability promise; a renamed option that tests use keeps its old spelling as an alias for about six months. How the design changed The first version ( #226087 , 2026-09-30) gave each struct a process-wide T::Global , so a library could be ported before its readers had a context. Per-context storage, originally a later step of the plan, was moved up and landed on 2026-10-14 ( #231407 ), and T::Global was deleted on 2026-11-15 ( #242854 ). The only process-wide store left is the one LLVMParseCommandLineOptions fills for C API users. The temporary global made the first ports cheap. But once contexts existed, every reader still bound to the global was a silent-ignore bug. For example, an early version of the per-context patch dropped target -mllvm options in clang's distributed ThinLTO backend, because that path built its TargetMachine without the context's options. Spellings Each port normalizes spellings: one prefix per library, and positive booleans with enable- and disable- dropped ( -cgp-branch-opts=0 , not -disable-cgp-branch-opts ). This matches what most options already looked like: 1,360 of the 1,808 booleans in llc and opt's -help-hidden had neither prefix. Old spellings that tests or users rely on are kept as aliases for a while ( #232174 ): def : AliasOf ; def : AliasOf ; A boolean accepts -x and -x=true|false|1|0 . I proposed accepting -no-x and eventually rejecting -x=false . Hans Wennborg pointed out that countless build configurations pass -x=false , and James Y Knight and Nikita Popov saw no value in a second spelling, so I withdrew it. Cleaning up cl:: first Before porting, I removed cl:: features that have no .td equivalent: cl::Sink , cl::multi_val , cl::Grouping , cl::DefaultOption , and cl::bits . cl::opt now accepts only true , false , 1 and 0 , the values a BoolField accepts. cl::callback has no equivalent either: a ported option becomes a plain field plus code that inspects the state after parsing. A few callbacks remain on options that are not ported yet, such as -opt-bisect-limit and -print-debug-counter . Pass plugins no longer put their options into the global namespace; -plugin-arg= , ( #227414 ) routes arguments to the plugin. The tool-level registries in CommandFlags.cpp and MCTargetOptionsCommandFlags.cpp became opt-in TableGen structs too. Cost and benefit The first prototype ported LLVMPasses and LLVMCGData. On the compile-time tracker, instructions:u stayed within ±0.02% on all configurations, PassBuilderPipelines.cpp.o shrank by 75.8 KB (7.9%), and clang's .bss by 1.5%. Larger ports saved startup work: Scalar (214 options) −0.06% to −0.10% instructions:u on O0-g. One measurement trap: the new pass manager identifies each analysis by the address of a static AnalysisKey in .bss , and removing cl::opt objects moves those addresses. AnalysisManager caches results in DenseMap s keyed by these pointers, and DenseMapInfo hashes the pointer bits, so collisions and probe lengths change with no code change. Adding just 0x40 bytes of .bss padding moved opt -O3 by +0.085% instructions, and the Analysis port measured +0.15%, with callgrind putting 92% of the difference in AnalysisManager . Pinning the keys with --symbol-ordering-file (all AnalysisKey symbols) and --section-start=.bss gave both builds the same key addresses, and the port's cost dropped to zero within noise. Padding alone cannot fix this, since each library's .bss shrinks by a different amount and the hash uses every pointer bit. The effect can just as easily show up as a spurious win. Where it stands As of 2026-11-23, 39 .td files on main declare about 1,970 fields, covering 14 generic libraries (including Analysis, CodeGen, IR, MC, Passes and the Transforms libraries) and 17 targets. Others have ported options too: Meredith Julian ported NVPTX, Simon Pilgrim SelectionDAG, and Maksim Shelegov and Rahman Lavaee smaller groups. On 2026-11-06 I posted a help wanted call to library maintainers. -Werror=global-constructors is on for llvm/lib in Clang builds ( #239678 ), with 62 libraries still opted out. Once a library reaches zero dynamic initializers it leaves the opt-out list and cannot regain a global cl::opt . What is left: Hexagon (the largest, about 240 options), the rest of CodeGen (about 170, plus SelectionDAG and AsmPrinter), Transforms/Utils (about 130), ARM, LTO, ProfileData, BPF, LoongArch and WebAssembly, plus leftovers in IPO, Analysis and IR. -print-options and "Did you mean" suggestions do not see library options yet. Global constructors that are not options: pass registries, DEBUG_COUNTER , and the GlobalISel combiner's rule lists. LLVM 24 branches on 2027-01-12, and I want most of llvm/ done by then. MLIR, Polly, BOLT and clang-tools-extra will follow later. Acknowledgments Alexis Engelke reviewed most of this work: he approved 57 of the 91 framework and port patches I landed. His reviews shaped the design, including trivially destructible structs and a constant-initialized T::Default in place of seeding each context. Nikita Popov steered the C API toward one global store until the migration ends and reviewed the C API changes and the removal of T::Global . Reid Kleckner pushed for per-context storage on behalf of embedders and reviewed the framework, the MC port, per-context storage and AliasOf , which grew out of his alias patches.📝MaskRay

Saturday, November 21, 2026

Welcome to Soviet Union 2.0, comradeI have a former coworker who was born in the Soviet Union at a very specific time in history. He was just old enough to see the system from the inside and grasp how it works (or, more specifically, did not work) but young enough that it did not consume him. He got out fairly quickly after the collapse and is nowadays doing computer related work in "the west", as it were. Having seen both sides of the world order he had quite an interesting view on why the Soviet Union eventually crashed and how it ties to modern companies. Let's assume that you are working in the Soviet Union in a car factory. Your job is to be responsible for all things needed to attach the wheels to the body of the car. In practice this means taking parts from subcontractors (typically other divisions of the same factory) such as break pads and lines, the actual wheels, and all other things and put them together so that the car can roll forward. Seems reasonable enough, right? In practice it turns out that all parts you get are actually garbage. The wheels are not properly balanced. The inner tube might have a hole in it or be completely missing. The metal in brake pads has been silently changed to a cheaper one removing 50-70% of braking power. The brake lines are too short for installation. To make them work you'd need to cut holes in the car's superstructure. Your screws are too soft to properly function, but fortunately so are your wrenches. The downside is that after tightening one wheel all your tools are shaped like a banana. And so on and so on. Should you find yourself in such a situation, what should you do about it? In theory the parts you are given are not up to spec. So you could file a complaint about it. But you really can't, because then the problem would be you. You would need to do the extra work of getting the people providing you parts to fix their process (which you can't do). You would need to file the paper work. Your name would be on every one of them. When higher ups get reprimanded for cars not getting finished fast enough to reach the requirements of the current five year plan, they are going to come looking for a scapegoat. You made a ruckus. You stopped the pipeline. You are the problem. You get punished. But it gets worse. Not only are the people below you not caring and producing garbage work, so are the people above you. At every part of the chain nobody gives a shit, they just take things from below, fiddle with them a bit and then shove them upwards and hope that when things eventually fail, you can deflect the blame on to someone else. If you wish to survive, that is what you must do also. This, according to my coworker, was what eventually brought down the Soviet Union. When all organizational layers of an entire nation gets filled with garbage in – garbage out shovelers, the system loses its capability to function, becomes a zombie, wanders on aimlessly and eventually dies. He claims to have witnessed aspects of this appearing in the organizational chains of several software companies and that he has tried to warn them about the bad direction things are heading. Usually to deaf ears. But what about today? All of that happened years ago. The question is whether any of it still matters in this, our Shining New Era of AI. It most definitely does, more than ever. Any organization can tolerate a small fraction of employees that don't particularly care about "the job" and are just hanging around putting in the minimal amount of effort they need to to still remain employed. That is just how large organizations work. The problem is ratio, and this is where AI comes in. One of the main non-technical changes AI has brought about seems to be the wholesale conversion of formerly competent and caring people into garbage in – garbage out shovelers. We see them all around us every day. Like the people who handle all emails sent to them by copypasting the entire email thread to a chatbot, asking "what should I reply to this" and then copypasting the entire thing (including the prompt) back as their reply. Or software developers who used to be smart, knowledgeable and competent but suddenly resemble Alzheimer's patients who reply to merge review questions such as "why did you do this thing here" with "I don't know, Claude told me to" and then merge their code without fixing any of the issues raised. All of this is exacerbated by all the recent layoffs in the tech sector. No doubt this has been used to rid the company of those pesky troublemakers who dare point out flaws in The Perfect New System. Those who know their history might remember that this was the preferred tactic of Stalin (though, granted, his methods were more extreme). As firing people saves money immediately and only causes problems with a delay, this is seen as a good thing and managers doing it get rewarded. And this is where we are today. Many formerly good organizations have become or are on their way to becoming lumbering hulks that can no longer properly function and will eventually collapse under the weight of their own incompetence. You can already feel this with the recent outages of Microsoft cloud and other services. Things that should have worked just breaking down randomly without anyone really knowing why was an every day occurrence in the Soviet Union. People just shrugged it off as an unavoidable fact of life. That is the direction we are heading. The last laugh of Lenin The latter half of the 20th century was a battle between communism and capitalism. The latter won and, having its world view validated, went on to an even more extreme end of ultra-capitalism. The ultimate irony is that eventually it reached the exact same end state as communism: an absolute unwavering ideological religion. Which is made all the more amusing by the fact that both of these movements were meant to be fully atheistic. In communism the country was filled with party leaders who were vocal that communism would lead to "the workers' paradise" which was "within our grasp just over the horizon", we just have to give it some time. The average person, on the other hand, did not believe a word of this nonsense, just pretended to care to get along with their life. I communism 2.0 we instead have CEOs claiming that AI leads to "freeing humanity from the shackles of work" and that "the cure for cancer is just over the horizon", we just have to give them infinite amounts of money first. The average person does not believe a word of this nonsense, just pretend to care to get along with their life. At least the Soviet Union had the banging Red Army Choir. All noises the techbro CEOs seem to be capable of producing consist of whingy stuttering and vocal fry.📝Nibble Stew
C++26 is done (again)! — Trip report: November 2026 ISO C++ standards meeting (Búzios, Brazil)tl;dr: A few highlights C++26 technical work, originally completed in March, was reopened and is now recompleted: The anticipated plan is to reissue the updated C++26 document for a second approval ballot. Most of the six-day meeting was devoted to addressing a second set of international comments for C++26, primarily on the contracts language feature. … Continue reading C++26 is done (again)! — Trip report: November 2026 ISO C++ standards meeting (Búzios, Brazil) →📝Sutter’s Mill

Friday, November 20, 2026

Decoding base64 email attachments: a speed ranking of programming languagesEmail attachments are base64. So are cryptographic PEM certificates. In both cases the text is broken into lines, 76 characters for email and 64 for PEM. Skipping line endings sounds trivial. Yet many fast decoders only work on uninterrupted base64. As soon as they meet a line break, they fall back to a slow path. … Continue reading Decoding base64 email attachments: a speed ranking of programming languages📝Daniel Lemire's blog