1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
llvm-mirror/lib/Analysis
Peter Collingbourne 41f4d00801 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

llvm-svn: 273756
2016-06-25 00:23:04 +00:00
..
AliasAnalysis.cpp Fix AAResults::callCapturesBefore for operand bundles 2016-06-13 19:55:04 +00:00
AliasAnalysisEvaluator.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
AliasSetTracker.cpp [AliasSetTracker] Correctly handle changing the size of an entry 2016-04-14 22:00:11 +00:00
Analysis.cpp [PM] Port LVI to the new PM. 2016-06-13 22:01:25 +00:00
AssumptionCache.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
BasicAliasAnalysis.cpp Revert "Claim NoAlias if two GEPs index different fields of the same struct" 2016-06-01 18:55:32 +00:00
BlockFrequencyInfo.cpp [BFI]: NFC refactoring 2016-06-22 17:12:12 +00:00
BlockFrequencyInfoImpl.cpp [BFI]: NFC refactoring 2016-06-22 17:12:12 +00:00
BranchProbabilityInfo.cpp [PPC] Strength-reduce SmallVectors into arrays. 2016-06-17 13:15:10 +00:00
CallGraph.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
CallGraphSCCPass.cpp Interprocedural Register Allocation (IPRA) Analysis 2016-06-10 16:19:46 +00:00
CallPrinter.cpp [CG] Rename the DOT printing pass to actually reference "DOT". 2016-03-10 11:04:40 +00:00
CaptureTracking.cpp [CaptureTracking] Volatile operations capture their memory location 2016-05-26 17:36:22 +00:00
CFG.cpp Avoid overly large SmallPtrSet/SmallSet 2016-01-30 01:24:31 +00:00
CFGPrinter.cpp Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
CFLAliasAnalysis.cpp Attempt to fix MSVC breakage caused by r273636. 2016-06-24 01:41:29 +00:00
CGSCCPassManager.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
CMakeLists.txt IR: New representation for CFI and virtual call optimization pass metadata. 2016-06-24 21:21:32 +00:00
CodeMetrics.cpp use range-based for loop; NFCI 2016-03-08 20:53:48 +00:00
ConstantFolding.cpp Replace silly uses of 'signed' with 'int' 2016-06-21 05:10:24 +00:00
CostModel.cpp [CodeGen] Teach LLVM how to lower @llvm.{min,max}num to {MIN,MAX}NAN 2016-04-14 07:13:24 +00:00
Delinearization.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
DemandedBits.cpp Port DemandedBits to the new pass manager. 2016-04-18 23:55:01 +00:00
DependenceAnalysis.cpp Apply most suggestions of clang-tidy's performance-unnecessary-value-param 2016-06-08 19:09:22 +00:00
DivergenceAnalysis.cpp DivergenceAnalysis: Fix crash with no return blocks 2016-05-09 16:57:08 +00:00
DominanceFrontier.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
DomPrinter.cpp Introduce analysis pass to compute PostDominators in the new pass manager. NFC 2016-02-25 17:54:07 +00:00
EHPersonalities.cpp X86: permit using SjLj EH on x86 targets as an option 2016-05-31 01:48:07 +00:00
GlobalsModRef.cpp Don't IPO over functions that can be de-refined 2016-04-08 00:48:30 +00:00
InlineCost.cpp Use ProfileSummaryInfo in inline cost analysis. 2016-06-09 22:23:21 +00:00
InstCount.cpp Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
InstructionSimplify.cpp [InstSimplify] analyze (optionally casted) icmps to eliminate obviously false logic (PR27869) 2016-06-20 20:59:59 +00:00
Interval.cpp Revert "[C++11] Add predecessors(BasicBlock *) / successors(BasicBlock *) iterator ranges." 2014-07-21 17:06:51 +00:00
IntervalPartition.cpp [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-15 04:59:12 +00:00
IteratedDominanceFrontier.cpp Correct IDF calculator for ReverseIDF 2016-04-19 06:13:28 +00:00
IVUsers.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
LazyCallGraph.cpp Add a super basic LazyCallGraph DOT printer. 2016-06-18 09:17:32 +00:00
LazyValueInfo.cpp [PM] Port LVI to the new PM. 2016-06-13 22:01:25 +00:00
Lint.cpp [opaque pointer types] [NFC] FindAvailableLoadedValue: take LoadInst instead of just the pointer. 2016-01-22 01:51:51 +00:00
LLVMBuild.txt Revert r269131 2016-05-10 23:26:04 +00:00
Loads.cpp Fix documentation for FindAvailableLoadedValue. 2016-06-24 21:32:15 +00:00
LoopAccessAnalysis.cpp [PM]: LoopAccessInfo simple refactoring 2016-06-22 23:20:59 +00:00
LoopInfo.cpp [PM] Remove support for omitting the AnalysisManager argument to new 2016-06-17 00:11:01 +00:00
LoopPass.cpp Fix dynamically linked debug builds. 2016-06-20 02:48:11 +00:00
LoopPassManager.cpp PM: Check that loop passes preserve a basic set of analyses 2016-05-03 21:35:08 +00:00
LoopUnrollAnalyzer.cpp [LoopUnrollAnalyzer] Fix a bug in UnrolledInstAnalyzer::visitLoad. 2016-06-23 14:31:31 +00:00
MemDepPrinter.cpp [PM] Port memdep to the new pass manager. 2016-03-10 00:55:30 +00:00
MemDerefPrinter.cpp NFC. Move isDereferenceable to Loads.h/cpp 2016-02-24 12:49:04 +00:00
MemoryBuiltins.cpp Calculate __builtin_object_size when pointer depends on a condition 2016-04-13 12:25:25 +00:00
MemoryDependenceAnalysis.cpp Avoid duplicated map lookups. No functionality change intended. 2016-06-17 18:59:41 +00:00
MemoryLocation.cpp [TLI] Unify LibFunc signature checking. NFCI. 2016-04-27 19:04:35 +00:00
ModuleDebugInfoPrinter.cpp Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
ModuleSummaryAnalysis.cpp ThinLTO: fix assertion and refactor check for hidden use from inline ASM in a helper function 2016-05-06 08:25:33 +00:00
ObjCARCAliasAnalysis.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
ObjCARCAnalysisUtils.cpp [ARC] Pull the ObjC ARC components that really serve the role of 2015-08-20 08:06:03 +00:00
ObjCARCInstKind.cpp Add support for objc_unsafeClaimAutoreleasedReturnValue to the 2016-01-27 19:05:08 +00:00
OrderedBasicBlock.cpp [CaptureTracker] Provide an ordered basic block to PointerMayBeCapturedBefore 2015-07-31 14:31:35 +00:00
PHITransAddr.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
PostDominators.cpp [PM] Remove support for omitting the AnalysisManager argument to new 2016-06-17 00:11:01 +00:00
ProfileSummaryInfo.cpp [PM] Remove support for omitting the AnalysisManager argument to new 2016-06-17 00:11:01 +00:00
PtrUseVisitor.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
README.txt
RegionInfo.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
RegionPass.cpp Change range-based for-loops to be -Wrange-loop-analysis clean. 2015-04-15 01:21:15 +00:00
RegionPrinter.cpp [RegionInfo] Add debug-time region viewer functions 2015-08-10 13:21:59 +00:00
ScalarEvolution.cpp [SCEV] Fix incorrect trip count computation 2016-06-18 04:38:31 +00:00
ScalarEvolutionAliasAnalysis.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
ScalarEvolutionExpander.cpp Avoid output indeterminism between GCC and Clang builds. 2016-06-20 10:19:04 +00:00
ScalarEvolutionNormalization.cpp Remove emacs mode markers from .cpp files. NFC 2016-04-24 17:55:41 +00:00
ScopedNoAliasAA.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
SparsePropagation.cpp Analysis: Remove implicit ilist iterator conversions 2015-10-10 00:53:03 +00:00
StratifiedSets.h [CFLAA] Propagate StratifiedAttrs in interproc. analysis. 2016-06-24 01:00:03 +00:00
TargetLibraryInfo.cpp [TargetLibraryInfo] Reduce code duplication. 2016-06-21 04:32:21 +00:00
TargetTransformInfo.cpp [PM] Remove support for omitting the AnalysisManager argument to new 2016-06-17 00:11:01 +00:00
Trace.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
TypeBasedAliasAnalysis.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
TypeMetadataUtils.cpp IR: Introduce llvm.type.checked.load intrinsic. 2016-06-25 00:23:04 +00:00
ValueTracking.cpp [ValueTracking] simplify logic in ComputeNumSignBits (NFCI) 2016-06-23 17:41:59 +00:00
VectorUtils.cpp [Analysis] Enabled BITREVERSE as a vectorizable intrinsic 2016-06-04 20:21:07 +00:00

Analysis Opportunities:

//===---------------------------------------------------------------------===//

In test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll, the
ScalarEvolution expression for %r is this:

  {1,+,3,+,2}<loop>

Outside the loop, this could be evaluated simply as (%n * %n), however
ScalarEvolution currently evaluates it as

  (-2 + (2 * (trunc i65 (((zext i64 (-2 + %n) to i65) * (zext i64 (-1 + %n) to i65)) /u 2) to i64)) + (3 * %n))

In addition to being much more complicated, it involves i65 arithmetic,
which is very inefficient when expanded into code.

//===---------------------------------------------------------------------===//

In formatValue in test/CodeGen/X86/lsr-delayed-fold.ll,

ScalarEvolution is forming this expression:

((trunc i64 (-1 * %arg5) to i32) + (trunc i64 %arg5 to i32) + (-1 * (trunc i64 undef to i32)))

This could be folded to

(-1 * (trunc i64 undef to i32))

//===---------------------------------------------------------------------===//