Skip to content

Commit f0d898f

Browse files
authored
DAG: Move get_dynamic_area_offset type check to IR verifier (#145268)
Also fix the LangRef to match the implementation. This was checking against the alloca address space size rather than the default address space. The check was also more permissive than the LangRef. The error check permitted any size less than the pointer size; follow the stricter wording of the LangRef.
1 parent 90a6819 commit f0d898f

File tree

4 files changed

+40
-7
lines changed

4 files changed

+40
-7
lines changed

llvm/docs/LangRef.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14600,7 +14600,7 @@ Semantics:
1460014600
compile-time-known constant value.
1460114601

1460214602
The return value type of :ref:`llvm.get.dynamic.area.offset <int_get_dynamic_area_offset>`
14603-
must match the target's default address space's (address space 0) pointer type.
14603+
must match the target's :ref:`alloca address space <alloca_addrspace>` type.
1460414604

1460514605
'``llvm.prefetch``' Intrinsic
1460614606
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7320,13 +7320,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
73207320
return;
73217321
case Intrinsic::get_dynamic_area_offset: {
73227322
SDValue Op = getRoot();
7323-
EVT PtrTy = TLI.getFrameIndexTy(DAG.getDataLayout());
73247323
EVT ResTy = TLI.getValueType(DAG.getDataLayout(), I.getType());
7325-
// Result type for @llvm.get.dynamic.area.offset should match PtrTy for
7326-
// target.
7327-
if (PtrTy.getFixedSizeInBits() < ResTy.getFixedSizeInBits())
7328-
report_fatal_error("Wrong result type for @llvm.get.dynamic.area.offset"
7329-
" intrinsic!");
73307324
Res = DAG.getNode(ISD::GET_DYNAMIC_AREA_OFFSET, sdl, DAG.getVTList(ResTy),
73317325
Op);
73327326
DAG.setRoot(Op);

llvm/lib/IR/Verifier.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6061,6 +6061,15 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
60616061
"va_start called in a non-varargs function");
60626062
break;
60636063
}
6064+
case Intrinsic::get_dynamic_area_offset: {
6065+
auto *IntTy = dyn_cast<IntegerType>(Call.getType());
6066+
Check(IntTy && DL.getPointerSizeInBits(DL.getAllocaAddrSpace()) ==
6067+
IntTy->getBitWidth(),
6068+
"get_dynamic_area_offset result type must be scalar integer matching "
6069+
"alloca address space width",
6070+
Call);
6071+
break;
6072+
}
60646073
case Intrinsic::vector_reduce_and:
60656074
case Intrinsic::vector_reduce_or:
60666075
case Intrinsic::vector_reduce_xor:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; RUN: not llvm-as -disable-output %s 2>&1 | FileCheck %s
2+
3+
target datalayout = "p0:64:64-p5:32:32-A5"
4+
5+
declare i64 @llvm.get.dynamic.area.offset.i64()
6+
7+
; CHECK: get_dynamic_area_offset result type must be scalar integer matching alloca address space width
8+
; CHECK-NEXT: %res = call i64 @llvm.get.dynamic.area.offset.i64()
9+
define i64 @test_dynamic_area_too_big() {
10+
%res = call i64 @llvm.get.dynamic.area.offset.i64()
11+
ret i64 %res
12+
}
13+
14+
declare i16 @llvm.get.dynamic.area.offset.i16()
15+
16+
; CHECK: get_dynamic_area_offset result type must be scalar integer matching alloca address space width
17+
; CHECK-NEXT: %res = call i16 @llvm.get.dynamic.area.offset.i16()
18+
define i16 @test_dynamic_area_too_small() {
19+
%res = call i16 @llvm.get.dynamic.area.offset.i16()
20+
ret i16 %res
21+
}
22+
23+
declare <2 x i32> @llvm.get.dynamic.area.offset.v2i32()
24+
25+
; CHECK: get_dynamic_area_offset result type must be scalar integer matching alloca address space width
26+
; CHECK-NEXT: %res = call <2 x i32> @llvm.get.dynamic.area.offset.v2i32()
27+
define <2 x i32> @test_dynamic_area_vector() {
28+
%res = call <2 x i32> @llvm.get.dynamic.area.offset.v2i32()
29+
ret <2 x i32> %res
30+
}

0 commit comments

Comments
 (0)