[ThinLTO] Avoid extra index lookup during promotion
authorTeresa Johnson <tejohnson@google.com>
Mon, 18 Nov 2019 20:03:58 +0000 (12:03 -0800)
committerTeresa Johnson <tejohnson@google.com>
Mon, 18 Nov 2019 20:55:53 +0000 (12:55 -0800)
commitcc1b0bc24d2703087d80e4f4dc0560879733299a
treea6404d66385bedb815df52cfe63018bb17ffda6a
parentee31adb7fa42f5b601d9612f23755b4604f83cac
[ThinLTO] Avoid extra index lookup during promotion

Summary:
Pass down the already accessed ValueInfo to shouldPromoteLocalToGlobal,
to avoid an unnecessary extra index lookup.

Add some assertion checking to confirm we have a non-empty VI when
expected.

Also some misc cleanup, merging the two versions of
doImportAsDefinition, since one was only called by the other, and
unnecessarily passed in a member variable.

Reviewers: steven_wu, pcc, evgeny777

Reviewed By: evgeny777

Subscribers: mehdi_amini, inglorion, hiraditya, dexonsmith, arphaman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D70337
llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h
llvm/lib/Transforms/Utils/FunctionImportUtils.cpp