diff --git a/cmake/Modules/FindLLVM.cmake b/cmake/Modules/FindLLVM.cmake index dadf945006..c002e9d403 100644 --- a/cmake/Modules/FindLLVM.cmake +++ b/cmake/Modules/FindLLVM.cmake @@ -32,7 +32,8 @@ # We also want an user-specified LLVM_ROOT_DIR to take precedence over the # system default locations such as /usr/local/bin. Executing find_program() # multiples times is the approach recommended in the docs. -set(llvm_config_names llvm-config-17.0 llvm-config170 llvm-config-17 +set(llvm_config_names llvm-config-18.1 llvm-config181 llvm-config-18 + llvm-config-17.0 llvm-config170 llvm-config-17 llvm-config-16.0 llvm-config160 llvm-config-16 llvm-config-15.0 llvm-config150 llvm-config-15 llvm-config-14.0 llvm-config140 llvm-config-14 @@ -49,12 +50,12 @@ if(APPLE) # extra fallbacks for MacPorts & Homebrew find_program(LLVM_CONFIG NAMES ${llvm_config_names} - PATHS /opt/local/libexec/llvm-17/bin + PATHS /opt/local/libexec/llvm-18/bin /opt/local/libexec/llvm-17/bin /opt/local/libexec/llvm-16/bin /opt/local/libexec/llvm-15/bin /opt/local/libexec/llvm-14/bin /opt/local/libexec/llvm-13/bin /opt/local/libexec/llvm-12/bin /opt/local/libexec/llvm-11/bin /opt/local/libexec/llvm/bin - /usr/local/opt/llvm@17/bin + /usr/local/opt/llvm@18/bin /usr/local/opt/llvm@17/bin /usr/local/opt/llvm@16/bin /usr/local/opt/llvm@15/bin /usr/local/opt/llvm@14/bin /usr/local/opt/llvm@13/bin /usr/local/opt/llvm@12/bin /usr/local/opt/llvm@11/bin diff --git a/driver/codegenerator.cpp b/driver/codegenerator.cpp index b4ec07f2ad..4f8e404262 100644 --- a/driver/codegenerator.cpp +++ b/driver/codegenerator.cpp @@ -115,7 +115,7 @@ void emitLLVMUsedArray(IRState &irs) { return; } - auto *i8PtrType = LDC_getInt8PtrTy(irs.context()); + auto *i8PtrType = getVoidPtrType(irs.context()); // Convert all elements to i8* (the expected type for llvm.used) for (auto &elem : irs.usedArray) { diff --git a/driver/toobj.cpp b/driver/toobj.cpp index e1f492fbcf..1a00c5c6c3 100644 --- a/driver/toobj.cpp +++ b/driver/toobj.cpp @@ -48,9 +48,9 @@ using CodeGenFileType = llvm::CodeGenFileType; #if LDC_LLVM_VER >= 1800 -#define CGFT_AssemblyFile CodeGenFileType::AssemblyFile -#define CGFT_ObjectFile CodeGenFileType::ObjectFile -#define CGFT_Null CodeGenFileType::Null +constexpr llvm::CodeGenFileType CGFT_AssemblyFile = CodeGenFileType::AssemblyFile; +constexpr llvm::CodeGenFileType CGFT_ObjectFile = CodeGenFileType::ObjectFile; +constexpr llvm::CodeGenFileType CGFT_Null = CodeGenFileType::Null; #endif #if LDC_LLVM_VER < 1700 diff --git a/gen/ms-cxx-helper.cpp b/gen/ms-cxx-helper.cpp index 038cd6e28a..2bf069d5b0 100644 --- a/gen/ms-cxx-helper.cpp +++ b/gen/ms-cxx-helper.cpp @@ -185,9 +185,8 @@ llvm::GlobalVariable *getTypeDescriptor(IRState &irs, ClassDeclaration *cd) { // Declare and initialize the TypeDescriptor. llvm::Constant *Fields[] = { - classInfoPtr, // VFPtr - llvm::ConstantPointerNull::get( - LDC_getInt8PtrTy(gIR->context())), // Runtime data + classInfoPtr, // VFPtr + llvm::ConstantPointerNull::get(getVoidPtrType()), // Runtime data llvm::ConstantDataArray::getString(gIR->context(), TypeNameString)}; llvm::StructType *TypeDescriptorType = getTypeDescriptorType(irs, classInfoPtr, TypeNameString); diff --git a/gen/pgo_ASTbased.cpp b/gen/pgo_ASTbased.cpp index b2010ba013..70b764d3d3 100644 --- a/gen/pgo_ASTbased.cpp +++ b/gen/pgo_ASTbased.cpp @@ -910,7 +910,7 @@ void CodeGenPGO::emitCounterIncrement(const RootObject *S) const { assert(counter_it != (*RegionCounterMap).end() && "Statement not found in PGO counter map!"); unsigned counter = counter_it->second; - auto *I8PtrTy = LDC_getInt8PtrTy(gIR->context()); + auto *I8PtrTy = getVoidPtrType(); gIR->ir->CreateCall(GET_INTRINSIC_DECL(instrprof_increment), {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy), gIR->ir->getInt64(FunctionHash), @@ -1118,7 +1118,7 @@ void CodeGenPGO::valueProfile(uint32_t valueKind, llvm::Instruction *valueSite, if (ptrCastNeeded) value = gIR->ir->CreatePtrToInt(value, gIR->ir->getInt64Ty()); - auto *i8PtrTy = LDC_getInt8PtrTy(gIR->context()); + auto *i8PtrTy = getVoidPtrType(); llvm::Value *Args[5] = { llvm::ConstantExpr::getBitCast(FuncNameVar, i8PtrTy), gIR->ir->getInt64(FunctionHash), value, gIR->ir->getInt32(valueKind), diff --git a/gen/tocall.cpp b/gen/tocall.cpp index f18c88c36f..91b47d3c49 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -271,7 +271,7 @@ static LLType *getPtrToAtomicType(LLType *type) { #if LDC_LLVM_VER < 1800 return LLType::getIntNPtrTy(gIR->context(), static_cast(N)); #else - return llvm::PointerType::get(gIR->context(), static_cast(N)); + return LLPointerType::getIntNPtrTy(gIR->context(), static_cast(N)); #endif default: return nullptr; diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 1b95098a62..981bf8680f 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -738,7 +738,11 @@ LLPointerType *getPtrToType(LLType *t) { } LLPointerType *getVoidPtrType() { - return LLType::getInt8Ty(gIR->context())->getPointerTo(); + return getVoidPtrType(gIR->context()); +} + +LLPointerType *getVoidPtrType(llvm::LLVMContext &C) { + return LLType::getInt8Ty(C)->getPointerTo(); } llvm::ConstantPointerNull *getNullPtr(LLType *t) { diff --git a/gen/tollvm.h b/gen/tollvm.h index b9cbefbd90..fc2b9cfa1e 100644 --- a/gen/tollvm.h +++ b/gen/tollvm.h @@ -152,6 +152,7 @@ LLGlobalVariable *isaGlobalVar(LLValue *v); LLType *getI8Type(); LLPointerType *getPtrToType(LLType *t); LLPointerType *getVoidPtrType(); +LLPointerType *getVoidPtrType(llvm::LLVMContext &C); llvm::ConstantPointerNull *getNullPtr(LLType *t); LLConstant *getNullValue(LLType *t); @@ -218,11 +219,3 @@ void DtoMemCpy(LLType *type, LLValue *dst, LLValue *src, bool withPadding = fals * Generates a call to C memcmp. */ LLValue *DtoMemCmp(LLValue *lhs, LLValue *rhs, LLValue *nbytes); - -inline auto *LDC_getInt8PtrTy(llvm::LLVMContext &C) { -#if LDC_LLVM_VER < 1800 - return llvm::Type::getInt8PtrTy(C); -#else - return llvm::PointerType::getUnqual(C); -#endif -} diff --git a/gen/trycatchfinally.cpp b/gen/trycatchfinally.cpp index db7dddfcb8..6c689bde12 100644 --- a/gen/trycatchfinally.cpp +++ b/gen/trycatchfinally.cpp @@ -663,7 +663,7 @@ TryCatchFinallyScopes::getLandingPadRef(CleanupCursor scope) { namespace { llvm::LandingPadInst *createLandingPadInst(IRState &irs) { - LLType *retType = LLStructType::get(LDC_getInt8PtrTy(irs.context()), + LLType *retType = LLStructType::get(getVoidPtrType(irs.context()), LLType::getInt32Ty(irs.context())); if (!irs.func()->hasLLVMPersonalityFn()) { irs.func()->setLLVMPersonalityFn(