Skip to content

Commit 88862e7

Browse files
bokrzesipszymich
authored andcommitted
[LLVM16] Minor compilation fixes: Optionals
Porting IGC code to LLVM16 Once changes related to Source/IGC/CMFE/AdaptorCM/Frontend.h file are merged the return type of makeFEWrapper() will be changed from LLVM::Optional to std::optional. Due to this change the IGCLLVM::makeOptional() call no longer valid and can be removed. (cherry picked from commit 8ff0a49)
1 parent 6372d4e commit 88862e7

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

IGC/AdaptorOCL/ocl_igc_interface/impl/fcl_ocl_translation_ctx_impl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ OclTranslationOutputBase* CIF_PIMPL(FclOclTranslationCtx)::TranslateCM(
551551
};
552552
auto MaybeFE =
553553
IGC::AdaptorCM::Frontend::makeFEWrapper(ErrFn, getCMFEWrapperDir());
554+
554555
if (!MaybeFE)
555556
return outputInterface;
556557

IGC/CMFE/AdaptorCM/Frontend.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ SPDX-License-Identifier: MIT
1111

1212
#include "Interface.h"
1313

14-
#include <llvm/ADT/Optional.h>
1514
#include <llvm/ADT/StringExtras.h>
1615
#include <llvm/ADT/StringRef.h>
1716
#include <llvm/ADT/Twine.h>
@@ -20,6 +19,7 @@ SPDX-License-Identifier: MIT
2019
#include <llvm/Support/Process.h>
2120

2221
#include <memory>
22+
#include <optional>
2323
#include <sstream>
2424

2525
namespace IGC {
@@ -117,8 +117,8 @@ template <typename Fn> class FEWrapper {
117117
constexpr auto CustomPathEnv = "CM_FE_DIR";
118118

119119
std::string LibDir;
120-
if (auto EnvDir = llvm::sys::Process::GetEnv(CustomPathEnv))
121-
LibDir = EnvDir.getValue();
120+
if (const char *EnvDir = std::getenv(CustomPathEnv))
121+
LibDir = std::string(EnvDir);
122122
else
123123
LibDir = DefaultDir;
124124

@@ -145,7 +145,7 @@ template <typename Fn> class FEWrapper {
145145
: ErrHandler(std::forward<ErrFn>(ErrH)), Lib(loadLibrary(DefaultPath)) {}
146146

147147
template <typename ErrFn, typename ErrFnTy>
148-
friend llvm::Optional<FEWrapper<ErrFnTy>>
148+
friend std::optional<FEWrapper<ErrFnTy>>
149149
makeFEWrapper(ErrFn &&ErrH, const std::string &DefaultDir);
150150

151151
public:
@@ -212,16 +212,15 @@ template <typename Fn> class FEWrapper {
212212
// absolute path to directory with FE wrapper. Defaults to empty string
213213
// that is expanded to plain FE wrapper name.
214214
// Return Optional as it can fail during loading.
215-
template <typename ErrFn,
216-
typename ErrFnTy = typename std::decay<ErrFn>::type>
217-
inline llvm::Optional<FEWrapper<ErrFnTy>>
215+
template <typename ErrFn, typename ErrFnTy = typename std::decay<ErrFn>::type>
216+
inline std::optional<FEWrapper<ErrFnTy>>
218217
makeFEWrapper(ErrFn &&ErrH, const std::string &DefaultDir = std::string{}) {
219218
FEWrapper<ErrFnTy> IFace{std::forward<ErrFn>(ErrH), DefaultDir};
220219

221220
if (!IFace.Lib.isValid())
222-
return llvm::None;
221+
return std::nullopt;
223222
if (!IFace.isCompatibleABI())
224-
return llvm::None;
223+
return std::nullopt;
225224
return IFace;
226225
}
227226

IGC/CMFE/AdaptorCM/Interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ struct IDriverInvocation {
8383
};
8484

8585
// this number should be increased whenever the public interface changes
86-
static const int InterfaceVersion = 10;
86+
static const int InterfaceVersion = 11;
8787

8888
} // namespace ClangFE
8989
} // namespace CM

0 commit comments

Comments
 (0)