rnk added inline comments.
================ Comment at: llvm/lib/Target/X86/X86FixupCFGuard.cpp:13 +/// for such cases and replaces the pair of instructions with a single +/// call/invoke. For example: +/// ---------------- hans wrote: > Naive question: Why do we generate code as in the examples in the first > place, and can't some general optimization pass do this folding? From the > examples it looks like straight-forward constant propagation. Actually, I used this test IR, LLVM seems to always fold the memory operand into the call: ``` @fptr = external dso_local global void()* define i32 @foo() { %fp1 = load void()*, void()** @fptr call void %fp1() %fp2 = load void()*, void()** @fptr call void %fp2() ret i32 0 } ``` Maybe it won't do it if there are more parameters, I'm not sure. I ran llc with both isels for x64 and ia32, and it always folded the load into the call. Maybe it's best to make this a verification pass that emits an error via MCContext if there is an unfolded load of the CFG check function pointer? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65761/new/ https://reviews.llvm.org/D65761 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits