1*e8d8bef9SDimitry Andric //===- Assumptions.cpp ------ Collection of helpers for assumptions -------===// 2*e8d8bef9SDimitry Andric // 3*e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*e8d8bef9SDimitry Andric // 7*e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===// 8*e8d8bef9SDimitry Andric // 9*e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===// 10*e8d8bef9SDimitry Andric 11*e8d8bef9SDimitry Andric #include "llvm/IR/Assumptions.h" 12*e8d8bef9SDimitry Andric #include "llvm/IR/Attributes.h" 13*e8d8bef9SDimitry Andric #include "llvm/IR/Function.h" 14*e8d8bef9SDimitry Andric 15*e8d8bef9SDimitry Andric using namespace llvm; 16*e8d8bef9SDimitry Andric 17*e8d8bef9SDimitry Andric bool llvm::hasAssumption(Function &F, 18*e8d8bef9SDimitry Andric const KnownAssumptionString &AssumptionStr) { 19*e8d8bef9SDimitry Andric const Attribute &A = F.getFnAttribute(AssumptionAttrKey); 20*e8d8bef9SDimitry Andric if (!A.isValid()) 21*e8d8bef9SDimitry Andric return false; 22*e8d8bef9SDimitry Andric assert(A.isStringAttribute() && "Expected a string attribute!"); 23*e8d8bef9SDimitry Andric 24*e8d8bef9SDimitry Andric SmallVector<StringRef, 8> Strings; 25*e8d8bef9SDimitry Andric A.getValueAsString().split(Strings, ","); 26*e8d8bef9SDimitry Andric 27*e8d8bef9SDimitry Andric return llvm::any_of(Strings, [=](StringRef Assumption) { 28*e8d8bef9SDimitry Andric return Assumption == AssumptionStr; 29*e8d8bef9SDimitry Andric }); 30*e8d8bef9SDimitry Andric } 31*e8d8bef9SDimitry Andric 32*e8d8bef9SDimitry Andric StringSet<> llvm::KnownAssumptionStrings({ 33*e8d8bef9SDimitry Andric "omp_no_openmp", // OpenMP 5.1 34*e8d8bef9SDimitry Andric "omp_no_openmp_routines", // OpenMP 5.1 35*e8d8bef9SDimitry Andric "omp_no_parallelism", // OpenMP 5.1 36*e8d8bef9SDimitry Andric }); 37