[ThinLTO] Write TYPE_IDs for types used in functions imported by aliases

Summary:
ThinLTO imports alias as a copy of a aliasee, so when we import such functions with type tests we will
need type ids used by function. However after D49565 we pick types only during processing of
FunctionSummary which is not happening for such aliesees.

Example:
Unit U1 with a type, a functions F with the type check, and an alias A to the function.
Unit U2 with only call to the alias A.

In particular, this happens when we use -mconstructor-aliases, which is default.
So if c++ unit only creates instance of the class, without calling any other methods it will lack of
necessary type ids, which will result in false CFI reports.

Reviewers: tejohnson, eugenis

Subscribers: pcc, mehdi_amini, inglorion, eraman, hiraditya, steven_wu, dexonsmith, llvm-commits

Differential Revision: https://reviews.llvm.org/D52201

llvm-svn: 342574
This commit is contained in:
Vitaly Buka
2018-09-19 18:51:42 +00:00
parent 7e880a4f6d
commit 84d912b7d2
3 changed files with 44 additions and 6 deletions

View File

@@ -3877,6 +3877,9 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
Stream.EmitRecord(bitc::FS_COMBINED_ALIAS, NameVals, FSAliasAbbrev);
NameVals.clear();
MaybeEmitOriginalName(*AS);
if (auto *FS = dyn_cast<FunctionSummary>(&AS->getAliasee()))
getReferencedTypeIds(FS, ReferencedTypeIds);
}
if (!Index.cfiFunctionDefs().empty()) {