diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-18 20:30:12 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-06 20:11:55 +0000 |
commit | 5f757f3ff9144b609b3c433dfd370cc6bdc191ad (patch) | |
tree | 1b4e980b866cd26a00af34c0a653eb640bd09caf /contrib/llvm-project/llvm/lib/IR/Module.cpp | |
parent | 3e1c8a35f741a5d114d0ba670b15191355711fe9 (diff) | |
parent | 312c0ed19cc5276a17bacf2120097bec4515b0f1 (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/IR/Module.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/IR/Module.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/contrib/llvm-project/llvm/lib/IR/Module.cpp b/contrib/llvm-project/llvm/lib/IR/Module.cpp index 73354a8f36d2..eeb90a6cb3c4 100644 --- a/contrib/llvm-project/llvm/lib/IR/Module.cpp +++ b/contrib/llvm-project/llvm/lib/IR/Module.cpp @@ -71,7 +71,8 @@ template class llvm::SymbolTableListTraits<GlobalIFunc>; Module::Module(StringRef MID, LLVMContext &C) : Context(C), ValSymTab(std::make_unique<ValueSymbolTable>(-1)), - ModuleID(std::string(MID)), SourceFileName(std::string(MID)), DL("") { + ModuleID(std::string(MID)), SourceFileName(std::string(MID)), DL(""), + IsNewDbgInfoFormat(false) { Context.addModule(this); } @@ -155,12 +156,6 @@ FunctionCallee Module::getOrInsertFunction(StringRef Name, FunctionType *Ty, return {Ty, New}; // Return the new prototype. } - // If the function exists but has the wrong type, return a bitcast to the - // right type. - auto *PTy = PointerType::get(Ty, F->getAddressSpace()); - if (F->getType() != PTy) - return {Ty, ConstantExpr::getBitCast(F, PTy)}; - // Otherwise, we just found the existing function or a prototype. return {Ty, F}; } @@ -211,13 +206,6 @@ Constant *Module::getOrInsertGlobal( GV = CreateGlobalCallback(); assert(GV && "The CreateGlobalCallback is expected to create a global"); - // If the variable exists but has the wrong type, return a bitcast to the - // right type. - Type *GVTy = GV->getType(); - PointerType *PTy = PointerType::get(Ty, GVTy->getPointerAddressSpace()); - if (GVTy != PTy) - return ConstantExpr::getBitCast(GV, PTy); - // Otherwise, we just found the existing function or a prototype. return GV; } @@ -395,8 +383,6 @@ void Module::setDataLayout(StringRef Desc) { void Module::setDataLayout(const DataLayout &Other) { DL = Other; } -const DataLayout &Module::getDataLayout() const { return DL; } - DICompileUnit *Module::debug_compile_units_iterator::operator*() const { return cast<DICompileUnit>(CUs->getOperand(Idx)); } @@ -633,6 +619,23 @@ void Module::setCodeModel(CodeModel::Model CL) { addModuleFlag(ModFlagBehavior::Error, "Code Model", CL); } +std::optional<uint64_t> Module::getLargeDataThreshold() const { + auto *Val = + cast_or_null<ConstantAsMetadata>(getModuleFlag("Large Data Threshold")); + + if (!Val) + return std::nullopt; + + return cast<ConstantInt>(Val->getValue())->getZExtValue(); +} + +void Module::setLargeDataThreshold(uint64_t Threshold) { + // Since the large data threshold goes along with the code model, the merge + // behavior is the same. + addModuleFlag(ModFlagBehavior::Error, "Large Data Threshold", + ConstantInt::get(Type::getInt64Ty(Context), Threshold)); +} + void Module::setProfileSummary(Metadata *M, ProfileSummary::Kind Kind) { if (Kind == ProfileSummary::PSK_CSInstr) setModuleFlag(ModFlagBehavior::Error, "CSProfileSummary", M); |