kparzysz-quic commented on code in PR #12140: URL: https://github.com/apache/tvm/pull/12140#discussion_r928888179
########## src/target/llvm/llvm_scope.cc: ########## @@ -0,0 +1,368 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifdef TVM_LLVM_VERSION + +#include "llvm_scope.h" + +#include <dmlc/base.h> +#include <llvm/ADT/ArrayRef.h> +#include <llvm/ADT/StringRef.h> +#if TVM_LLVM_VERSION >= 150 +#include <llvm/IR/FMF.h> +#else +#include <llvm/IR/Operator.h> +#endif +#include <llvm/IR/LLVMContext.h> +#include <llvm/IR/Metadata.h> +#include <llvm/IR/Module.h> +#include <llvm/IRReader/IRReader.h> +#if TVM_LLVM_VERSION >= 140 +#include <llvm/MC/TargetRegistry.h> +#else +#include <llvm/Support/TargetRegistry.h> +#endif +#include <llvm/Support/CodeGen.h> +#include <llvm/Support/ErrorOr.h> +#include <llvm/Support/Host.h> +#include <llvm/Support/MemoryBuffer.h> +#include <llvm/Support/SourceMgr.h> +#include <llvm/Support/TargetSelect.h> +#include <llvm/Support/raw_ostream.h> +#include <llvm/Target/TargetMachine.h> +#include <llvm/Target/TargetOptions.h> +#include <tvm/runtime/container/array.h> +#include <tvm/runtime/container/map.h> +#include <tvm/runtime/container/optional.h> +#include <tvm/runtime/container/string.h> +#include <tvm/runtime/logging.h> +#include <tvm/runtime/object.h> +#include <tvm/target/target.h> + +#include <atomic> +#include <sstream> +#include <string> +#include <system_error> + +namespace tvm { +namespace codegen { + +namespace { +namespace defaults { +static const std::string cpu = "generic"; // NOLINT(runtime/string) +static const llvm::CodeGenOpt::Level opt_level = llvm::CodeGenOpt::Aggressive; +} // namespace defaults +} // namespace + +namespace { +bool InitializeLLVM() { + static std::atomic_flag initialized = ATOMIC_FLAG_INIT; Review Comment: The previous initialization code (in [llvm_common.cc](https://github.com/apache/tvm/pull/12140/files#diff-87ff91bdb4a2845d4ffac8e46ea9648cb72ae71505530a420163202c8906d373L64)) had an atomic flag in it (although in a bit more complex scheme), so I kept it. If you still think it should be removed, let me know---I have no problem changing it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
