LLVM  13.0.0git
Assumptions.cpp
Go to the documentation of this file.
1 //===- Assumptions.cpp ------ Collection of helpers for assumptions -------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 //===----------------------------------------------------------------------===//
10 
11 #include "llvm/IR/Assumptions.h"
12 #include "llvm/IR/Attributes.h"
13 #include "llvm/IR/Function.h"
14 
15 using namespace llvm;
16 
18  const KnownAssumptionString &AssumptionStr) {
19  const Attribute &A = F.getFnAttribute(AssumptionAttrKey);
20  if (!A.isValid())
21  return false;
22  assert(A.isStringAttribute() && "Expected a string attribute!");
23 
25  A.getValueAsString().split(Strings, ",");
26 
27  return llvm::any_of(Strings, [=](StringRef Assumption) {
28  return Assumption == AssumptionStr;
29  });
30 }
31 
33  "omp_no_openmp", // OpenMP 5.1
34  "omp_no_openmp_routines", // OpenMP 5.1
35  "omp_no_parallelism", // OpenMP 5.1
36 });
llvm
Definition: AllocatorList.h:23
llvm::Function
Definition: Function.h:61
llvm::Attribute
Definition: Attributes.h:52
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1167
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::KnownAssumptionStrings
StringSet KnownAssumptionStrings
A set of known assumption strings that are accepted without warning and which can be recommended as t...
Assumptions.h
llvm::KnownAssumptionString
Helper that allows to insert a new assumption string in the known assumption set by creating a (stati...
Definition: Assumptions.h:34
llvm::AssumptionAttrKey
constexpr StringRef AssumptionAttrKey
The key we use for assumption attributes.
Definition: Assumptions.h:26
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::StringSet
StringSet - A wrapper for StringMap that provides set-like functionality.
Definition: StringSet.h:22
llvm::any_of
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1489
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
Attributes.h
Function.h
llvm::hasAssumption
bool hasAssumption(Function &F, const KnownAssumptionString &AssumptionStr)
Return true if F has the assumption AssumptionStr attached.
Definition: Assumptions.cpp:17