2599 Commits

Author SHA1 Message Date
David Majnemer
22e3ed1aa0 Add EP_CGSCCOptimizerLate extension point to PassManagerBuilder
The EP_CGSCCOptimizerLate extension point allows adding CallGraphSCC
passes at the end of the main CallGraphSCC passes and before any
function simplification passes run by CGPassManager.

Patch by Gor Nishanov!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276953 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 03:28:43 +00:00
Sean Silva
9728cbe338 Cleanup : Reformat PartialInliner.cpp to have current LLVM style conventions
Modify the variable names and code style to be that of modern LLVM.

Patch by River Riddle!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276610 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 05:57:59 +00:00
Sean Silva
4cd349418b Fix : Partial Inliner requires AssumptionCacheTracker
The public InlineFunction utility assumes that the passed in
InlineFunctionInfo has a valid AssumptionCacheTracker.

Patch by River Riddle!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276609 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 05:00:00 +00:00
Xinliang David Li
52e0b0d91b [Profile] Use explicit flag to enable IR PGO
Patch by Jake VanAdrighem

Differential Revision: http://reviews.llvm.org/D22607




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276516 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-23 04:28:52 +00:00
Sean Silva
9486968c02 Avoid using a raw AssumptionCacheTracker in various inliner functions.
This unblocks the new PM part of River's patch in
https://reviews.llvm.org/D22706

Conveniently, this same change was needed for D21921 and so these
changes are just spun out from there.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276515 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-23 04:22:50 +00:00
Alina Sbirlea
9909951848 Add flag to PassManagerBuilder to disable GVN Hoist Pass.
Summary:
Adding a flag to diable GVN Hoisting by default.
Note: The GVN Hoist Pass causes some Halide tests to hang. Halide will disable the pass while investigating.

Reviewers: llvm-commits, chandlerc, spop, dberlin

Subscribers: mehdi_amini

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276479 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 22:02:19 +00:00
David Majnemer
14834723b0 Don't remove side effecting instructions due to ConstantFoldInstruction
Just because we can constant fold the result of an instruction does not
imply that we can delete the instruction.  It may have side effects.

This fixes PR28655.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276389 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 04:54:44 +00:00
George Burgess IV
6b817ea4e2 Make help text more consistent. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276205 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 23:14:29 +00:00
David Majnemer
baf88b3b1a [FunctionAttrs] Correct the safety analysis for inference of 'returned'
We skipped over ReturnInsts which didn't return an argument which would
lead us to incorrectly conclude that an argument returned by another
ReturnInst was 'returned'.

This reverts commit r275756.

This fixes PR28610.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276008 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19 18:50:26 +00:00
Teresa Johnson
385d70633e [PM] Port FunctionImport Pass to new PM
Summary: Port FunctionImport Pass to new PM.

Reviewers: mehdi_amini, davide

Subscribers: davidxl, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275916 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 21:22:24 +00:00
NAKAMURA Takumi
73585958d4 Revert r275678, "Revert "Revert r275027 - Let FuncAttrs infer the 'returned' argument attribute""
This reverts also r275029, "Update Clang tests after adding inference for the returned argument attribute"

It broke LTO build. Seems miscompilation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275756 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 03:23:25 +00:00
Teresa Johnson
e2f34269f3 [ThinLTO] Perform profile-guided indirect call promotion
Summary:
To enable profile-guided indirect call promotion in ThinLTO mode, we
simply add call graph edges for each profitable target from the profile
to the summaries, then the summary-guided importing will consider the
callee for importing as usual.

Also we need to enable the indirect call promotion pass creation in the
PassManagerBuilder when PerformThinLTO=true (we are in the ThinLTO
backend), so that the newly imported functions are considered for
promotion in the backends.

The IC promotion profiles refer to callees by GUID, which required
adding GUIDs to the per-module VST in bitcode (and assigning them
valueIds similar to how they are assigned valueIds in the combined
index).

Reviewers: mehdi_amini, xur

Subscribers: mehdi_amini, davidxl, llvm-commits

Differential Revision: http://reviews.llvm.org/D21932

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275707 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-17 14:47:01 +00:00
Hal Finkel
4fe9cc7cb0 Revert "Revert r275027 - Let FuncAttrs infer the 'returned' argument attribute"
This reverts commit r275042; the initial commit triggered self-hosting failures
on ARM/AArch64. James Molloy identified the problematic backend code, which has
been disabled in r275677. Trying again...

Original commit message:

Let FuncAttrs infer the 'returned' argument attribute

A function can have one argument with the 'returned' attribute, indicating that
the associated argument is always the return value of the function. Add
FuncAttrs inference logic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275678 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-16 07:21:28 +00:00
Rong Xu
0922b287f7 [PGO] IRPGO pre-cleanup pass changes
This patch adds a selected set of cleanup passes including a pre-inline pass
before LLVM IR PGO instrumentation. The inline is only intended to apply those
obvious/trivial ones before instrumentation so that much less instrumentation
is needed to get better profiling information. This will drastically improve
the instrumented code performance for large C++ applications. Another benefit
is the context sensitive counts that can potentially improve the PGO
optimization.

Differential Revision: http://reviews.llvm.org/D21405


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275588 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 18:10:49 +00:00
Sebastian Pop
9c2e9dc782 code hoisting pass based on GVN
This pass hoists duplicated computations in the program. The primary goal of
gvn-hoist is to reduce the size of functions before inline heuristics to reduce
the total cost of function inlining.

Pass written by Sebastian Pop, Aditya Kumar, Xiaoyu Hu, and Brian Rzycki.
Important algorithmic contributions by Daniel Berlin under the form of reviews.

Differential Revision: http://reviews.llvm.org/D19338

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275561 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 13:45:20 +00:00
Nico Weber
037f8a7c73 Revert r275401, it caused PR28551.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275420 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 14:41:25 +00:00
Sebastian Pop
16129fc15d code hoisting pass based on GVN
This pass hoists duplicated computations in the program. The primary goal of
gvn-hoist is to reduce the size of functions before inline heuristics to reduce
the total cost of function inlining.

Pass written by Sebastian Pop, Aditya Kumar, Xiaoyu Hu, and Brian Rzycki.
Important algorithmic contributions by Daniel Berlin under the form of reviews.

Differential Revision: http://reviews.llvm.org/D19338

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275401 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 12:18:53 +00:00
Ivan Krasin
bf38a6cacf Print remarks from WholeProgramDevirt pass for each call site.
Summary:
It's useful to have some visibility about which call sites are devirtualized,
especially for debug purposes. Another use case is a regression test on the
application side (like, Chromium).

Reviewers: pcc

Differential Revision: http://reviews.llvm.org/D22252

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275145 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-12 02:38:37 +00:00
Davide Italiano
eb0664013d [PM/IPO] Port LowerTypeTests to the new PassManager.
There's a little bit of churn in this patch because the initialization
mechanism is now shared between the old and the new PM. Other than
that, it's just a pretty mechanical translation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275082 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 18:10:06 +00:00
Davide Italiano
abd1b54b30 [LowerTypeTests] Don't rely on doInitialization().
In preparation for porting this pass to the new PM (which has no
doInitialization()).

Differential Revision:  http://reviews.llvm.org/D22223

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275074 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 17:00:31 +00:00
Dehao Chen
bc3b9e5114 Implement callsite-hotness based inline cost for Sample-based PGO
Summary:
For sample-based PGO, using BFI to calculate callsite count is sometime not accurate. This is because with sampling based approach, if a callsite resides in a hot loop deeply nested in a bunch of cold branches, the callsite's BFI frequency would be inaccurately calculated due to lack of samples in the cold branch.

E.g.

if (A1 && A2 && A3 && ..... && A10) {
  for (i=0; i < 100000000; i++) {
    callsite();
  }
}

Assume that A1 to A100 are all 100% taken, and callsite has 1000 samples and thus is considerred hot. Because the loop's trip count is huge, it's normal that all branches outside the loop has no sample at all. As a result, we can only use static branch probability to derive the the frequency of the loop header. Assuming that static heuristic thinks each branch is 50% taken, then the count calculated from BFI will be 1/(2^10) of the actual value.

In order to get more accurate callsite count, we directly annotate the weight on the call instruction, and directly use it when checking callsite hotness.

Note that this mechanism can also be shared by instrumentation based callsite hotness analysis. The side benefit is that it breaks the dependency from Inliner to BFI as call count is embedded in the IR.

Reviewers: davidxl, eraman, dnovillo

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D22118

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275073 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 16:48:54 +00:00
Dehao Chen
a47e4c72af Tune the weight propagation algorithm for sample profile.
Summary: Handle the case when there is only one incoming/outgoing edge for a visited basic block: use the block weight to adjust edge weight even when the edge has been visited before. This can help reduce inaccuracies introduced by incorrect basic block profile, as shown in the updated unittest.

Reviewers: davidxl, dnovillo

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D22180

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275072 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 16:40:17 +00:00
Hal Finkel
7f9e1e0b77 Revert r275027 - Let FuncAttrs infer the 'returned' argument attribute
Reverting r275027 and r275033. These seem to cause miscompiles on the AArch64 buildbot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275042 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 04:51:23 +00:00
Hal Finkel
8b01a2f64c Don't use a SmallSet for returned attribute inference
Suggested post-commit by David Majnemer on IRC (following-up on a pre-commit
review comment).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275033 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 01:14:21 +00:00
Hal Finkel
772d8502ad Let FuncAttrs infer the 'returned' argument attribute
A function can have one argument with the 'returned' attribute, indicating that
the associated argument is always the return value of the function. Add
FuncAttrs inference logic.

Differential Revision: http://reviews.llvm.org/D22202

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275027 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-10 22:02:55 +00:00
Benjamin Kramer
a894cad1e7 [ArgPromote] Use function_ref and for-range loops.
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274973 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-09 10:36:36 +00:00
Davide Italiano
0dd611bd69 [PM] Port CrossDSOCFI to the new pass manager.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274962 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-09 03:25:35 +00:00
Piotr Padlewski
8969dd96cc Add 'thinlto_src_module' md with asserts or -enable-import-metadata
Summary:
This way the metadata will be only generated when asserts enabled,
or when -enable-import-metadata specified

FIXED missing colon on requires.

Reviewers: tejohnson, eraman, mehdi_amini

Subscribers: mehdi_amini, llvm-commits

Differential Revision: http://reviews.llvm.org/D22167

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274947 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08 23:01:49 +00:00
Piotr Padlewski
a745089940 Revert "Add 'thinlto_src_module' md with asserts or -enable-import-metadata"
Reverting because of 17463
http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/17463

This reverts commit d20cb431bba2ba43b4c65a8556cff445bfefbb7c.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274946 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08 22:55:48 +00:00
Piotr Padlewski
d20cb431bb Add 'thinlto_src_module' md with asserts or -enable-import-metadata
Summary:
This way the metadata will be only generated when asserts enabled,
or when -enable-import-metadata specified

Reviewers: tejohnson, eraman, mehdi_amini

Subscribers: mehdi_amini, llvm-commits

Differential Revision: http://reviews.llvm.org/D22167

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274938 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08 21:25:39 +00:00
Dehao Chen
432e623b14 Remove inline hints computation from SampleProfile.cpp
Summary: As we will move to use uniformed hotness check in inliner, we do not need inline hints in SampleProfile pass any more.

Reviewers: dnovillo, davidxl

Subscribers: eraman, llvm-commits

Differential Revision: http://reviews.llvm.org/D19287

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274918 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08 20:12:44 +00:00
Davide Italiano
0a70e9ac52 [CrossDSOCFI] Change the pass so that it doesn't require doInitialization()
Differential Revision:  http://reviews.llvm.org/D21357

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274910 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08 19:30:06 +00:00
Piotr Padlewski
a5ef55b509 Add 'thinlto_src_module' metadata to imported function
Added metadata to be able to make statistics on how many functions
that have been imported have been removed. Also module name might
be helpfull when debugging.

Reviewers: tejohnson, eraman

Subscribers: mehdi_amini, llvm-commits

Differential Revision: http://reviews.llvm.org/D21943

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274668 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 20:26:25 +00:00
Piotr Padlewski
d459f38473 NFC changed names in FunctionImport
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274649 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 18:12:23 +00:00
George Burgess IV
3b5b98a488 [CFLAA] Split into Anders+Steens analysis.
StratifiedSets (as implemented) is very fast, but its accuracy is also
limited. If we take a more aggressive andersens-like approach, we can be
way more accurate, but we'll also end up being slower.

So, we've decided to split CFLAA into CFLSteensAA and CFLAndersAA.

Long-term, we want to end up in a place where CFLSteens is queried
first; if it can provide an answer, great (since queries are basically
map lookups). Otherwise, we'll fall back to CFLAnders, BasicAA, etc.

This patch splits everything out so we can try to do something like
that when we get a reasonable CFLAnders implementation.

Patch by Jia Chen.

Differential Revision: http://reviews.llvm.org/D21910


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274589 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 00:26:41 +00:00
Sean Silva
ad5ea26278 [PM] Some preparatory refactoring to minimize the diff of D21921
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274456 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-03 03:35:03 +00:00
Sean Silva
e82e4ddb87 Remove dead TLI arg of isKnownNonNull and propagate deadness. NFC.
This actually uncovered a surprisingly large chain of ultimately unused
TLI args.
From what I can gather, this argument is a remnant of when
isKnownNonNull would look at the TLI directly.
The current approach seems to be that InferFunctionAttrs runs early in
the pipeline and uses TLI to annotate the TLI-dependent non-null
information as return attributes.

This also removes the dependence of functionattrs on TLI altogether.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274455 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-02 23:47:27 +00:00
Sean Silva
2cea4e67ba [PM] Some preparatory refactoring to minimize the diff of D21921
The main change here is just moving stuff to static functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274446 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-02 19:12:56 +00:00
Sean Silva
197a7516a3 [PM] Preparatory cleanups to ArgumentPromotion.
This pulls some obvious changes out of http://reviews.llvm.org/D21921 to
minimize the diff.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274445 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-02 18:59:51 +00:00
Duncan P. N. Exon Smith
d88fd1226e Revert "code hoisting pass based on GVN"
This reverts commit r274305, since it breaks self-hosting:
  http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_build/22349/
  http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/17232

Note that the blamelist on lab.llvm.org:8011 is incorrect.  The previous
build was r274299, but somehow r274305 wasn't included in the blamelist:
  http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274320 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-01 01:51:40 +00:00
Sebastian Pop
164e0c1535 code hoisting pass based on GVN
This pass hoists duplicated computations in the program. The primary goal of
gvn-hoist is to reduce the size of functions before inline heuristics to reduce
the total cost of function inlining.

Pass written by Sebastian Pop, Aditya Kumar, Xiaoyu Hu, and Brian Rzycki.
Important algorithmic contributions by Daniel Berlin under the form of reviews.

Differential Revision: http://reviews.llvm.org/D19338

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274305 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-01 00:24:31 +00:00
Easwaran Raman
78b1ab747b [PM] Port PartialInlining to the new PM
Differential revision: http://reviews.llvm.org/D21699



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273894 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-27 16:50:18 +00:00
Benjamin Kramer
5288df58b7 Apply clang-tidy's modernize-loop-convert to most of lib/Transforms.
Only minor manual fixes. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273808 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-26 12:28:59 +00:00
David Majnemer
db5173a31d Revert "[SimplifyCFG] Stop inserting calls to llvm.trap for UB"
This reverts commit r273778, it seems to break UBSan :/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273779 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-25 08:19:55 +00:00
David Majnemer
46e1183e69 [SimplifyCFG] Stop inserting calls to llvm.trap for UB
SimplifyCFG had logic to insert calls to llvm.trap for two very
particular IR patterns: stores and invokes of undef/null.

While InstCombine canonicalizes certain undefined behavior IR patterns
to stores of undef, phase ordering means that this cannot be relied upon
in general.

There are much better tools than llvm.trap: UBSan and ASan.

N.B. I could be argued into reverting this change if a clear argument as
to why it is important that we synthesize llvm.trap for stores, I'd be
hard pressed to see why it'd be useful for invokes...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273778 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-25 08:04:19 +00:00
Peter Collingbourne
02296e214b IR: Introduce llvm.type.checked.load intrinsic.
This intrinsic safely loads a function pointer from a virtual table pointer
using type metadata. This intrinsic is used to implement control flow integrity
in conjunction with virtual call optimization. The virtual call optimization
pass will optimize away llvm.type.checked.load intrinsics associated with
devirtualized calls, thereby removing the type check in cases where it is
not needed to enforce the control flow integrity constraint.

This patch also introduces the capability to copy type metadata between
global variables, and teaches the virtual call optimization pass to do so.

Differential Revision: http://reviews.llvm.org/D21121

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273756 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-25 00:23:04 +00:00
Dehao Chen
51f85a493d Hookup ProfileSummary with SampleProfilerLoader
Summary: Set ProfileSummary in SampleProfilerLoader.

Reviewers: davidxl, eraman

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D21702

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273745 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 22:57:06 +00:00
Peter Collingbourne
8a380d8f16 Fix unused variable warning in -asserts builds.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273737 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 21:37:11 +00:00
Peter Collingbourne
dba9146333 IR: New representation for CFI and virtual call optimization pass metadata.
The bitset metadata currently used in LLVM has a few problems:

1. It has the wrong name. The name "bitset" refers to an implementation
   detail of one use of the metadata (i.e. its original use case, CFI).
   This makes it harder to understand, as the name makes no sense in the
   context of virtual call optimization.

2. It is represented using a global named metadata node, rather than
   being directly associated with a global. This makes it harder to
   manipulate the metadata when rebuilding global variables, summarise it
   as part of ThinLTO and drop unused metadata when associated globals are
   dropped. For this reason, CFI does not currently work correctly when
   both CFI and vcall opt are enabled, as vcall opt needs to rebuild vtable
   globals, and fails to associate metadata with the rebuilt globals. As I
   understand it, the same problem could also affect ASan, which rebuilds
   globals with a red zone.

This patch solves both of those problems in the following way:

1. Rename the metadata to "type metadata". This new name reflects how
   the metadata is currently being used (i.e. to represent type information
   for CFI and vtable opt). The new name is reflected in the name for the
   associated intrinsic (llvm.type.test) and pass (LowerTypeTests).

2. Attach metadata directly to the globals that it pertains to, rather
   than using the "llvm.bitsets" global metadata node as we are doing now.
   This is done using the newly introduced capability to attach
   metadata to global variables (r271348 and r271358).

See also: http://lists.llvm.org/pipermail/llvm-dev/2016-June/100462.html

Differential Revision: http://reviews.llvm.org/D21053

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273729 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 21:21:32 +00:00
Peter Collingbourne
277258478e IR: Introduce Module::global_objects().
This is a convenience iterator that allows clients to enumerate the
GlobalObjects within a Module.

Also start using it in a few places where it is obviously the right thing
to use.

Differential Revision: http://reviews.llvm.org/D21580

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273470 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 20:29:42 +00:00