summaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/StackSafetyAnalysis.cpp
AgeCommit message (Collapse)Author
2025-11-12Remove unused standard headers: memory, unordered_* (#167297)serge-sans-paille
2025-10-21[ThinLTO] Make SummaryList private (NFC) (#164355)Teresa Johnson
In preparation for a follow on change that will require checking every time a new summary is added to the SummaryList for a GUID, make the SummaryList private and require all accesses to go through one of two new interfaces. Most changes are to access the list via the read only getSummaryList() method, and the few that add new summaries (e.g. while building the combined summary) use the new addSummary() method.
2025-04-21[LLVM] Cleanup pass initialization for Analysis passes (#135858)Rahul Joshi
- Do not call pass initialization from pass constructors. - Instead, pass initialization should happen in the `initializeAnalysis` function. - https://github.com/llvm/llvm-project/issues/111767
2025-03-25[Analysis] Use *Set::insert_range (NFC) (#132878)Kazu Hirata
We can use *Set::insert_range to collapse: for (auto Elem : Range) Set.insert(E); down to: Set.insert_range(Range); In some cases, we can further fold that into the set declaration.
2024-10-29[StackSafetyAnalysis] Bail out when calling ifuncFangrui Song
An assertion failure arises when a call instruction calls a GlobalIFunc. Since we cannot reason about the underlying function, just bail out. Fix #87923 Pull Request: https://github.com/llvm/llvm-project/pull/113841
2024-06-28[IR] Add getDataLayout() helpers to Function and GlobalValue (#96919)Nikita Popov
Similar to https://github.com/llvm/llvm-project/pull/96902, this adds `getDataLayout()` helpers to Function and GlobalValue, replacing the current `getParent()->getDataLayout()` pattern.
2024-06-27[IR] Add getDataLayout() helpers to BasicBlock and Instruction (#96902)Nikita Popov
This is a helper to avoid writing `getModule()->getDataLayout()`. I regularly try to use this method only to remember it doesn't exist... `getModule()->getDataLayout()` is also a common (the most common?) reason why code has to include the Module.h header.
2024-06-14[llvm] Use llvm::unique (NFC) (#95628)Kazu Hirata
2024-01-30[StackSafetyAnalysis] Don't call getTruncateOrZeroExtend for pointers of ↵Pierre van Houtryve
different sizes (#79804) Otherwise SCEV asserts `Can't extend pointer!` Fixes SWDEV-442670
2024-01-11[StackSafetyAnalysis] Bail out if MemIntrinsic length is -1 (#77837)Fangrui Song
Clang generates llvm.memset.p0.i64 with a length of -1 for the following code in `-stdlib=libc++ -std=c++20` mode (https://github.com/llvm/llvm-project/pull/77210#issuecomment-1887650010) ```cpp bool strtof_clamp(const std::string &str); void floatsuffix_check(char *yytext_r) { std::string text = yytext_r; text.resize(text.size() - 1); strtof_clamp(text); } ``` `Sizes = [0xffffffffffffffff, 0)`. `SizeRange = [0, 0-1)`, leading to `assert(!isUnsafe(SizeRange));` failure. Bail out if the length is -1. Other negative values are handled by the existing condition.
2023-11-07[NFC] Remove Type::getInt8PtrTy (#71029)Paulo Matos
Replace this with PointerType::getUnqual(). Followup to the opaque pointer transition. Fixes an in-code TODO item.
2023-08-31Support atomic write operations in stack safetyFlorian Mayer
This has two benefits: * we can now mark allocas that are used in atomic operations as safe * this fixes a bug that would incorrectly mark all atomic writes as safe in HWASan instrumentation. this is because stack safety keeps a list of all *unsafe* operations that are reachable from an alloca, but it did not analyze atomic writes, so it would always mark them as safe. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D159153
2023-01-11[NFC] Use TypeSize::geFixedValue() instead of TypeSize::getFixedSize()Guillaume Chatelet
This change is one of a series to implement the discussion from https://reviews.llvm.org/D141134.
2022-07-16[Analysis] Qualify auto variables in for loops (NFC)Kazu Hirata
2022-06-18[llvm] Use value_or instead of getValueOr (NFC)Kazu Hirata
2022-03-01Cleanup includes: LLVMAnalysisserge-sans-paille
Number of lines output by preprocessor: before: 1065940348 after: 1065307662 Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D120659
2021-11-23[stack-safety] Check SCEV constraints at memory instructions.Florian Mayer
Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D113160
2021-10-18[Sanitizers] Replaced getMaxPointerSizeInBits with getPointerSizeInBits, ↵Kirill Stoimenov
which was causing failures for 32bit x86. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D111829
2021-10-06[IR][NFC] Rename getBaseObject to getAliaseeObjectItay Bookstein
To better reflect the meaning of the now-disambiguated {GlobalValue, GlobalAlias}::getBaseObject after breaking off GlobalIFunc::getResolverFunction (D109792), the function is renamed to getAliaseeObject.
2021-09-22[hwasan] also omit safe mem[cpy|mov|set].Florian Mayer
Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D109816
2021-09-19[llvm] Use pop_back_val (NFC)Kazu Hirata
2021-09-13[hwasan] Respect returns attribute when tracking values.Florian Mayer
Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D109233
2021-09-10[stack-safety] Allow to determine safe accesses.Florian Mayer
Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D109503
2021-09-09[APInt] Normalize naming on keep constructors / predicate methods.Chris Lattner
This renames the primary methods for creating a zero value to `getZero` instead of `getNullValue` and renames predicates like `isAllOnesValue` to simply `isAllOnes`. This achieves two things: 1) This starts standardizing predicates across the LLVM codebase, following (in this case) ConstantInt. The word "Value" doesn't convey anything of merit, and is missing in some of the other things. 2) Calling an integer "null" doesn't make any sense. The original sin here is mine and I've regretted it for years. This moves us to calling it "zero" instead, which is correct! APInt is widely used and I don't think anyone is keen to take massive source breakage on anything so core, at least not all in one go. As such, this doesn't actually delete any entrypoints, it "soft deprecates" them with a comment. Included in this patch are changes to a bunch of the codebase, but there are more. We should normalize SelectionDAG and other APIs as well, which would make the API change more mechanical. Differential Revision: https://reviews.llvm.org/D109483
2021-09-09[NFC] [stack-safety] add placeholder addRange.Florian Mayer
This is in preparataion of D108457.
2021-09-09[stack-safety] [NFC] do not terminate print with blank line.Florian Mayer
2021-09-09[NFC] [stack-safety] remove unused return value.Florian Mayer
2021-07-06Recommit [ScalarEvolution] Make getMinusSCEV() fail for unrelated pointers.Eli Friedman
As part of making ScalarEvolution's handling of pointers consistent, we want to forbid multiplying a pointer by -1 (or any other value). This means we can't blindly subtract pointers. There are a few ways we could deal with this: 1. We could completely forbid subtracting pointers in getMinusSCEV() 2. We could forbid subracting pointers with different pointer bases (this patch). 3. We could try to ptrtoint pointer operands. The option in this patch is more friendly to non-integral pointers: code that works with normal pointers will also work with non-integral pointers. And it seems like there are very few places that actually benefit from the third option. As a minimal patch, the ScalarEvolution implementation of getMinusSCEV still ends up subtracting pointers if they have the same base. This should eliminate the shared pointer base, but eventually we'll need to rewrite it to avoid negating the pointer base. I plan to do this as a separate step to allow measuring the compile-time impact. This doesn't cause obvious functional changes in most cases; the one case that is significantly affected is ICmpZero handling in LSR (which is the source of almost all the test changes). The resulting changes seem okay to me, but suggestions welcome. As an alternative, I tried explicitly ptrtoint'ing the operands, but the result doesn't seem obviously better. I deleted the test lsr-undef-in-binop.ll becuase I couldn't figure out how to repair it to test what it was actually trying to test. Recommitting with fix to MemoryDepChecker::isDependent. Differential Revision: https://reviews.llvm.org/D104806
2021-07-06Revert "[ScalarEvolution] Make getMinusSCEV() fail for unrelated pointers."Eli Friedman
This reverts commit 74d6ce5d5f169e9cf3fac0eb1042602e286dd2b9. Seeing crashes on buildbots in MemoryDepChecker::isDependent.
2021-07-06[ScalarEvolution] Make getMinusSCEV() fail for unrelated pointers.Eli Friedman
As part of making ScalarEvolution's handling of pointers consistent, we want to forbid multiplying a pointer by -1 (or any other value). This means we can't blindly subtract pointers. There are a few ways we could deal with this: 1. We could completely forbid subtracting pointers in getMinusSCEV() 2. We could forbid subracting pointers with different pointer bases (this patch). 3. We could try to ptrtoint pointer operands. The option in this patch is more friendly to non-integral pointers: code that works with normal pointers will also work with non-integral pointers. And it seems like there are very few places that actually benefit from the third option. As a minimal patch, the ScalarEvolution implementation of getMinusSCEV still ends up subtracting pointers if they have the same base. This should eliminate the shared pointer base, but eventually we'll need to rewrite it to avoid negating the pointer base. I plan to do this as a separate step to allow measuring the compile-time impact. This doesn't cause obvious functional changes in most cases; the one case that is significantly affected is ICmpZero handling in LSR (which is the source of almost all the test changes). The resulting changes seem okay to me, but suggestions welcome. As an alternative, I tried explicitly ptrtoint'ing the operands, but the result doesn't seem obviously better. I deleted the test lsr-undef-in-binop.ll becuase I couldn't figure out how to repair it to test what it was actually trying to test. Differential Revision: https://reviews.llvm.org/D104806
2021-01-09[llvm] Drop unnecessary make_range (NFC)Kazu Hirata
2020-10-03[Analysis] resolveAllCalls - fix use after std::move warning. NFCI.Simon Pilgrim
We can't use Use.Calls after its std::move()'d to TmpCalls as it will be in an undefined state. Instead, swap with the known empty map in TmpCalls so we can then safely emplace_back into the now empty Use.Calls. Fixes clang static analyzer warning.
2020-09-18[NFC][StackSafety] Replace auto with typeVitaly Buka
Fixes static analyzer is warning.
2020-08-17[NFC][StackSafety] Move out sort from the loopVitaly Buka
2020-08-16[StackSafety] Change how callee searched in indexVitaly Buka
Handle other than local linkage types.
2020-08-14[StackSafety] Use ValueInfo in ParamAccess::CallVitaly Buka
This avoid GUID lookup in Index.findSummaryInModule. Follow up for D81242. Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D85269
2020-08-14Revert "[NFC][StackSafety] Move out sort from the loop"Matt Morehouse
This reverts commit 0426e28419799c35cf52fe3d773c5bab9928c699 due to ASan buildbot failure.
2020-08-14[NFC][StackSafety] Change map key comparisonVitaly Buka
2020-08-14[NFC][StackSafety] Move out sort from the loopVitaly Buka
2020-08-14[NFC][StackSafety] Dedup calleesVitaly Buka
2020-08-09[NFC][StackSafety] Add a couple of early returnsVitaly Buka
2020-08-09[NFC][StackSafety] Count dataflow inputsVitaly Buka
2020-08-09[StackSafety] Fix union which produces wrapped setsVitaly Buka
2020-08-09[NFC][StackSafety] Avoid assert in getBaseObjecVitaly Buka
2020-08-09[StackSafety] Don't keep FullSet in indexVitaly Buka
Optimization. Missing record is enterpreted as FullSet anyway.
2020-08-07[NFC][StackSafety] Fix statisticsVitaly Buka
2020-08-07[StackSafety,NFC] Add Stats countersVitaly Buka
2020-08-06[StackSafety,NFC] Fix tests in debugVitaly Buka
2020-08-06[StackSafety,NFC] Add debug countersVitaly Buka
2020-08-06[StackSafety,NFC] Use CHECK-EMPTY in testsVitaly Buka