Skip to content

Commit 61647b0

Browse files
committed
[Clang] Default to async unwind tables for amdgcn
To avoid codegen changes when enabling debug-info (see https://bugs.llvm.org/show_bug.cgi?id=37240) we want to enable unwind tables by default. There is some pessimization in post-prologepilog scheduling, and a general solution to the problem of CFI_INSTRUCTION-as-scheduling-barrier should be explored.
1 parent 638fa37 commit 61647b0

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,7 @@ Generic_GCC::getDefaultUnwindTableLevel(const ArgList &Args) const {
30323032
switch (getArch()) {
30333033
case llvm::Triple::aarch64:
30343034
case llvm::Triple::aarch64_be:
3035+
case llvm::Triple::amdgcn:
30353036
case llvm::Triple::ppc:
30363037
case llvm::Triple::ppcle:
30373038
case llvm::Triple::ppc64:

clang/test/Driver/amdgpu-unwind.cl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// REQUIRES: amdgpu-registered-target
2+
3+
// Default options
4+
// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
5+
// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
6+
// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
7+
8+
// Explicitly enable sync-tables (somewhat surprisingly this is still preempted by the default-on async tables)
9+
// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib -funwind-tables %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
10+
// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
11+
// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
12+
13+
// Explicitly enable sync-tables and surpress default async-tables
14+
// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib -funwind-tables -fno-asynchronous-unwind-tables %s 2>&1 | FileCheck -check-prefix=SYNC-TABLES %s
15+
// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables -fno-asynchronous-unwind-tables %s 2>&1 | FileCheck -check-prefix=SYNC-TABLES %s
16+
// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables -fno-asynchronous-unwind-tables %s 2>&1 | FileCheck -check-prefix=SYNC-TABLES %s
17+
18+
// Suppress the default async-tables
19+
// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib -fno-asynchronous-unwind-tables %s 2>&1 | FileCheck -check-prefix=NO-TABLES %s
20+
// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -fno-asynchronous-unwind-tables %s 2>&1 | FileCheck -check-prefix=NO-TABLES %s
21+
// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -fno-asynchronous-unwind-tables %s 2>&1 | FileCheck -check-prefix=NO-TABLES %s
22+
23+
24+
// ASYNC-TABLES: "-triple" "amdgcn-amd-amdhsa" {{.*}} "-funwind-tables=2"
25+
// SYNC-TABLES: "-triple" "amdgcn-amd-amdhsa" {{.*}} "-funwind-tables=1"
26+
// NO-TABLES-NOT: "-triple" "amdgcn-amd-amdhsa" {{.*}} "-funwind-tables={{.*}}"

0 commit comments

Comments
 (0)