
As part of the migration to ptradd (https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699), we need to change the representation of the `inrange` attribute, which is used for vtable splitting. Currently, inrange is specified as follows: ``` getelementptr inbounds ({ [4 x ptr], [4 x ptr] }, ptr @vt, i64 0, inrange i32 1, i64 2) ``` The `inrange` is placed on a GEP index, and all accesses must be "in range" of that index. The new representation is as follows: ``` getelementptr inbounds inrange(-16, 16) ({ [4 x ptr], [4 x ptr] }, ptr @vt, i64 0, i32 1, i64 2) ``` This specifies which offsets are "in range" of the GEP result. The new representation will continue working when canonicalizing to ptradd representation: ``` getelementptr inbounds inrange(-16, 16) (i8, ptr @vt, i64 48) ``` The inrange offsets are relative to the return value of the GEP. An alternative design could make them relative to the source pointer instead. The result-relative format was chosen on the off-chance that we want to extend support to non-constant GEPs in the future, in which case this variant is more expressive. This implementation "upgrades" the old inrange representation in bitcode by simply dropping it. This is a very niche feature, and I don't think trying to upgrade it is worthwhile. Let me know if you disagree.
47 lines
1.4 KiB
LLVM
47 lines
1.4 KiB
LLVM
; RUN: split-file %s %t
|
|
; RUN: not llvm-as < %t/parse-error-1.ll -o /dev/null 2>&1 | FileCheck --check-prefix=PARSE-ERROR-1 %s
|
|
; RUN: not llvm-as < %t/parse-error-2.ll -o /dev/null 2>&1 | FileCheck --check-prefix=PARSE-ERROR-2 %s
|
|
; RUN: not llvm-as < %t/parse-error-3.ll -o /dev/null 2>&1 | FileCheck --check-prefix=PARSE-ERROR-3 %s
|
|
; RUN: not llvm-as < %t/parse-error-4.ll -o /dev/null 2>&1 | FileCheck --check-prefix=PARSE-ERROR-4 %s
|
|
; RUN: not llvm-as < %t/end-not-larger-start.ll -o /dev/null 2>&1 | FileCheck --check-prefix=END-NOT-LARGER-START %s
|
|
|
|
;--- parse-error-1.ll
|
|
|
|
; PARSE-ERROR-1: error: expected integer
|
|
@g = external global i8
|
|
define ptr @test() {
|
|
ret ptr getelementptr inrange (i8, ptr @g, i64 8)
|
|
}
|
|
|
|
;--- parse-error-2.ll
|
|
|
|
; PARSE-ERROR-2: error: expected ','
|
|
@g = external global i8
|
|
define ptr @test() {
|
|
ret ptr getelementptr inrange(42 (i8, ptr @g, i64 8)
|
|
}
|
|
|
|
;--- parse-error-3.ll
|
|
|
|
; PARSE-ERROR-3: error: expected integer
|
|
@g = external global i8
|
|
define ptr @test() {
|
|
ret ptr getelementptr inrange(42, (i8, ptr @g, i64 8)
|
|
}
|
|
|
|
;--- parse-error-4.ll
|
|
|
|
; PARSE-ERROR-4: error: expected ')'
|
|
@g = external global i8
|
|
define ptr @test() {
|
|
ret ptr getelementptr inrange(42, 123 (i8, ptr @g, i64 8)
|
|
}
|
|
|
|
;--- end-not-larger-start.ll
|
|
|
|
; END-NOT-LARGER-START: error: expected end to be larger than start
|
|
@g = external global i8
|
|
define ptr @test() {
|
|
ret ptr getelementptr inrange(42, 42) (i8, ptr @g, i64 8)
|
|
}
|