[amdgpu-cfi: 3/9]: [Clang] Default to async unwind tables for amdgcn - #183148
Conversation
169ca3f to
b0a436f
Compare
5168131 to
5791b4a
Compare
b0a436f to
e4505cb
Compare
5791b4a to
2f91d13
Compare
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
|
@llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-clang Author: Scott Linder (slinder1) ChangesTo avoid codegen changes when enabling debug-info (see There is some pessimization in post-prologepilog scheduling, and a Change-Id: I83625875966928c7c4411cd7b95174dc58bda25a Stack:
<sub>(Note: Closed and merged PRs may not be reflected here and PR numbering is not stable.)</sub> Full diff: https://github.com/llvm/llvm-project/pull/183148.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index d8d537ec14b89..80e32eb63a21e 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -3066,6 +3066,7 @@ Generic_GCC::getDefaultUnwindTableLevel(const ArgList &Args) const {
switch (getArch()) {
case llvm::Triple::aarch64:
case llvm::Triple::aarch64_be:
+ case llvm::Triple::amdgcn:
case llvm::Triple::ppc:
case llvm::Triple::ppcle:
case llvm::Triple::ppc64:
diff --git a/clang/test/Driver/amdgpu-unwind.cl b/clang/test/Driver/amdgpu-unwind.cl
new file mode 100644
index 0000000000000..5a18b24126714
--- /dev/null
+++ b/clang/test/Driver/amdgpu-unwind.cl
@@ -0,0 +1,26 @@
+// REQUIRES: amdgpu-registered-target
+
+// Default options
+// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+
+// Explicitly enable sync-tables (somewhat surprisingly this is still preempted by the default-on async tables)
+// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib -funwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+
+// Explicitly enable sync-tables and surpress default async-tables
+// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib -funwind-tables -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=SYNC-TABLES %s
+// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=SYNC-TABLES %s
+// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=SYNC-TABLES %s
+
+// Suppress the default async-tables
+// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=NO-TABLES %s
+// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=NO-TABLES %s
+// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=NO-TABLES %s
+
+
+// ASYNC-TABLES: "-triple" "amdgcn-amd-amdhsa" {{.*}} "-funwind-tables=2"
+// SYNC-TABLES: "-triple" "amdgcn-amd-amdhsa" {{.*}} "-funwind-tables=1"
+// NO-TABLES-NOT: "-triple" "amdgcn-amd-amdhsa" {{.*}} "-funwind-tables={{.*}}"
|
|
@llvm/pr-subscribers-clang-driver Author: Scott Linder (slinder1) ChangesTo avoid codegen changes when enabling debug-info (see There is some pessimization in post-prologepilog scheduling, and a Change-Id: I83625875966928c7c4411cd7b95174dc58bda25a Stack:
<sub>(Note: Closed and merged PRs may not be reflected here and PR numbering is not stable.)</sub> Full diff: https://github.com/llvm/llvm-project/pull/183148.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index d8d537ec14b89..80e32eb63a21e 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -3066,6 +3066,7 @@ Generic_GCC::getDefaultUnwindTableLevel(const ArgList &Args) const {
switch (getArch()) {
case llvm::Triple::aarch64:
case llvm::Triple::aarch64_be:
+ case llvm::Triple::amdgcn:
case llvm::Triple::ppc:
case llvm::Triple::ppcle:
case llvm::Triple::ppc64:
diff --git a/clang/test/Driver/amdgpu-unwind.cl b/clang/test/Driver/amdgpu-unwind.cl
new file mode 100644
index 0000000000000..5a18b24126714
--- /dev/null
+++ b/clang/test/Driver/amdgpu-unwind.cl
@@ -0,0 +1,26 @@
+// REQUIRES: amdgpu-registered-target
+
+// Default options
+// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+
+// Explicitly enable sync-tables (somewhat surprisingly this is still preempted by the default-on async tables)
+// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib -funwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=ASYNC-TABLES %s
+
+// Explicitly enable sync-tables and surpress default async-tables
+// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib -funwind-tables -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=SYNC-TABLES %s
+// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=SYNC-TABLES %s
+// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -funwind-tables -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=SYNC-TABLES %s
+
+// Suppress the default async-tables
+// RUN: %clang -### -x cl -target amdgcn-amd-amdhsa -c -emit-llvm --no-offloadlib -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=NO-TABLES %s
+// RUN: %clang -### -x hip --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=NO-TABLES %s
+// RUN: %clang -### -fopenmp --offload-arch=gfx90a --offload-device-only --no-offloadlib -c -emit-llvm -fno-asynchronous-unwind-tables -nogpuinc %s 2>&1 | FileCheck -check-prefix=NO-TABLES %s
+
+
+// ASYNC-TABLES: "-triple" "amdgcn-amd-amdhsa" {{.*}} "-funwind-tables=2"
+// SYNC-TABLES: "-triple" "amdgcn-amd-amdhsa" {{.*}} "-funwind-tables=1"
+// NO-TABLES-NOT: "-triple" "amdgcn-amd-amdhsa" {{.*}} "-funwind-tables={{.*}}"
|
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. Change-Id: I83625875966928c7c4411cd7b95174dc58bda25a
5545665 to
fe270cf
Compare
|
🛠️ Changes since last push: none (likely a rebase) |
|
🛠️ Changes since last push: none (likely a rebase) |
8 similar comments
|
🛠️ Changes since last push: none (likely a rebase) |
|
🛠️ Changes since last push: none (likely a rebase) |
|
🛠️ Changes since last push: none (likely a rebase) |
|
🛠️ Changes since last push: none (likely a rebase) |
|
🛠️ Changes since last push: none (likely a rebase) |
|
🛠️ Changes since last push: none (likely a rebase) |
|
🛠️ Changes since last push: none (likely a rebase) |
|
🛠️ Changes since last push: none (likely a rebase) |
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.
Change-Id: I83625875966928c7c4411cd7b95174dc58bda25a
Stack:
main(Note: Closed and merged PRs may not be reflected here and PR numbering is not stable.)