| ... | ... | @@ -112,7 +112,7 @@ LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Tri |
| 112 | 112 | const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, |
| 113 | 113 | LLVMCodeModel CodeModel, bool function_sections, ZigLLVMABIType float_abi, const char *abi_name) |
| 114 | 114 | { |
| 115 | | Optional<Reloc::Model> RM; |
| 115 | std::optional<Reloc::Model> RM; |
| 116 | 116 | switch (Reloc){ |
| 117 | 117 | case LLVMRelocStatic: |
| 118 | 118 | RM = Reloc::Static; |
| ... | ... | @@ -137,7 +137,7 @@ LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Tri |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | bool JIT; |
| 140 | | Optional<CodeModel::Model> CM = unwrap(CodeModel, JIT); |
| 140 | std::optional<CodeModel::Model> CM = unwrap(CodeModel, JIT); |
| 141 | 141 | |
| 142 | 142 | CodeGenOpt::Level OL; |
| 143 | 143 | switch (Level) { |
| ... | ... | @@ -287,11 +287,12 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM |
| 287 | 287 | |
| 288 | 288 | // Instrumentations |
| 289 | 289 | PassInstrumentationCallbacks instr_callbacks; |
| 290 | | StandardInstrumentations std_instrumentations(false); |
| 290 | StandardInstrumentations std_instrumentations(llvm_module.getContext(), false); |
| 291 | 291 | std_instrumentations.registerCallbacks(instr_callbacks); |
| 292 | 292 | |
| 293 | std::optional<PGOOptions> opt_pgo_options = {}; |
| 293 | 294 | PassBuilder pass_builder(&target_machine, pipeline_opts, |
| 294 | | None, &instr_callbacks); |
| 295 | opt_pgo_options, &instr_callbacks); |
| 295 | 296 | |
| 296 | 297 | LoopAnalysisManager loop_am; |
| 297 | 298 | FunctionAnalysisManager function_am; |
| ... | ... | @@ -415,14 +416,9 @@ ZIG_EXTERN_C LLVMTypeRef ZigLLVMTokenTypeInContext(LLVMContextRef context_ref) { |
| 415 | 416 | |
| 416 | 417 | |
| 417 | 418 | ZIG_EXTERN_C void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit) { |
| 418 | | // In LLVM15 we just have an OptBisect singleton we can edit. |
| 419 | | OptBisect& bisect = getOptBisector(); |
| 420 | | bisect.setLimit(limit); |
| 421 | | |
| 422 | | // In LLVM16 OptBisect will be wrapped in OptPassGate, and will need to be set per context. |
| 423 | | // static OptBisect _opt_bisector; |
| 424 | | // _opt_bisector.setLimit(limit); |
| 425 | | // unwrap(context_ref)->setOptPassGate(_opt_bisector); |
| 419 | static OptBisect opt_bisect; |
| 420 | opt_bisect.setLimit(limit); |
| 421 | unwrap(context_ref)->setOptPassGate(opt_bisect); |
| 426 | 422 | } |
| 427 | 423 | |
| 428 | 424 | LLVMValueRef ZigLLVMAddFunctionInAddressSpace(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy, unsigned AddressSpace) { |
| ... | ... | @@ -435,8 +431,8 @@ LLVMValueRef ZigLLVMBuildCall(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, |
| 435 | 431 | const char *Name) |
| 436 | 432 | { |
| 437 | 433 | FunctionType *FTy = unwrap<FunctionType>(Ty); |
| 438 | | CallInst *call_inst = unwrap(B)->CreateCall(FTy, unwrap(Fn), makeArrayRef(unwrap(Args), |
| 439 | | NumArgs), Name); |
| 434 | CallInst *call_inst = unwrap(B)->CreateCall(FTy, unwrap(Fn), |
| 435 | ArrayRef(unwrap(Args), NumArgs), Name); |
| 440 | 436 | call_inst->setCallingConv(static_cast<CallingConv::ID>(CC)); |
| 441 | 437 | switch (attr) { |
| 442 | 438 | case ZigLLVM_CallAttrAuto: |
| ... | ... | @@ -579,7 +575,7 @@ ZigLLVMDIType *ZigLLVMCreateDebugPointerType(ZigLLVMDIBuilder *dibuilder, ZigLLV |
| 579 | 575 | uint64_t size_in_bits, uint64_t align_in_bits, const char *name) |
| 580 | 576 | { |
| 581 | 577 | DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createPointerType( |
| 582 | | reinterpret_cast<DIType*>(pointee_type), size_in_bits, align_in_bits, Optional<unsigned>(), name); |
| 578 | reinterpret_cast<DIType*>(pointee_type), size_in_bits, align_in_bits, std::optional<unsigned>(), name); |
| 583 | 579 | return reinterpret_cast<ZigLLVMDIType*>(di_type); |
| 584 | 580 | } |
| 585 | 581 | |
| ... | ... | @@ -625,7 +621,7 @@ ZigLLVMDIEnumerator *ZigLLVMCreateDebugEnumeratorOfArbitraryPrecision(ZigLLVMDIB |
| 625 | 621 | const char *name, unsigned NumWords, const uint64_t Words[], unsigned int bits, bool isUnsigned) |
| 626 | 622 | { |
| 627 | 623 | DIEnumerator *di_enumerator = reinterpret_cast<DIBuilder*>(dibuilder)->createEnumerator(name, |
| 628 | | APSInt(APInt(bits, makeArrayRef(Words, NumWords)), isUnsigned)); |
| 624 | APSInt(APInt(bits, ArrayRef(Words, NumWords)), isUnsigned)); |
| 629 | 625 | return reinterpret_cast<ZigLLVMDIEnumerator*>(di_enumerator); |
| 630 | 626 | } |
| 631 | 627 | |
| ... | ... | @@ -1493,6 +1489,7 @@ static_assert((Triple::ArchType)ZigLLVM_thumbeb == Triple::thumbeb, ""); |
| 1493 | 1489 | static_assert((Triple::ArchType)ZigLLVM_x86 == Triple::x86, ""); |
| 1494 | 1490 | static_assert((Triple::ArchType)ZigLLVM_x86_64 == Triple::x86_64, ""); |
| 1495 | 1491 | static_assert((Triple::ArchType)ZigLLVM_xcore == Triple::xcore, ""); |
| 1492 | static_assert((Triple::ArchType)ZigLLVM_xtensa == Triple::xtensa, ""); |
| 1496 | 1493 | static_assert((Triple::ArchType)ZigLLVM_nvptx == Triple::nvptx, ""); |
| 1497 | 1494 | static_assert((Triple::ArchType)ZigLLVM_nvptx64 == Triple::nvptx64, ""); |
| 1498 | 1495 | static_assert((Triple::ArchType)ZigLLVM_le32 == Triple::le32, ""); |
| ... | ... | @@ -1578,6 +1575,9 @@ static_assert((Triple::EnvironmentType)ZigLLVM_GNUABIN32 == Triple::GNUABIN32, " |
| 1578 | 1575 | static_assert((Triple::EnvironmentType)ZigLLVM_GNUABI64 == Triple::GNUABI64, ""); |
| 1579 | 1576 | static_assert((Triple::EnvironmentType)ZigLLVM_GNUEABI == Triple::GNUEABI, ""); |
| 1580 | 1577 | static_assert((Triple::EnvironmentType)ZigLLVM_GNUEABIHF == Triple::GNUEABIHF, ""); |
| 1578 | static_assert((Triple::EnvironmentType)ZigLLVM_GNUF32 == Triple::GNUF32, ""); |
| 1579 | static_assert((Triple::EnvironmentType)ZigLLVM_GNUF64 == Triple::GNUF64, ""); |
| 1580 | static_assert((Triple::EnvironmentType)ZigLLVM_GNUSF == Triple::GNUSF, ""); |
| 1581 | 1581 | static_assert((Triple::EnvironmentType)ZigLLVM_GNUX32 == Triple::GNUX32, ""); |
| 1582 | 1582 | static_assert((Triple::EnvironmentType)ZigLLVM_GNUILP32 == Triple::GNUILP32, ""); |
| 1583 | 1583 | static_assert((Triple::EnvironmentType)ZigLLVM_CODE16 == Triple::CODE16, ""); |