aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/StackSafetyAnalysis.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-07-10StackSafetyAnalysis.cpp - pass ConstantRange arg as const reference.Simon Pilgrim1-3/+3
Avoids unnecessary copies and silences clang tidy warning - we do this in most places, there are just a few that were missed.
2020-07-08[StackSafety,NFC] Update documentationVitaly Buka1-2/+9
It's follow up for D80908 Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D82941
2020-07-01[StackSafety,NFC] Remove expensive assertVitaly Buka1-2/+0
Differential Revision: https://reviews.llvm.org/D80908
2020-06-22[StackSafety] Check variable lifetimeVitaly Buka1-0/+14
We can't consider variable safe if out-of-lifetime access is possible. So if StackLifetime can't prove that the instruction always uses the variable when it's still alive, we consider it unsafe.
2020-06-22[StackSafety] Ignore unreachable instructionsVitaly Buka1-9/+21
Usually DominatorTree provides this info, but here we use StackLifetime. The reason is that in the next patch StackLifetime will be used for actual lifetime checks and we can avoid forwarding the DominatorTree into this code.
2020-06-13Fix GCC5 build by renaming variable used in 'auto' deduction (NFC)Mehdi Amini1-3/+3
GCC5 errors out with: llvm/lib/Analysis/StackSafetyAnalysis.cpp:935:21: error: use of 'KV' before deduction of 'auto' for (auto &KV : KV.second.Params) { ^
2020-06-12[StackSafety] Run ThinLTOVitaly Buka1-4/+111
Summary: ThinLTO linking runs dataflow processing on collected function parameters. Then StackSafetyGlobalInfoWrapperPass in ThinLTO backend will run as usual looking up to external symbol in the summary if needed. Depends on D80985. Reviewers: eugenis, pcc Reviewed By: eugenis Subscribers: inglorion, hiraditya, steven_wu, dexonsmith, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D81242
2020-06-12[StackSafety,NFC] Extract addOverflowNeverVitaly Buka1-8/+9
2020-06-11[StackSafety] Fix byval handlingVitaly Buka1-3/+11
We don't need process paramenters which marked as byval as we are not going to pass interested allocas without copying. If we pass value into byval argument, we just handle that as Load of corresponding type and stop that branch of analysis.
2020-06-11[StackSafety,NFC] Fix use of CallBase APIVitaly Buka1-15/+8
Code does not need iterate arguments and can get ArgNo from CallBase::getArgOperandNo.
2020-06-10[StackSafety] Pass summary into codegenVitaly Buka1-9/+25
Summary: The patch wraps ThinLTO index into immutable pass which can be used by StackSafety analysis. Reviewers: eugenis, pcc Reviewed By: eugenis Subscribers: hiraditya, steven_wu, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80985
2020-06-10[StackSafety] Add info into function summaryVitaly Buka1-0/+34
Summary: This patch adds optional field into function summary, implements asm and bitcode serialization. YAML serialization is omitted and can be added later if needed. This patch includes this information into summary only if module contains at least one sanitize_memtag function. In a near future MTE is the user of the analysis. Later if needed we can provede more direct control on when information is included into summary. Reviewers: eugenis Subscribers: hiraditya, steven_wu, dexonsmith, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80908
2020-06-07SmallPtrSet::find -> SmallPtrSet::countBenjamin Kramer1-1/+1
The latter is more readable and more efficient. While there clean up some double lookups. NFCI.
2020-06-04[StackSafety,NFC] Ignore callee declarationsVitaly Buka1-1/+1
It's going to fail FunctionInfo lookup anyway.
2020-06-04[StackSafety] Rename testing optsVitaly Buka1-3/+6
2020-06-04[StackSafety,NFC] Remove SCEVRewriteVisitorVitaly Buka1-23/+7
Summary: Depends on D80956. Reviewers: eugenis Reviewed By: eugenis Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80976
2020-06-03[StackSafety,NFC] Add statistic countersVitaly Buka1-1/+8
2020-06-03[NFC,StackSafety] Fix template arg nameVitaly Buka1-2/+2
2020-06-03[StackSafety,NFC] Convert to template internal stuffVitaly Buka1-50/+54
It's going to be usefull for ThinLTO.
2020-06-03[StackSafety,NFC] Rename internal classVitaly Buka1-4/+4
2020-06-03[StackSafety] Skip non-pointer parametersVitaly Buka1-35/+31
Summary: Depends on D80908. Reviewers: eugenis, pcc Reviewed By: eugenis Subscribers: hiraditya, steven_wu, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80956
2020-06-03[NFC, StackSafety] Change type of internal containerVitaly Buka1-26/+13
Summary: Depends on D80771. Reviewers: eugenis Reviewed By: eugenis Subscribers: mehdi_amini, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80847
2020-06-03Revert "[NFC, StackSafety] Change type of internal container"Mehdi Amini1-12/+25
This reverts commit f62813e7eae148a6175de28bfa384524a9f2bf94. GCC 5.3 build is broken.
2020-06-02[NFC, StackSafety] Change type of internal containerVitaly Buka1-25/+12
Summary: Depends on D80771. Reviewers: eugenis Reviewed By: eugenis Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80847
2020-06-02[MTE] Convert StackSafety into analysisVitaly Buka1-43/+28
This lets us to remove !stack-safe metadata and better controll when to perform StackSafety analysis. Reviewers: eugenis Subscribers: hiraditya, steven_wu, dexonsmith, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D80771
2020-05-28[NFC,StackSafety] Add test flagVitaly Buka1-1/+9
2020-05-28[NFC,StackSafety] clang-tidy warning fixesVitaly Buka1-18/+16
2020-05-28[StackSafety] Lazy calculationsVitaly Buka1-59/+83
We are going to convert this into pure analysis, so processing will be delayed up to the first safety request.
2020-05-28[NFC,StackSafety] Move internal offset calculationVitaly Buka1-10/+18
2020-05-28[StackSafety] Don't run datafow on allocasVitaly Buka1-80/+117
We need to process only parameters. Allocas access can be calculated afterwards. Also don't create fake function for aliases and just resolve them on initialization.
2020-05-28[StackSafety] Remove SetMetadata parameterVitaly Buka1-6/+5
2020-05-27[NFC,StackSafety] Add StackSafetyGlobalInfo classVitaly Buka1-18/+24
2020-05-27[NFC,StackSafety] Cleanup alloca size calculationVitaly Buka1-28/+40
2020-05-27[NFC,StackSafety] Rename some variablesVitaly Buka1-11/+11
2020-05-27[StackSafety] Bailout more aggressivelyVitaly Buka1-11/+27
Many edge cases, e.g. wrapped ranges, can be processed precisely without bailout. However it's very unlikely that memory access with min/max integer offsets will be classified as safe anyway. Early bailout may help with ThinLTO where we can drop unsafe parameters from summaries.
2020-05-27[StackSafety] Bailout on some function callsVitaly Buka1-0/+6
Don't miss values used in calls outside regular argument list.
2020-05-27[StackSafety] Ignore some use of valuesVitaly Buka1-2/+2
We should ignore value used in MemTransferInst as other then src/dst argument.
2020-05-26[StackSafety] Use SCEV to find mem operation lengthVitaly Buka1-9/+16
2020-05-26[StackSafety] Use getSignedRange for offsetsVitaly Buka1-3/+3
2020-05-26[StackSafety] Simplify SCEVRewriteVisitorVitaly Buka1-11/+2
Probably NFC.
2020-05-26[NFC, StackSafety] Add some missing includesVitaly Buka1-0/+6
2020-05-26[NFC, StackSafety] Remove duplicate codeVitaly Buka1-8/+1
2020-05-26[NFC, StackSafety] Better names for internal stuffVitaly Buka1-20/+16
Remove const from some parameters as upcoming changes in ScalarEvolution calls will need non const pointers.
2020-05-26[NFC, StackSafety] Remove unnecessary dataVitaly Buka1-84/+80
2020-05-26[NFC, StackSafety] Move FunctionInfo into :: namespaceVitaly Buka1-40/+43
2020-05-15[NFC,StackSafety] Rename local functionVitaly Buka1-26/+26
2020-04-27[IR] Replace all uses of CallBase::getCalledValue() with getCalledOperand().Craig Topper1-1/+1
This method has been commented as deprecated for a while. Remove it and replace all uses with the equivalent getCalledOperand(). I also made a few cleanups in here. For example, to removes use of getElementType on a pointer when we could just use getFunctionType from the call. Differential Revision: https://reviews.llvm.org/D78882
2020-04-23[llvm][NFC][CallSite] Remove ImmutableCallSite from a few locationsMircea Trofin1-5/+4
Reviewers: craig.topper, dblaikie Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78783
2020-03-16[memtag] Plug in stack safety analysis.Evgenii Stepanov1-9/+43
Summary: Run StackSafetyAnalysis at the end of the IR pipeline and annotate proven safe allocas with !stack-safe metadata. Do not instrument such allocas in the AArch64StackTagging pass. Reviewers: pcc, vitalybuka, ostannard Reviewed By: vitalybuka Subscribers: merge_guards_bot, kristof.beyls, hiraditya, cfe-commits, gilang, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D73513
2020-01-27Support zero size types in StackSafetyAnalysis.Evgenii Stepanov1-0/+4
Reviewers: vitalybuka Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73395