llvm-6502/lib/Transforms/IPO
Hal Finkel 16fd27b2c3 Add scoped-noalias metadata
This commit adds scoped noalias metadata. The primary motivations for this
feature are:
  1. To preserve noalias function attribute information when inlining
  2. To provide the ability to model block-scope C99 restrict pointers

Neither of these two abilities are added here, only the necessary
infrastructure. In fact, there should be no change to existing functionality,
only the addition of new features. The logic that converts noalias function
parameters into this metadata during inlining will come in a follow-up commit.

What is added here is the ability to generally specify noalias memory-access
sets. Regarding the metadata, alias-analysis scopes are defined similar to TBAA
nodes:

!scope0 = metadata !{ metadata !"scope of foo()" }
!scope1 = metadata !{ metadata !"scope 1", metadata !scope0 }
!scope2 = metadata !{ metadata !"scope 2", metadata !scope0 }
!scope3 = metadata !{ metadata !"scope 2.1", metadata !scope2 }
!scope4 = metadata !{ metadata !"scope 2.2", metadata !scope2 }

Loads and stores can be tagged with an alias-analysis scope, and also, with a
noalias tag for a specific scope:

... = load %ptr1, !alias.scope !{ !scope1 }
... = load %ptr2, !alias.scope !{ !scope1, !scope2 }, !noalias !{ !scope1 }

When evaluating an aliasing query, if one of the instructions is associated
with an alias.scope id that is identical to the noalias scope associated with
the other instruction, or is a descendant (in the scope hierarchy) of the
noalias scope associated with the other instruction, then the two memory
accesses are assumed not to alias.

Note that is the first element of the scope metadata is a string, then it can
be combined accross functions and translation units. The string can be replaced
by a self-reference to create globally unqiue scope identifiers.

[Note: This overview is slightly stylized, since the metadata nodes really need
to just be numbers (!0 instead of !scope0), and the scope lists are also global
unnamed metadata.]

Existing noalias metadata in a callee is "cloned" for use by the inlined code.
This is necessary because the aliasing scopes are unique to each call site
(because of possible control dependencies on the aliasing properties). For
example, consider a function: foo(noalias a, noalias b) { *a = *b; } that gets
inlined into bar() { ... if (...) foo(a1, b1); ... if (...) foo(a2, b2); } --
now just because we know that a1 does not alias with b1 at the first call site,
and a2 does not alias with b2 at the second call site, we cannot let inlining
these functons have the metadata imply that a1 does not alias with b2.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213864 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-24 14:25:39 +00:00
..
ArgumentPromotion.cpp AA metadata refactoring (introduce AAMDNodes) 2014-07-24 12:16:19 +00:00
BarrierNoopPass.cpp
CMakeLists.txt
ConstantMerge.cpp [C++] Use 'nullptr'. Transforms edition. 2014-04-25 05:29:35 +00:00
DeadArgumentElimination.cpp Constify the Function pointers in the result of makeSubprogramMap 2014-07-02 18:30:05 +00:00
ExtractGV.cpp GlobalValue: Assert symbols with local linkage have default visibility 2014-05-07 23:00:22 +00:00
FunctionAttrs.cpp AA metadata refactoring (introduce AAMDNodes) 2014-07-24 12:16:19 +00:00
GlobalDCE.cpp Revert "GlobalDCE: Delete available_externally initializers if it allows removing the value the initializer is referring to." 2014-07-08 17:06:03 +00:00
GlobalOpt.cpp GlobalOpt: Don't swap private for internal linkage 2014-07-01 15:26:50 +00:00
InlineAlways.cpp Check the alwaysinline attribute on the call as well as on the caller. 2014-05-19 18:25:54 +00:00
Inliner.cpp Add support for missed and analysis optimization remarks. 2014-05-22 14:19:46 +00:00
InlineSimple.cpp [C++] Use 'nullptr'. Transforms edition. 2014-04-25 05:29:35 +00:00
Internalize.cpp LTO: -internalize sets visibility to default 2014-05-05 17:40:44 +00:00
IPConstantPropagation.cpp [C++] Use 'nullptr'. Transforms edition. 2014-04-25 05:29:35 +00:00
IPO.cpp Removing spurious dependency of IPO on JumpInstrTables 2014-06-05 19:43:57 +00:00
LLVMBuild.txt
LoopExtractor.cpp Revert "[C++11] Add predecessors(BasicBlock *) / successors(BasicBlock *) iterator ranges." 2014-07-21 17:06:51 +00:00
Makefile
MergeFunctions.cpp MergeFunc patch from Björn Steinbrink. 2014-07-15 10:46:51 +00:00
PartialInlining.cpp Revert "[C++11] Add predecessors(BasicBlock *) / successors(BasicBlock *) iterator ranges." 2014-07-21 17:06:51 +00:00
PassManagerBuilder.cpp Add scoped-noalias metadata 2014-07-24 14:25:39 +00:00
PruneEH.cpp [C++] Use 'nullptr'. Transforms edition. 2014-04-25 05:29:35 +00:00
StripDeadPrototypes.cpp
StripSymbols.cpp [C++] Use 'nullptr'. Transforms edition. 2014-04-25 05:29:35 +00:00