Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 11 additions & 2 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4020,9 +4020,18 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
Function *F = CGM.getIntrinsic(Intrinsic::clear_cache, {CGM.DefaultPtrTy});
return RValue::get(Builder.CreateCall(F, {Begin, End}));
}
case Builtin::BI__builtin_trap:
EmitTrapCall(Intrinsic::trap);
case Builtin::BI__builtin_trap: {
llvm::CallInst *Trap = EmitTrapCall(Intrinsic::trap);
Trap->setDoesNotReturn();
Trap->setDoesNotThrow();
Comment thread
oontvoo marked this conversation as resolved.
Outdated
Builder.CreateUnreachable();
if (Builder.GetInsertBlock()) {
// Dummy block for the ret void - it'll be cleaned up.
llvm::BasicBlock *DeadBB = createBasicBlock("dead.trap");
EmitBlock(DeadBB);
}
Comment thread
oontvoo marked this conversation as resolved.
Outdated
return RValue::get(nullptr);
}
case Builtin::BI__builtin_verbose_trap: {
llvm::DILocation *TrapLocation = Builder.getCurrentDebugLocation();
if (getDebugInfo()) {
Expand Down
4 changes: 3 additions & 1 deletion clang/test/CodeGen/amdgpu-builtin-is-invocable.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// AMDGCN-GFX1010-SAME: ) #[[ATTR0:[0-9]+]] {
// AMDGCN-GFX1010-NEXT: [[ENTRY:.*:]]
// AMDGCN-GFX1010-NEXT: call void @llvm.trap()
// AMDGCN-GFX1010-NEXT: ret void
// AMDGCN-GFX1010-NEXT: unreachable
//
// AMDGCNSPIRV-LABEL: define spir_func void @foo(
// AMDGCNSPIRV-SAME: ) addrspace(4) #[[ATTR0:[0-9]+]] {
Expand All @@ -38,6 +38,8 @@
// AMDGCNSPIRV-NEXT: br i1 [[TOBOOL3]], label %[[IF_THEN]], label %[[IF_END:.*]]
// AMDGCNSPIRV: [[IF_THEN]]:
// AMDGCNSPIRV-NEXT: call addrspace(4) void @llvm.trap()
// AMDGCNSPIRV-NEXT: unreachable
// AMDGCNSPIRV: dead.trap:
// AMDGCNSPIRV-NEXT: br label %[[IF_END]]
// AMDGCNSPIRV: [[IF_END]]:
// AMDGCNSPIRV-NEXT: ret void
Expand Down
4 changes: 4 additions & 0 deletions clang/test/CodeGen/amdgpu-builtin-processor-is.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// AMDGCN-GFX900-SAME: ) #[[ATTR0:[0-9]+]] {
// AMDGCN-GFX900-NEXT: [[ENTRY:.*:]]
// AMDGCN-GFX900-NEXT: call void @llvm.trap()
// AMDGCN-GFX900-NEXT: unreachable
// AMDGCN-GFX900: dead.trap:
// AMDGCN-GFX900-NEXT: ret void
//
// AMDGCN-GFX1010-LABEL: define dso_local void @foo(
Expand Down Expand Up @@ -45,6 +47,8 @@
// AMDGCNSPIRV-NEXT: br i1 [[TOBOOL7]], label %[[IF_THEN]], label %[[IF_END:.*]]
// AMDGCNSPIRV: [[IF_THEN]]:
// AMDGCNSPIRV-NEXT: call addrspace(4) void @llvm.trap()
// AMDGCNSPIRV-NEXT: unreachable
// AMDGCNSPIRV: dead.trap:
// AMDGCNSPIRV-NEXT: br label %[[IF_END]]
// AMDGCNSPIRV: [[IF_END]]:
// AMDGCNSPIRV-NEXT: ret void
Expand Down
7 changes: 3 additions & 4 deletions clang/test/CodeGen/attr-nomerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ 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 @_ZN1AD1Ev(ptr {{.*}}) #[[ATTR1]]
// CHECK: call void @llvm.trap() #[[ATTR8:[0-9]+]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This breaks what this is supposed to be testing.

Please split the call to __builtin_trap() into a separate function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

// CHECK: unreachable

// CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}
// CHECK-DAG: attributes #[[ATTR1]] = {{{.*}}nomerge{{.*}}}
// CHECK-DAG attributes #[[ATTR8]] = { nomerge noreturn nounwind }
2 changes: 2 additions & 0 deletions clang/test/CodeGen/pr53127.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ void operator delete(void*);
// CHECK-NEXT: br i1 [[CALL]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
// CHECK: cond.true:
// CHECK-NEXT: call void @llvm.trap()
// CHECK-NEXT: unreachable
// CHECK: dead.trap:
// CHECK-NEXT: br label [[COND_END:%.*]]
// CHECK: cond.false:
// CHECK-NEXT: br label [[COND_END]]
Expand Down
1 change: 1 addition & 0 deletions clang/test/CodeGenCXX/microsoft-abi-byval-vararg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void call_var_args() {
}

// CHECK-LABEL: define dso_local void @"?call_var_args@@YAXXZ"()
// FIXME all of these are after the trap so they should be gone.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is something we plan to fix... not sure the FIXME is useful.

// 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 }>) %{{.*}})
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenCXX/trap-fnattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 no unwind "trap-func-name"="mytrap" }
// TRAPFUNC: attributes [[ATTR1]] = { {{.*}}"trap-func-name"="mytrap" }

// NOOPTION-NOT: attributes [[ATTR2]] = { {{.*}}"trap-func-name"="mytrap" }
Loading