Currently the max alignment representable is 1GB, see D108661. Setting the align of an object to 4GB is desirable in some cases to make sure the lower 32 bits are clear which can be used for some optimizations, e.g. https://crbug.com/1016945. This uses an extra bit in instructions that carry an alignment. We can store 15 bits of "free" information, and with this change some instructions (e.g. AtomicCmpXchgInst) use 14 bits. We can increase the max alignment representable above 4GB (up to 2^62) since we're only using 33 of the 64 values, but I've just limited it to 4GB for now. The one place we have to update the bitcode format is for the alloca instruction. It stores its alignment into 5 bits of a 32 bit bitfield. I've added another field which is 8 bits and should be future proof for a while. For backward compatibility, we check if the old field has a value and use that, otherwise use the new field. Updating clang's max allowed alignment will come in a future patch. Reviewed By: hans Differential Revision: https://reviews.llvm.org/D110451
60 lines
1.2 KiB
LLVM
60 lines
1.2 KiB
LLVM
; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
|
|
|
|
declare i8* @foo()
|
|
|
|
define void @f1() {
|
|
entry:
|
|
call i8* @foo(), !align !{i64 2}
|
|
ret void
|
|
}
|
|
; CHECK: align applies only to load instructions
|
|
; CHECK-NEXT: call i8* @foo()
|
|
|
|
define i8 @f2(i8* %x) {
|
|
entry:
|
|
%y = load i8, i8* %x, !align !{i64 2}
|
|
ret i8 %y
|
|
}
|
|
; CHECK: align applies only to pointer types
|
|
; CHECK-NEXT: load i8, i8* %x
|
|
|
|
define i8* @f3(i8** %x) {
|
|
entry:
|
|
%y = load i8*, i8** %x, !align !{}
|
|
ret i8* %y
|
|
}
|
|
; CHECK: align takes one operand
|
|
; CHECK-NEXT: load i8*, i8** %x
|
|
|
|
define i8* @f4(i8** %x) {
|
|
entry:
|
|
%y = load i8*, i8** %x, !align !{!"str"}
|
|
ret i8* %y
|
|
}
|
|
; CHECK: align metadata value must be an i64!
|
|
; CHECK-NEXT: load i8*, i8** %x
|
|
|
|
define i8* @f5(i8** %x) {
|
|
entry:
|
|
%y = load i8*, i8** %x, !align !{i32 2}
|
|
ret i8* %y
|
|
}
|
|
; CHECK: align metadata value must be an i64!
|
|
; CHECK-NEXT: load i8*, i8** %x
|
|
|
|
define i8* @f6(i8** %x) {
|
|
entry:
|
|
%y = load i8*, i8** %x, !align !{i64 3}
|
|
ret i8* %y
|
|
}
|
|
; CHECK: align metadata value must be a power of 2!
|
|
; CHECK-NEXT: load i8*, i8** %x
|
|
|
|
define i8* @f7(i8** %x) {
|
|
entry:
|
|
%y = load i8*, i8** %x, !align !{i64 8589934592}
|
|
ret i8* %y
|
|
}
|
|
; CHECK: alignment is larger that implementation defined limit
|
|
; CHECK-NEXT: load i8*, i8** %x
|