[PATCH] D65761: Add Windows Control Flow Guard checks (/guard:cf).
Reid Kleckner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 6 11:28:34 PDT 2019
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
More information about the cfe-commits
mailing list