Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attach attribute "trap-func-name" to call sites of llvm.trap and llvm…
….debugtrap. This is needed to use clang's command line option "-ftrap-function" for LTO and enable changing the trap function name on a per-call-site basis. rdar://problem/21225723 Differential Revision: http://reviews.llvm.org/D10831 llvm-svn: 241306
- Loading branch information
Showing
7 changed files
with
62 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// RUN: %clang_cc1 -O0 -emit-llvm -ftrapv -ftrap-function=mytrap %s -o - | FileCheck %s -check-prefix=TRAPFUNC | ||
// RUN: %clang_cc1 -O0 -emit-llvm -ftrapv %s -o - | FileCheck %s -check-prefix=NOOPTION | ||
|
||
// TRAPFUNC-LABEL: define void @_Z12test_builtinv | ||
// TRAPFUNC: call void @llvm.trap() [[ATTR0:#[0-9]+]] | ||
|
||
// NOOPTION-LABEL: define void @_Z12test_builtinv | ||
// NOOPTION: call void @llvm.trap(){{$}} | ||
|
||
void test_builtin(void) { | ||
__builtin_trap(); | ||
} | ||
|
||
// TRAPFUNC-LABEL: define i32 @_Z13test_noreturnv | ||
// TRAPFUNC: call void @llvm.trap() [[ATTR0]] | ||
|
||
// NOOPTION-LABEL: define i32 @_Z13test_noreturnv | ||
// NOOPTION: call void @llvm.trap(){{$}} | ||
|
||
int test_noreturn(void) { | ||
} | ||
|
||
// TRAPFUNC-LABEL: define i32 @_Z17test_add_overflowii | ||
// TRAPFUNC: call void @llvm.trap() [[ATTR1:#[0-9]+]] | ||
|
||
// NOOPTION-LABEL: define i32 @_Z17test_add_overflowii | ||
// NOOPTION: call void @llvm.trap() [[ATTR2:#[0-9]+]] | ||
|
||
int test_add_overflow(int a, int b) { | ||
return a + b; | ||
} | ||
|
||
// TRAPFUNC: attributes [[ATTR0]] = { {{.*}}"trap-func-name"="mytrap" } | ||
// TRAPFUNC: attributes [[ATTR1]] = { {{.*}}"trap-func-name"="mytrap" } | ||
|
||
// NOOPTION-NOT: attributes [[ATTR2]] = { {{.*}}"trap-func-name"="mytrap" } |