[WinCFG] Handle constant casts carefully in .gfids emission
authorReid Kleckner <rnk@google.com>
Wed, 30 Oct 2019 23:32:26 +0000 (16:32 -0700)
committerReid Kleckner <rnk@google.com>
Fri, 1 Nov 2019 20:32:03 +0000 (13:32 -0700)
commitf5d935c16777c39142043c429ccebb65259dc767
treea037344747eb77e615afbaae8b49fcb0a818db5e
parent52ea308f705af0a8f5d55e036a64fd2b5e4c2ee6
[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
llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
llvm/test/CodeGen/WinCFGuard/cfguard-cast.ll [new file with mode: 0644]