Skip to content

Commit 6de17cb

Browse files
authored
Avoid getElementType call for LLVM 15 (#324)
1 parent 31b11dc commit 6de17cb

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

Manifest.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
1010
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
1111

1212
[[CEnum]]
13-
git-tree-sha1 = "215a9aa4a1f23fbd05b92769fdd62559488d70e9"
13+
git-tree-sha1 = "eb4cb44a499229b3b8426dcfb5dd85333951ff90"
1414
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
15-
version = "0.4.1"
15+
version = "0.4.2"
1616

1717
[[Dates]]
1818
deps = ["Printf"]
@@ -33,10 +33,10 @@ uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
3333
version = "1.4.1"
3434

3535
[[LLVMExtra_jll]]
36-
deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg", "TOML"]
37-
git-tree-sha1 = "771bfe376249626d3ca12bcd58ba243d3f961576"
36+
deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"]
37+
git-tree-sha1 = "1fbc1c5dac58bd6c6183347b67ab6c2f0ce6c582"
3838
uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab"
39-
version = "0.0.16+0"
39+
version = "0.0.17+0"
4040

4141
[[LazyArtifacts]]
4242
deps = ["Artifacts", "Pkg"]

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
1111

1212
[compat]
1313
CEnum = "0.2, 0.3, 0.4"
14-
LLVMExtra_jll = "=0.0.16"
14+
LLVMExtra_jll = "=0.0.17"
1515
julia = "1.6"

deps/LLVMExtra/lib/llvm-api.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,16 +507,26 @@ LLVMValueRef LLVMBuildCallWithOpBundle(LLVMBuilderRef B, LLVMValueRef Fn,
507507
LLVMValueRef *Args, unsigned NumArgs,
508508
LLVMOperandBundleDefRef *Bundles, unsigned NumBundles,
509509
const char *Name) {
510+
511+
// TODO make opaque pointer compatibly
510512
Value *V = unwrap(Fn);
511-
FunctionType *FnT =
512-
cast<FunctionType>(cast<PointerType>(V->getType())->getElementType());
513+
#if LLVM_VERSION_MAJOR <= 14
514+
FunctionType *FnT =
515+
cast<FunctionType>(cast<PointerType>(V->getType())->getElementType());
516+
#else
517+
FunctionType *FnT =
518+
cast<FunctionType>(cast<PointerType>(V->getType())->getPointerElementType()); // deprecated
519+
#endif
513520

514521
SmallVector<OperandBundleDef, 1> BundleArray;
515522
for (auto *Bundle : makeArrayRef(Bundles, NumBundles))
516523
BundleArray.push_back(*unwrap<OperandBundleDef>(Bundle));
517524

518-
return wrap(unwrap(B)->CreateCall(FnT, unwrap(Fn), makeArrayRef(unwrap(Args), NumArgs),
519-
BundleArray, Name));
525+
llvm::IRBuilder<> *Builder = unwrap(B);
526+
llvm::ArrayRef<llvm::Value*> args = makeArrayRef(unwrap(Args), NumArgs);
527+
528+
llvm::CallInst *CI = Builder->CreateCall(FnT, unwrap(Fn), args ,BundleArray, Name);
529+
return wrap(CI);
520530
}
521531

522532
LLVMValueRef LLVMMetadataAsValue2(LLVMContextRef C, LLVMMetadataRef Metadata) {

0 commit comments

Comments
 (0)