llvm-project/llvm/lib/Transforms/IPO
Hideto Ueno 96e6ce4cd3 [Attributor][MustExec] Deduce dereferenceable and nonnull attribute using MustBeExecutedContextExplorer
Summary:
In D65186 and related patches, MustBeExecutedContextExplorer is introduced. This enables us to traverse instructions guaranteed to execute from function entry. If we can know the argument is used as `dereferenceable` or `nonnull` in these instructions, we can mark `dereferenceable` or `nonnull` in the argument definition:

1. Memory instruction (similar to D64258)
Trace memory instruction pointer operand. Currently, only inbounds GEPs are traced.
```
define i64* @f(i64* %a) {
entry:
  %add.ptr = getelementptr inbounds i64, i64* %a, i64 1
; (because of inbounds GEP we can know that %a is at least dereferenceable(16))
  store i64 1, i64* %add.ptr, align 8
  ret i64* %add.ptr ; dereferenceable 8 (because above instruction stores into it)
}
```

2. Propagation from callsite (similar to D27855)
If `deref` or `nonnull` are known in call site parameter attributes we can also say that argument also that attribute.

```
declare void @use3(i8* %x, i8* %y, i8* %z);
declare void @use3nonnull(i8* nonnull %x, i8* nonnull %y, i8* nonnull %z);

define void @parent1(i8* %a, i8* %b, i8* %c) {
  call void @use3nonnull(i8* %b, i8* %c, i8* %a)
; Above instruction is always executed so we can say that@parent1(i8* nonnnull %a, i8* nonnull %b, i8* nonnull %c)
  call void @use3(i8* %c, i8* %a, i8* %b)
  ret void
}
```

Reviewers: jdoerfert, sstefan1, spatel, reames

Reviewed By: jdoerfert

Subscribers: xbolva00, hiraditya, jfb, llvm-commits

Tags: #llvm

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

llvm-svn: 374063
2019-10-08 15:25:56 +00:00
..
AlwaysInliner.cpp [clang][NewPM] Fix broken -O0 test from missing assumptions 2019-06-13 18:18:40 +00:00
ArgumentPromotion.cpp [Alignment][NFC] Remove LoadInst::setAlignment(unsigned) 2019-09-30 09:37:05 +00:00
Attributor.cpp [Attributor][MustExec] Deduce dereferenceable and nonnull attribute using MustBeExecutedContextExplorer 2019-10-08 15:25:56 +00:00
BarrierNoopPass.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
BlockExtractor.cpp [BlockExtractor] Avoid assert with wrong line format 2019-08-20 14:46:02 +00:00
CMakeLists.txt [Attributor] Pass infrastructure and fixpoint framework 2019-06-05 03:02:24 +00:00
CalledValuePropagation.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ConstantMerge.cpp IR. Change strip* family of functions to not look through aliases. 2019-08-22 19:56:14 +00:00
CrossDSOCFI.cpp cfi-icall: Allow the jump table to be optionally made non-canonical. 2019-08-09 22:31:59 +00:00
DeadArgumentElimination.cpp [opaque pointer types] Pass function types to CallInst creation. 2019-02-01 20:43:25 +00:00
ElimAvailExtern.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ExtractGV.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ForceFunctionAttrs.cpp ARM MTE stack sanitizer. 2019-07-15 20:02:23 +00:00
FunctionAttrs.cpp [FunctionAttrs] Enable nonnull arg propagation 2019-09-23 09:58:02 +00:00
FunctionImport.cpp [ThinLTO] Fix handling of weak interposable symbols 2019-08-23 15:18:58 +00:00
GlobalDCE.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
GlobalOpt.cpp Recommit "[GlobalOpt] Pass DTU to removeUnreachableBlocks instead of recomputing." 2019-10-02 20:40:13 +00:00
GlobalSplit.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HotColdSplitting.cpp Invalidate assumption cache before outlining. 2019-10-04 22:46:42 +00:00
IPConstantPropagation.cpp [IPCP] Don't crash due to arg count/type mismatch between caller/callee 2019-01-29 10:19:44 +00:00
IPO.cpp [LLVM-C][Ocaml] Add MergeFunctions and DCE pass 2019-09-29 16:06:22 +00:00
InferFunctionAttrs.cpp Change TargetLibraryInfo analysis passes to always require Function 2019-09-07 03:09:36 +00:00
InlineSimple.cpp [CallSite removal] move InlineCost to CallBase usage 2019-04-23 12:43:27 +00:00
Inliner.cpp [Alignment][NFC] Remove AllocaInst::setAlignment(unsigned) 2019-09-30 13:34:44 +00:00
Internalize.cpp [Internalize] Replace uses of std::set with DenseSet 2019-04-02 09:25:31 +00:00
LLVMBuild.txt Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LoopExtractor.cpp [CodeExtractor] Update function's assumption cache after extracting blocks from it 2019-02-08 06:55:18 +00:00
LowerTypeTests.cpp LowerTypeTests: Rename local functions to avoid collisions with identically named functions in ThinLTO modules. 2019-10-03 23:42:44 +00:00
MergeFunctions.cpp Use llvm::stable_sort 2019-04-23 14:51:27 +00:00
PartialInlining.cpp Second attempt to add iterator_range::empty() 2019-10-07 18:14:24 +00:00
PassManagerBuilder.cpp Revert "Reland "r364412 [ExpandMemCmp][MergeICmps] Move passes out of CodeGen into opt pipeline."" 2019-09-10 10:39:09 +00:00
PruneEH.cpp [CallSite removal] Move the legacy PM, call graph, and some inliner 2019-04-19 05:59:42 +00:00
SCCP.cpp Change TargetLibraryInfo analysis passes to always require Function 2019-09-07 03:09:36 +00:00
SampleProfile.cpp [SampleFDO] Create a separate flag profile-accurate-for-symsinlist to handle 2019-09-27 22:33:59 +00:00
StripDeadPrototypes.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StripSymbols.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SyntheticCountsPropagation.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ThinLTOBitcodeWriter.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
WholeProgramDevirt.cpp [ThinLTO/WPD] Ensure devirtualized targets use promoted symbol when necessary 2019-10-02 16:36:59 +00:00