Skip to content

Commit 363a66f

Browse files
vchuravygbaraldi
andauthored
Add supportsTypedPointers and SimpleLoopUnswitch(#281)
Co-authored-by: Gabriel Baraldi <[email protected]>
1 parent 6de17cb commit 363a66f

File tree

7 files changed

+39
-3
lines changed

7 files changed

+39
-3
lines changed

Manifest.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ version = "1.4.1"
3434

3535
[[LLVMExtra_jll]]
3636
deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"]
37-
git-tree-sha1 = "1fbc1c5dac58bd6c6183347b67ab6c2f0ce6c582"
37+
git-tree-sha1 = "070e4b5b65827f82c16ae0916376cb47377aa1b5"
3838
uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab"
39-
version = "0.0.17+0"
39+
version = "0.0.18+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.17"
14+
LLVMExtra_jll = "=0.0.18"
1515
julia = "1.6"

deps/LLVMExtra/include/LLVMExtra.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void LLVMAddVectorCombinePass(LLVMPassManagerRef PM);
3030
void LLVMAddSpeculativeExecutionIfHasBranchDivergencePass(LLVMPassManagerRef PM);
3131
void LLVMAddSimpleLoopUnrollPass(LLVMPassManagerRef PM);
3232
void LLVMAddInductiveRangeCheckEliminationPass(LLVMPassManagerRef PM);
33+
void LLVMAddSimpleLoopUnswitchLegacyPass(LLVMPassManagerRef PM);
3334

3435
#if LLVM_VERSION_MAJOR < 12
3536
void LLVMAddInstructionSimplifyPass(LLVMPassManagerRef PM);
@@ -157,5 +158,9 @@ LLVMValueRef LLVMMetadataAsValue2(LLVMContextRef C, LLVMMetadataRef Metadata);
157158
void LLVMReplaceAllMetadataUsesWith(LLVMValueRef Old, LLVMValueRef New);
158159
void LLVMReplaceMDNodeOperandWith(LLVMMetadataRef MD, unsigned I, LLVMMetadataRef New);
159160

161+
#if LLVM_VERSION_MAJOR >= 12
162+
LLVMBool LLVMContextSupportsTypedPointers(LLVMContextRef C);
163+
#endif
164+
160165
LLVM_C_EXTERN_C_END
161166
#endif

deps/LLVMExtra/lib/llvm-api.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <llvm/Support/TargetSelect.h>
1616
#include <llvm/Transforms/IPO.h>
1717
#include <llvm/Transforms/Scalar.h>
18+
#include <llvm/Transforms/Scalar/SimpleLoopUnswitch.h>
1819
#include <llvm/Transforms/Vectorize.h>
1920
#if LLVM_VERSION_MAJOR < 12
2021
#include <llvm/Transforms/Scalar/InstSimplifyPass.h>
@@ -101,6 +102,11 @@ void LLVMAddInductiveRangeCheckEliminationPass(LLVMPassManagerRef PM)
101102
unwrap(PM)->add(createInductiveRangeCheckEliminationPass());
102103
}
103104

105+
void LLVMAddSimpleLoopUnswitchLegacyPass(LLVMPassManagerRef PM)
106+
{
107+
unwrap(PM)->add(createSimpleLoopUnswitchLegacyPass());
108+
}
109+
104110
#if LLVM_VERSION_MAJOR < 12
105111
void LLVMAddInstructionSimplifyPass(LLVMPassManagerRef PM)
106112
{
@@ -544,3 +550,9 @@ void LLVMReplaceAllMetadataUsesWith(LLVMValueRef Old, LLVMValueRef New) {
544550
void LLVMReplaceMDNodeOperandWith(LLVMMetadataRef MD, unsigned I, LLVMMetadataRef New) {
545551
unwrap<MDNode>(MD)->replaceOperandWith(I, unwrap(New));
546552
}
553+
554+
#if LLVM_VERSION_MAJOR > 12
555+
LLVMBool LLVMContextSupportsTypedPointers(LLVMContextRef C) {
556+
return unwrap(C)->supportsTypedPointers();
557+
}
558+
#endif

lib/libLLVM_extra.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ function LLVMAddInductiveRangeCheckEliminationPass(PM)
6363
ccall((:LLVMAddInductiveRangeCheckEliminationPass, libLLVMExtra), Cvoid, (LLVMPassManagerRef,), PM)
6464
end
6565

66+
function LLVMAddSimpleLoopUnswitchLegacyPass(PM)
67+
ccall((:LLVMAddSimpleLoopUnswitchLegacyPass, libLLVMExtra), Cvoid, (LLVMPassManagerRef,), PM)
68+
end
69+
6670
if version() < v"12"
6771
function LLVMAddInstructionSimplifyPass(PM)
6872
ccall((:LLVMAddInstructionSimplifyPass, libLLVMExtra), Cvoid, (LLVMPassManagerRef,), PM)
@@ -406,3 +410,9 @@ end
406410
function LLVMReplaceMDNodeOperandWith(MD, I, New)
407411
ccall((:LLVMReplaceMDNodeOperandWith, libLLVMExtra), Cvoid, (LLVMMetadataRef, Cuint, LLVMMetadataRef), MD, I, New)
408412
end
413+
414+
if version() > v"12"
415+
function LLVMContextSupportsTypedPointers(Ctx)
416+
ccall((:LLVMContextSupportsTypedPointers, libLLVMExtra), LLVMBool, (LLVMContextRef,), Ctx)
417+
end
418+
end

src/core/context.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ end
2727

2828
GlobalContext() = Context(API.LLVMGetGlobalContext())
2929

30+
if version() > v"13.0.0"
31+
supports_typed_pointers(ctx::Context) = API.LLVMContextSupportsTypedPointers(ctx) == 1
32+
else
33+
supports_typed_pointers(ctx::Context) = false
34+
end
3035

3136
## wrapper exception type
3237

test/core.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Context() do ctx end
2525

2626
@dispose ctx=Context() begin end
2727

28+
@dispose ctx=Context() begin
29+
@test LLVM.supports_typed_pointers(ctx) isa Bool
30+
end
31+
2832
end
2933

3034

0 commit comments

Comments
 (0)