[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / IR / Assumptions.cpp
blob6498114cd60d54e490eb656b0edb59962eea9b76
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 //===----------------------------------------------------------------------===//
11 #include "llvm/IR/Assumptions.h"
12 #include "llvm/IR/Attributes.h"
13 #include "llvm/IR/Function.h"
15 using namespace llvm;
17 bool llvm::hasAssumption(Function &F,
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!");
24 SmallVector<StringRef, 8> Strings;
25 A.getValueAsString().split(Strings, ",");
27 return llvm::any_of(Strings, [=](StringRef Assumption) {
28 return Assumption == AssumptionStr;
29 });
32 StringSet<> llvm::KnownAssumptionStrings({
33 "omp_no_openmp", // OpenMP 5.1
34 "omp_no_openmp_routines", // OpenMP 5.1
35 "omp_no_parallelism", // OpenMP 5.1
36 "ompx_spmd_amenable", // OpenMPOpt extension
37 });