1 //===- Assumptions.cpp ------ Collection of helpers for assumptions -------===//
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
7 //===----------------------------------------------------------------------===//
9 //===----------------------------------------------------------------------===//
11 #include "llvm/IR/Assumptions.h"
12 #include "llvm/IR/Attributes.h"
13 #include "llvm/IR/Function.h"
17 bool llvm::hasAssumption(Function
&F
,
18 const KnownAssumptionString
&AssumptionStr
) {
19 const Attribute
&A
= F
.getFnAttribute(AssumptionAttrKey
);
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
;
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