Skip to content

Commit 6c837ee

Browse files
committed
Switch align APIs from Global to GVar.
Follows llvm/llvm-project#143188
1 parent 326f833 commit 6c837ee

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

docs/src/lib/values.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ unnamed_addr
6666
unnamed_addr!
6767
local_unnamed_addr
6868
local_unnamed_addr!
69-
alignment(::LLVM.GlobalValue)
70-
alignment!(::LLVM.GlobalValue, ::Integer)
7169
```
7270

7371
### Global variables
@@ -87,6 +85,8 @@ isconstant(::GlobalVariable)
8785
constant!
8886
isextinit
8987
extinit!
88+
alignment(::GlobalVariable)
89+
alignment!(::GlobalVariable, ::Integer)
9090
```
9191

9292
## Uses

docs/src/man/values.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ couple of additional APIs:
199199
- `linkage`/`linkage!`: get or set the linkage of the global value.
200200
- `visibility`/`visibility!`: get or set the visibility of the global value.
201201
- `section`/`section!`: get or set the section of the global value.
202-
- `alignment`/`alignment!`: get or set the alignment of the global value.
203202
- `dllstorage`/`dllstorage!`: get or set the DLL storage class of the global value.
204203
- `unnamed_addr`/`unnamed_addr!`: get or set whether the global value has an unnamed address.
205204
- `local_unnamed_addr`/`local_unnamed_addr!`: get or set whether the global value has a local unnamed address.
@@ -223,6 +222,7 @@ Global variables support additional APIs:
223222
- `isconstant`/`isconstant!`: get or set whether the global variable is constant.
224223
- `isextinit`/`isextinit!`: get or set whether the global variable is externally initialized.
225224
- `erase!`: delete the global variable from its parent module, and delete the object.
225+
- `alignment`/`alignment!`: get or set the alignment of the global variable.
226226

227227

228228
## Uses

src/core/value/constant.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,7 @@ export GlobalValue, global_value_type,
756756
visibility, visibility!,
757757
dllstorage, dllstorage!,
758758
unnamed_addr, unnamed_addr!,
759-
local_unnamed_addr, local_unnamed_addr!,
760-
alignment, alignment!
759+
local_unnamed_addr, local_unnamed_addr!
761760

762761
"""
763762
parent(val::LLVM.GlobalValue)
@@ -884,20 +883,6 @@ Set the local unnamed address flag of the global value.
884883
"""
885884
local_unnamed_addr!(val::GlobalValue, flag::Bool) = API.LLVMSetUnnamedAddress(val, flag ? API.LLVMLocalUnnamedAddr : API.LLVMNoUnnamedAddr)
886885

887-
"""
888-
alignment(val::LLVM.GlobalValue)
889-
890-
Get the alignment of the global value.
891-
"""
892-
alignment(val::GlobalValue) = API.LLVMGetAlignment(val)
893-
894-
"""
895-
alignment!(val::LLVM.GlobalValue, bytes::Integer)
896-
897-
Set the alignment of the global value.
898-
"""
899-
alignment!(val::GlobalValue, bytes::Integer) = API.LLVMSetAlignment(val, bytes)
900-
901886

902887
## global variables
903888

@@ -908,7 +893,8 @@ export GlobalVariable, erase!,
908893
isthreadlocal, threadlocal!,
909894
threadlocalmode, threadlocalmode!,
910895
isconstant, constant!,
911-
isextinit, extinit!
896+
isextinit, extinit!,
897+
alignment, alignment!
912898

913899
"""
914900
GlobalVariable <: LLVM.GlobalObject
@@ -1020,3 +1006,17 @@ isextinit(gv::GlobalVariable) = API.LLVMIsExternallyInitialized(gv) |> Bool
10201006
Set the externally initialized flag of the global variable.
10211007
"""
10221008
extinit!(gv::GlobalVariable, bool) = API.LLVMSetExternallyInitialized(gv, bool)
1009+
1010+
"""
1011+
alignment(gv::GlobalVariable)
1012+
1013+
Get the alignment of the global variable.
1014+
"""
1015+
alignment(gv::GlobalVariable) = API.LLVMGetAlignment(gv)
1016+
1017+
"""
1018+
alignment!(gv::GlobalVariable, bytes::Integer)
1019+
1020+
Set the alignment of the global variable.
1021+
"""
1022+
alignment!(gv::GlobalVariable, bytes::Integer) = API.LLVMSetAlignment(gv, bytes)

test/core_tests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,6 @@ end
759759
@test !unnamed_addr(fn)
760760
@test local_unnamed_addr(fn)
761761

762-
@test alignment(fn) == 0
763-
alignment!(fn, 4)
764-
@test alignment(fn) == 4
765-
766762
str = MDString("bar")
767763
md = MDNode([str])
768764
@test isempty(metadata(fn))
@@ -808,6 +804,10 @@ end
808804
extinit!(gv, true)
809805
@test isextinit(gv)
810806

807+
@test alignment(gv) == 0
808+
alignment!(gv, 4)
809+
@test alignment(gv) == 4
810+
811811
@test threadlocalmode(gv) == LLVM.API.LLVMGeneralDynamicTLSModel
812812
threadlocalmode!(gv, LLVM.API.LLVMNotThreadLocal)
813813
@test threadlocalmode(gv) == LLVM.API.LLVMNotThreadLocal

0 commit comments

Comments
 (0)