diff options
| author | Reid Kleckner <rnk@google.com> | 2019-10-30 16:32:26 -0700 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2019-11-01 13:32:03 -0700 |
| commit | f5d935c16777c39142043c429ccebb65259dc767 (patch) | |
| tree | a037344747eb77e615afbaae8b49fcb0a818db5e /llvm/test/CodeGen/WinCFGuard | |
| parent | 52ea308f705af0a8f5d55e036a64fd2b5e4c2ee6 (diff) | |
| download | bcm5719-llvm-f5d935c16777c39142043c429ccebb65259dc767.tar.gz bcm5719-llvm-f5d935c16777c39142043c429ccebb65259dc767.zip | |
[WinCFG] Handle constant casts carefully in .gfids emission
Summary:
The general Function::hasAddressTaken has two issues that make it
inappropriate for our purposes:
1. it is sensitive to dead constant users (PR43858 / crbug.com/1019970),
leading to different codegen when debu info is enabled
2. it considers direct calls via a function cast to be address escapes
The first is fixable, but the second is not, because IPO clients rely on
this behavior. They assume this function means that all call sites are
analyzable for IPO purposes.
So, implement our own analysis, which gets closer to finding functions
that may be indirect call targets.
Reviewers: ajpaverd, efriedma, hans
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69676
Diffstat (limited to 'llvm/test/CodeGen/WinCFGuard')
| -rw-r--r-- | llvm/test/CodeGen/WinCFGuard/cfguard-cast.ll | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/WinCFGuard/cfguard-cast.ll b/llvm/test/CodeGen/WinCFGuard/cfguard-cast.ll new file mode 100644 index 00000000000..e66345b0d70 --- /dev/null +++ b/llvm/test/CodeGen/WinCFGuard/cfguard-cast.ll @@ -0,0 +1,35 @@ +; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s + +; Check how constant function pointer casts are handled. + +declare void @unprototyped(...) + +define i32 @call_unprototyped() { + call void bitcast (void (...)* @unprototyped to void ()*)() + ret i32 0 +} + +; CHECK-LABEL: call_unprototyped: +; CHECK: callq unprototyped +; CHECK: xorl %eax, %eax +; CHECK: retq + +declare void @escaped_cast() + +define i32 @escape_it_with_cast(i8** %p) { + store i8* bitcast (void ()* @escaped_cast to i8*), i8** %p + ret i32 0 +} + +declare void @dead_constant() + +!llvm.module.flags = !{!0} +!0 = !{i32 2, !"cfguard", i32 1} + +!dead_constant_root = !{!1} +!1 = !DITemplateValueParameter(name: "dead_constant", value: i8* bitcast (void ()* @dead_constant to i8*)) + +; CHECK-LABEL: .section .gfids$y,"dr" +; CHECK-NEXT: .symidx escaped_cast +; CHECK-NOT: .symidx + |

