Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions llvm/include/llvm/IR/Intrinsics.td
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,12 @@ def int_instrprof_mcdc_tvbitmap_update : Intrinsic<[],
[llvm_ptr_ty, llvm_i64_ty,
llvm_i32_ty, llvm_ptr_ty]>;

def int_call_preallocated_setup : DefaultAttrsIntrinsic<[llvm_token_ty], [llvm_i32_ty]>;
def int_call_preallocated_arg : DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_i32_ty]>;
def int_call_preallocated_setup
: DefaultAttrsIntrinsic<[llvm_token_ty], [llvm_i32_ty],
[ImmArg<ArgIndex<0>>]>;
def int_call_preallocated_arg
: DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_i32_ty],
[ImmArg<ArgIndex<1>>]>;
def int_call_preallocated_teardown : DefaultAttrsIntrinsic<[], [llvm_token_ty]>;

// This intrinsic is intentionally undocumented and users shouldn't call it;
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5869,9 +5869,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
break;
}
case Intrinsic::call_preallocated_setup: {
auto *NumArgs = dyn_cast<ConstantInt>(Call.getArgOperand(0));
Check(NumArgs != nullptr,
"llvm.call.preallocated.setup argument must be a constant");
auto *NumArgs = cast<ConstantInt>(Call.getArgOperand(0));
bool FoundCall = false;
for (User *U : Call.users()) {
auto *UseCall = dyn_cast<CallBase>(U);
Expand Down
10 changes: 9 additions & 1 deletion llvm/test/Verifier/preallocated-invalid.ll
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,21 @@ define void @preallocated_one_call() {
ret void
}

; CHECK: must be a constant
; CHECK: immarg operand has non-immediate parameter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test for the call_preallocated_arg case?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, but that's a pre-existing test coverage gap. This stuff relies on shared infrastructure. How much testing of immarg do we need, especially for a feature which was never productionized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, this did end up catching an issue in this case. Because part of the validation for preallocated.arg is done when visiting the preallocated.setup, we can't actually assume that the argument is constant in the verifier at that point, so it ended up asserting. I've restored that check, which also means that this doesn't actually produce the immarg message now.

define void @preallocated_setup_constant() {
%ac = call i32 @blackbox()
%cs = call token @llvm.call.preallocated.setup(i32 %ac)
ret void
}

; CHECK: llvm.call.preallocated.alloc arg index must be a constant
define void @preallocated_arg_constant() {
%ac = call i32 @blackbox()
%cs = call token @llvm.call.preallocated.setup(i32 3)
call token @llvm.call.preallocated.arg(token %cs, i32 %ac)
ret void
}

; CHECK: must be between 0 and corresponding
define void @preallocated_setup_arg_index_in_bounds() {
%cs = call token @llvm.call.preallocated.setup(i32 2)
Expand Down
Loading