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
11 changes: 9 additions & 2 deletions clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4626,8 +4626,8 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
}

llvm::CallInst *CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID) {
llvm::CallInst *TrapCall =
Builder.CreateCall(CGM.getIntrinsic(IntrID));
llvm::Function *TrapIntrinsic = CGM.getIntrinsic(IntrID);
llvm::CallInst *TrapCall = Builder.CreateCall(TrapIntrinsic);

if (!CGM.getCodeGenOpts().TrapFuncName.empty()) {
auto A = llvm::Attribute::get(getLLVMContext(), "trap-func-name",
Expand All @@ -4637,6 +4637,13 @@ llvm::CallInst *CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID) {

if (InNoMergeAttributedStmt)
TrapCall->addFnAttr(llvm::Attribute::NoMerge);
if (TrapIntrinsic->doesNotThrow())
TrapCall->setDoesNotThrow();
if (TrapIntrinsic->doesNotReturn()) {
TrapCall->setDoesNotReturn();
Builder.CreateUnreachable();
EmitBlock(createBasicBlock());
}
return TrapCall;
}

Expand Down
10 changes: 8 additions & 2 deletions clang/test/CodeGen/amdgpu-builtin-is-invocable.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
// AMDGCN-GFX1010-LABEL: define dso_local void @foo(
// AMDGCN-GFX1010-SAME: ) #[[ATTR0:[0-9]+]] {
// AMDGCN-GFX1010-NEXT: [[ENTRY:.*:]]
// AMDGCN-GFX1010-NEXT: call void @llvm.trap()
// AMDGCN-GFX1010-NEXT: call void @llvm.trap() #[[ATTR2:[0-9]+]]
// AMDGCN-GFX1010-NEXT: unreachable
// AMDGCN-GFX1010: [[BB0:.*:]]
// AMDGCN-GFX1010-NEXT: ret void
//
// AMDGCNSPIRV-LABEL: define spir_func void @foo(
Expand All @@ -37,7 +39,9 @@
// AMDGCNSPIRV-NEXT: [[TOBOOL3:%.*]] = icmp ne i1 [[TMP2]], false
// AMDGCNSPIRV-NEXT: br i1 [[TOBOOL3]], label %[[IF_THEN]], label %[[IF_END:.*]]
// AMDGCNSPIRV: [[IF_THEN]]:
// AMDGCNSPIRV-NEXT: call addrspace(4) void @llvm.trap()
// AMDGCNSPIRV-NEXT: call addrspace(4) void @llvm.trap() #[[ATTR3:[0-9]+]]
// AMDGCNSPIRV-NEXT: unreachable
// AMDGCNSPIRV: [[BB3:.*:]]
// AMDGCNSPIRV-NEXT: br label %[[IF_END]]
// AMDGCNSPIRV: [[IF_END]]:
// AMDGCNSPIRV-NEXT: ret void
Expand All @@ -53,10 +57,12 @@ void foo() {
//.
// AMDGCN-GFX1010: attributes #[[ATTR0]] = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx1010" }
// AMDGCN-GFX1010: attributes #[[ATTR1:[0-9]+]] = { cold noreturn nounwind memory(inaccessiblemem: write) }
// AMDGCN-GFX1010: attributes #[[ATTR2]] = { noreturn nounwind }
//.
// AMDGCNSPIRV: attributes #[[ATTR0]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+16-bit-insts,+add-min-max-insts,+ashr-pk-insts,+asynccnt,+atomic-buffer-global-pk-add-f16-insts,+atomic-buffer-pk-add-bf16-inst,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-fmin-fmax-global-f32,+atomic-fmin-fmax-global-f64,+atomic-global-pk-add-bf16-inst,+bf16-cvt-insts,+bf16-pk-insts,+bf16-trans-insts,+bf8-cvt-scale-insts,+bitop3-insts,+ci-insts,+clusters,+cube-insts,+cvt-pknorm-vop2-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot11-insts,+dot12-insts,+dot13-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+f16bf16-to-fp6bf6-cvt-scale-insts,+f32-to-f16bf16-cvt-sr-insts,+flat-global-insts,+fp4-cvt-scale-insts,+fp6bf6-cvt-scale-insts,+fp8-conversion-insts,+fp8-cvt-scale-insts,+fp8-insts,+fp8e5m3-insts,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx12-insts,+gfx1250-insts,+gfx1251-gemm-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+gfx950-insts,+gws,+image-insts,+lerp-inst,+mai-insts,+mcast-load-insts,+mqsad-insts,+mqsad-pk-insts,+msad-insts,+permlane16-swap,+permlane32-swap,+pk-add-min-max-insts,+prng-inst,+qsad-insts,+s-memrealtime,+s-memtime-inst,+s-wakeup-barrier-inst,+sad-insts,+setprio-inc-wg-inst,+swmmac-gfx1200-insts,+swmmac-gfx1250-insts,+tanh-insts,+tensor-cvt-lut-insts,+transpose-load-f4f6-insts,+vmem-pref-insts,+vmem-to-lds-load-insts,+wavefrontsize32,+wavefrontsize64,+wmma-128b-insts,+wmma-256b-insts,+xf32-insts" }
// AMDGCNSPIRV: attributes #[[ATTR1:[0-9]+]] = { nounwind }
// AMDGCNSPIRV: attributes #[[ATTR2:[0-9]+]] = { cold noreturn nounwind memory(inaccessiblemem: write) }
// AMDGCNSPIRV: attributes #[[ATTR3]] = { noreturn nounwind }
//.
// AMDGCN-GFX900: [[META0:![0-9]+]] = !{i32 1, !"amdhsa_code_object_version", i32 600}
// AMDGCN-GFX900: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
Expand Down
10 changes: 8 additions & 2 deletions clang/test/CodeGen/amdgpu-builtin-processor-is.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
// AMDGCN-GFX900-LABEL: define dso_local void @foo(
// AMDGCN-GFX900-SAME: ) #[[ATTR0:[0-9]+]] {
// AMDGCN-GFX900-NEXT: [[ENTRY:.*:]]
// AMDGCN-GFX900-NEXT: call void @llvm.trap()
// AMDGCN-GFX900-NEXT: call void @llvm.trap() #[[ATTR2:[0-9]+]]
// AMDGCN-GFX900-NEXT: unreachable
// AMDGCN-GFX900: [[BB0:.*:]]
// AMDGCN-GFX900-NEXT: ret void
//
// AMDGCN-GFX1010-LABEL: define dso_local void @foo(
Expand Down Expand Up @@ -44,7 +46,9 @@
// AMDGCNSPIRV-NEXT: [[TOBOOL7:%.*]] = icmp ne i1 [[TMP4]], false
// AMDGCNSPIRV-NEXT: br i1 [[TOBOOL7]], label %[[IF_THEN]], label %[[IF_END:.*]]
// AMDGCNSPIRV: [[IF_THEN]]:
// AMDGCNSPIRV-NEXT: call addrspace(4) void @llvm.trap()
// AMDGCNSPIRV-NEXT: call addrspace(4) void @llvm.trap() #[[ATTR3:[0-9]+]]
// AMDGCNSPIRV-NEXT: unreachable
// AMDGCNSPIRV: [[BB5:.*:]]
// AMDGCNSPIRV-NEXT: br label %[[IF_END]]
// AMDGCNSPIRV: [[IF_END]]:
// AMDGCNSPIRV-NEXT: ret void
Expand All @@ -60,12 +64,14 @@ void foo() {
//.
// AMDGCN-GFX900: attributes #[[ATTR0]] = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" }
// AMDGCN-GFX900: attributes #[[ATTR1:[0-9]+]] = { cold noreturn nounwind memory(inaccessiblemem: write) }
// AMDGCN-GFX900: attributes #[[ATTR2]] = { noreturn nounwind }
//.
// AMDGCN-GFX1010: attributes #[[ATTR0]] = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx1010" }
//.
// AMDGCNSPIRV: attributes #[[ATTR0]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+16-bit-insts,+add-min-max-insts,+ashr-pk-insts,+asynccnt,+atomic-buffer-global-pk-add-f16-insts,+atomic-buffer-pk-add-bf16-inst,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-fmin-fmax-global-f32,+atomic-fmin-fmax-global-f64,+atomic-global-pk-add-bf16-inst,+bf16-cvt-insts,+bf16-pk-insts,+bf16-trans-insts,+bf8-cvt-scale-insts,+bitop3-insts,+ci-insts,+clusters,+cube-insts,+cvt-pknorm-vop2-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot11-insts,+dot12-insts,+dot13-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+f16bf16-to-fp6bf6-cvt-scale-insts,+f32-to-f16bf16-cvt-sr-insts,+flat-global-insts,+fp4-cvt-scale-insts,+fp6bf6-cvt-scale-insts,+fp8-conversion-insts,+fp8-cvt-scale-insts,+fp8-insts,+fp8e5m3-insts,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx12-insts,+gfx1250-insts,+gfx1251-gemm-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+gfx950-insts,+gws,+image-insts,+lerp-inst,+mai-insts,+mcast-load-insts,+mqsad-insts,+mqsad-pk-insts,+msad-insts,+permlane16-swap,+permlane32-swap,+pk-add-min-max-insts,+prng-inst,+qsad-insts,+s-memrealtime,+s-memtime-inst,+s-wakeup-barrier-inst,+sad-insts,+setprio-inc-wg-inst,+swmmac-gfx1200-insts,+swmmac-gfx1250-insts,+tanh-insts,+tensor-cvt-lut-insts,+transpose-load-f4f6-insts,+vmem-pref-insts,+vmem-to-lds-load-insts,+wavefrontsize32,+wavefrontsize64,+wmma-128b-insts,+wmma-256b-insts,+xf32-insts" }
// AMDGCNSPIRV: attributes #[[ATTR1:[0-9]+]] = { nounwind }
// AMDGCNSPIRV: attributes #[[ATTR2:[0-9]+]] = { cold noreturn nounwind memory(inaccessiblemem: write) }
// AMDGCNSPIRV: attributes #[[ATTR3]] = { noreturn nounwind }
//.
// AMDGCN-GFX900: [[META0:![0-9]+]] = !{i32 1, !"amdhsa_code_object_version", i32 600}
// AMDGCN-GFX900: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
Expand Down
23 changes: 19 additions & 4 deletions clang/test/CodeGen/attr-nomerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@ void foo(int i, A *ap, B *bp) {

A *newA = new B();
delete newA;
[[clang::nomerge]] __builtin_trap();
[[clang::nomerge]] __debugbreak();
[[clang::nomerge]] __debugbreak();
}

void foo_trap() {
[[clang::nomerge]] __builtin_trap();
}

void foo_verbose_trap() {
[[clang::nomerge]] __builtin_verbose_trap("check null", "Argument must not be null.");
}

Expand Down Expand Up @@ -100,10 +107,18 @@ void something_else_again() {
// CHECK: load ptr, ptr
// CHECK: %[[AG:.*]] = load ptr, ptr
// CHECK-NEXT: call void %[[AG]](ptr {{.*}}) #[[ATTR1]]
// CHECK: call void @llvm.trap() #[[ATTR0]]
// CHECK: call void @llvm.debugtrap() #[[ATTR0]]
// CHECK: call void @llvm.trap() #[[ATTR0]]
// CHECK: call void @llvm.debugtrap() #[[ATTR1]]
// CHECK: call void @llvm.debugtrap() #[[ATTR1]]
// CHECK: call void @_ZN1AD1Ev(ptr {{.*}}) #[[ATTR1]]

// CHECK-LABEL: define dso_local void @_Z8foo_trapv()
// CHECK: call void @llvm.trap() #[[ATTR_TRAP:[0-9]+]]
// CHECK-NEXT: unreachable

// CHECK-LABEL: define dso_local void @_Z16foo_verbose_trapv()
// CHECK: call void @llvm.trap() #[[ATTR_TRAP]]
// CHECK-NEXT: unreachable

// CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}
// CHECK-DAG: attributes #[[ATTR1]] = {{{.*}}nomerge{{.*}}}
// CHECK-DAG: attributes #[[ATTR_TRAP]] = {{{.*}}nomerge{{.*}}}
17 changes: 17 additions & 0 deletions clang/test/CodeGen/builtin-trap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 %s -o - | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O1 %s -o - | FileCheck %s
// RUN: %clang_cc1 -triple wasm32-unknown-unknown -emit-llvm -O0 %s -o - | FileCheck %s

// CHECK-LABEL: define {{.*}}void @test_trap()
void test_trap(void) {
// CHECK: call void @llvm.trap()
// CHECK-NEXT: unreachable
__builtin_trap();
}

// CHECK-LABEL: define {{.*}}void @test_debugtrap()
void test_debugtrap(void) {
// CHECK: call void @llvm.debugtrap()
// CHECK-NOT: unreachable
__builtin_debugtrap();
}
26 changes: 14 additions & 12 deletions clang/test/CodeGen/pr53127.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ void operator delete(void*);
// CHECK-LABEL: @_Z1fPiz(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[P_ADDR:%.*]] = alloca ptr, align 8
// CHECK-NEXT: [[L:%.*]] = alloca [1 x %struct.__va_list_tag], align 16
// CHECK-NEXT: [[L2:%.*]] = alloca [1 x %struct.__va_list_tag], align 16
// CHECK-NEXT: [[L:%.*]] = alloca [1 x [[STRUCT___VA_LIST_TAG:%.*]]], align 16
// CHECK-NEXT: [[L2:%.*]] = alloca [1 x [[STRUCT___VA_LIST_TAG]]], align 16
// CHECK-NEXT: store ptr [[P:%.*]], ptr [[P_ADDR]], align 8
// CHECK-NEXT: [[CALL:%.*]] = call noundef zeroext i1 @_Z1ev()
// CHECK-NEXT: br i1 [[CALL]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
// CHECK: cond.true:
// CHECK-NEXT: call void @llvm.trap()
// CHECK-NEXT: call void @llvm.trap() #[[ATTR8:[0-9]+]]
// CHECK-NEXT: unreachable
// CHECK: 0:
// CHECK-NEXT: br label [[COND_END:%.*]]
// CHECK: cond.false:
// CHECK-NEXT: br label [[COND_END]]
Expand All @@ -28,12 +30,12 @@ void operator delete(void*);
// CHECK-NEXT: br label [[COND_END4]]
// CHECK: cond.end4:
// CHECK-NEXT: [[CALL5:%.*]] = call noundef zeroext i1 @_Z1ev()
// CHECK-NEXT: [[TMP0:%.*]] = zext i1 [[CALL5]] to i64
// CHECK-NEXT: [[TMP1:%.*]] = zext i1 [[CALL5]] to i64
// CHECK-NEXT: call void @llvm.assume(i1 true)
// CHECK-NEXT: [[CALL6:%.*]] = call noundef zeroext i1 @_Z1ev()
// CHECK-NEXT: br i1 [[CALL6]], label [[COND_TRUE7:%.*]], label [[COND_FALSE8:%.*]]
// CHECK: cond.true7:
// CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr [[L]], i64 0, i64 0
// CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [1 x [[STRUCT___VA_LIST_TAG]]], ptr [[L]], i64 0, i64 0
// CHECK-NEXT: call void @llvm.va_start.p0(ptr [[ARRAYDECAY]])
// CHECK-NEXT: br label [[COND_END9:%.*]]
// CHECK: cond.false8:
Expand All @@ -42,8 +44,8 @@ void operator delete(void*);
// CHECK-NEXT: [[CALL10:%.*]] = call noundef zeroext i1 @_Z1ev()
// CHECK-NEXT: br i1 [[CALL10]], label [[COND_TRUE11:%.*]], label [[COND_FALSE14:%.*]]
// CHECK: cond.true11:
// CHECK-NEXT: [[ARRAYDECAY12:%.*]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr [[L]], i64 0, i64 0
// CHECK-NEXT: [[ARRAYDECAY13:%.*]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr [[L2]], i64 0, i64 0
// CHECK-NEXT: [[ARRAYDECAY12:%.*]] = getelementptr inbounds [1 x [[STRUCT___VA_LIST_TAG]]], ptr [[L]], i64 0, i64 0
// CHECK-NEXT: [[ARRAYDECAY13:%.*]] = getelementptr inbounds [1 x [[STRUCT___VA_LIST_TAG]]], ptr [[L2]], i64 0, i64 0
// CHECK-NEXT: call void @llvm.va_copy.p0(ptr [[ARRAYDECAY12]], ptr [[ARRAYDECAY13]])
// CHECK-NEXT: br label [[COND_END15:%.*]]
// CHECK: cond.false14:
Expand All @@ -52,8 +54,8 @@ void operator delete(void*);
// CHECK-NEXT: [[CALL16:%.*]] = call noundef zeroext i1 @_Z1ev()
// CHECK-NEXT: br i1 [[CALL16]], label [[COND_TRUE17:%.*]], label [[COND_FALSE18:%.*]]
// CHECK: cond.true17:
// CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[P_ADDR]], align 8
// CHECK-NEXT: call void @llvm.prefetch.p0(ptr [[TMP1]], i32 0, i32 3, i32 1)
// CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr [[P_ADDR]], align 8
// CHECK-NEXT: call void @llvm.prefetch.p0(ptr [[TMP2]], i32 0, i32 3, i32 1)
// CHECK-NEXT: br label [[COND_END19:%.*]]
// CHECK: cond.false18:
// CHECK-NEXT: br label [[COND_END19]]
Expand All @@ -67,9 +69,9 @@ void operator delete(void*);
// CHECK-NEXT: br label [[COND_END23]]
// CHECK: cond.end23:
// CHECK-NEXT: [[CALL24:%.*]] = call noundef zeroext i1 @_Z1ev()
// CHECK-NEXT: [[TMP2:%.*]] = zext i1 [[CALL24]] to i64
// CHECK-NEXT: [[TMP3:%.*]] = load ptr, ptr [[P_ADDR]], align 8
// CHECK-NEXT: call void @_ZdlPv(ptr noundef [[TMP3]]) #[[ATTR8:[0-9]+]]
// CHECK-NEXT: [[TMP3:%.*]] = zext i1 [[CALL24]] to i64
// CHECK-NEXT: [[TMP4:%.*]] = load ptr, ptr [[P_ADDR]], align 8
// CHECK-NEXT: call void @_ZdlPv(ptr noundef [[TMP4]]) #[[ATTR9:[0-9]+]]
// CHECK-NEXT: ret void
//
void f(int* p, ...)
Expand Down
12 changes: 5 additions & 7 deletions clang/test/CodeGenCXX/microsoft-abi-byval-vararg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ void call_var_args() {
}

// CHECK-LABEL: define dso_local void @"?call_var_args@@YAXXZ"()
// CHECK: call void {{.*varargs_zero.*}}(ptr inalloca(<{ %struct.A }>) %{{.*}})
// CHECK: call void {{.*varargs_one.*}}(ptr inalloca(<{ i32, %struct.A }>) %{{.*}})
// CHECK: call void {{.*varargs_two.*}}(ptr inalloca(<{ i32, i32, %struct.A }>) %{{.*}})
// CHECK: call void {{.*varargs_three.*}}(ptr inalloca(<{ i32, i32, i32, %struct.A }>) %{{.*}})
// Passing non-POD to varargs ellipsis (...) traps. Since the trap is noreturn,
// it is followed by unreachable, and subsequent dead code (like inalloca stack
// allocations and varargs calls) is pruned and not emitted.
// CHECK: call void @llvm.trap()
// CHECK-NEXT: unreachable

// CHECK-LABEL: declare dso_local void @"?varargs_zero@@YAXZZ"(...)
// CHECK-LABEL: declare dso_local void @"?varargs_one@@YAXHZZ"(i32 noundef, ...)
// CHECK-LABEL: declare dso_local void @"?varargs_two@@YAXHHZZ"(i32 noundef, i32 noundef, ...)
// CHECK-LABEL: declare dso_local void @"?varargs_three@@YAXHHHZZ"(i32 noundef, i32 noundef, i32 noundef, ...)
6 changes: 3 additions & 3 deletions clang/test/CodeGenCXX/microsoft-vector-deleting-dtors2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ void TesttheTest() {
// CHECK: dtor.scalar:
// X64-NEXT: call void @"??1Test@@UEAA@XZ"(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %this1)
// X86-NEXT: call x86_thiscallcc void @"??1Test@@UAE@XZ"(ptr noundef nonnull align 4 dead_on_return(4) dereferenceable(4) %this1)
// CHECK-NEXT: %6 = and i32 %should_call_delete2, 1
// CHECK-NEXT: %7 = icmp eq i32 %6, 0
// CHECK-NEXT: br i1 %7, label %dtor.continue, label %dtor.call_delete
// CHECK-NEXT: %7 = and i32 %should_call_delete2, 1
// CHECK-NEXT: %8 = icmp eq i32 %7, 0
// CHECK-NEXT: br i1 %8, label %dtor.continue, label %dtor.call_delete
// CHECK: dtor.call_delete:
// X64-NEXT: call void @"??3Test@@SAXPEAX@Z"(ptr noundef %this1)
// X86-NEXT: call void @"??3Test@@SAXPAX@Z"(ptr noundef %this1)
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CodeGenCXX/trap-fnattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// TRAPFUNC: call void @llvm.trap() [[ATTR0:#[0-9]+]]

// NOOPTION-LABEL: define {{(dso_local )?}}void @{{_Z12test_builtinv|\"\?test_builtin@@YAXXZ\"}}
// NOOPTION: call void @llvm.trap(){{$}}
// NOOPTION: call void @llvm.trap()

void test_builtin(void) {
__builtin_trap();
Expand All @@ -15,7 +15,7 @@ void test_builtin(void) {
// TRAPFUNC: call void @llvm.trap() [[ATTR0]]

// NOOPTION-LABEL: define {{.*}}i32 @{{_Z13test_noreturnv|\"\?test_noreturn@@YAHXZ\"}}
// NOOPTION: call void @llvm.trap(){{$}}
// NOOPTION: call void @llvm.trap()

int test_noreturn(void) {
}
Expand All @@ -30,7 +30,7 @@ int test_add_overflow(int a, int b) {
return a + b;
}

// TRAPFUNC: attributes [[ATTR0]] = { {{.*}}"trap-func-name"="mytrap" }
// TRAPFUNC: attributes [[ATTR0]] = { noreturn nounwind "trap-func-name"="mytrap" }
// TRAPFUNC: attributes [[ATTR1]] = { {{.*}}"trap-func-name"="mytrap" }

// NOOPTION-NOT: attributes [[ATTR2]] = { {{.*}}"trap-func-name"="mytrap" }
2 changes: 1 addition & 1 deletion clang/test/CodeGenCXX/vararg-non-pod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ void vararg(...);
void test(X x) {
// CHECK: call void @llvm.trap()
vararg(x);
// CHECK: ret void
// CHECK-NEXT: unreachable
}
17 changes: 11 additions & 6 deletions clang/test/DebugInfo/CXX/verbose-trap.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++20 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s

// CHECK-LABEL: define void @_Z2f0v()
// CHECK: call void @llvm.trap(), !dbg ![[LOC17:.*]]
// CHECK: call void @llvm.trap(){{.*}}, !dbg ![[LOC17:.*]]

// CHECK: declare void @llvm.trap() #[[ATTR1:.*]]

// CHECK-LABEL: define void @_Z2f1v()
// CHECK: call void @llvm.trap(), !dbg ![[LOC23:.*]]
// CHECK: call void @llvm.trap(), !dbg ![[LOC25:.*]]
// CHECK: call void @llvm.trap(){{.*}}, !dbg ![[LOC23:.*]]

// CHECK-LABEL: define void @_Z4f1_bv()
// CHECK: call void @llvm.trap(){{.*}}, !dbg ![[LOC25:.*]]

// CHECK-LABEL: define void @_Z2f3v()
// CHECK: call void @_Z2f2IXadsoKcL_ZL8constCatEEEXadsoS0_L_ZL8constMsgEEEEvv()

// CHECK-LABEL: define internal void @_Z2f2IXadsoKcL_ZL8constCatEEEXadsoS0_L_ZL8constMsgEEEEvv
// CHECK: call void @llvm.trap(), !dbg ![[LOC36:.*]]
// CHECK: call void @llvm.trap(){{.*}}, !dbg ![[LOC36:.*]]

// CHECK: attributes #[[ATTR1]] = { cold {{.*}}}

Expand All @@ -32,12 +34,15 @@ void f0() {

// CHECK: ![[SUBPROG22:.*]] = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v",
// CHECK: ![[LOC23]] = !DILocation(line: 0, scope: ![[SUBPROG18]], inlinedAt: ![[LOC24:.*]])
// CHECK: ![[LOC24]] = !DILocation(line: [[@LINE+5]], column: 3, scope: ![[SUBPROG22]])
// CHECK: ![[LOC24]] = !DILocation(line: [[@LINE+6]], column: 3, scope: ![[SUBPROG22]])
// CHECK: ![[SUBPROG_F1B:.*]] = distinct !DISubprogram(name: "f1_b", linkageName: "_Z4f1_bv",
// CHECK: ![[LOC25]] = !DILocation(line: 0, scope: ![[SUBPROG26:.*]], inlinedAt: ![[LOC27:.*]])
// CHECK: ![[SUBPROG26]] = distinct !DISubprogram(name: "__clang_trap_msg$category2$hello", scope: ![[FILESCOPE]], file: ![[FILESCOPE]], type: !{{.*}}, flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: !{{.*}})
// CHECK: ![[LOC27]] = !DILocation(line: [[@LINE+3]], column: 3, scope: ![[SUBPROG22]])
// CHECK: ![[LOC27]] = !DILocation(line: [[@LINE+5]], column: 3, scope: ![[SUBPROG_F1B]])
void f1() {
__builtin_verbose_trap("category1", "Argument_must_not_be_null");
}
void f1_b() {
__builtin_verbose_trap("category2", "hello");
}

Expand Down
2 changes: 1 addition & 1 deletion clang/test/Headers/gpuintrin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,7 @@ __gpu_kernel void foo() {
// SPIRV-SAME: ) #[[ATTR1:[0-9]+]] {
// SPIRV-NEXT: [[ENTRY:.*:]]
// SPIRV-NEXT: call void @llvm.trap()
// SPIRV-NEXT: ret void
// SPIRV-NEXT: unreachable
//
//.
// AMDGPU: [[RNG2]] = !{i32 1, i32 0}
Expand Down
3 changes: 2 additions & 1 deletion clang/test/OpenMP/spirv_target_codegen_noexceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// RUN: FileCheck -implicit-check-not='{{invoke|throw|cxa}}' %s
void foo() {
// CHECK: call addrspace(9) void @llvm.trap()
// CHECK-NEXT: call spir_func addrspace(9) void @__kmpc_target_deinit()
// CHECK-NEXT: unreachable
// CHECK: call spir_func addrspace(9) void @__kmpc_target_deinit()
#pragma omp target
throw "bad";
}
Loading
Loading