Skip to content

[amdgpu-cfi: 3/9]: [Clang] Default to async unwind tables for amdgcn - #183148

Merged
slinder1 merged 3 commits into
mainfrom
users/slinder1/I83625875966928c7c4411cd7b95174dc58bda25a
May 19, 2026
Merged

slinder1 merged 3 commits into
mainfrom
users/slinder1/I83625875966928c7c4411cd7b95174dc58bda25a

Conversation

@slinder1

@slinder1 slinder1 commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

@slinder1
slinder1 changed the base branch from main to users/slinder1/I763d0cabe5990394670281d4afb5a170981e55d0 February 24, 2026 19:57
@slinder1 slinder1 changed the title [Clang] Default to async unwind tables for amdgcn [2/8]: [Clang] Default to async unwind tables for amdgcn Feb 24, 2026
@slinder1
slinder1 force-pushed the users/slinder1/I763d0cabe5990394670281d4afb5a170981e55d0 branch from 169ca3f to b0a436f Compare February 24, 2026 21:41
@slinder1
slinder1 force-pushed the users/slinder1/I83625875966928c7c4411cd7b95174dc58bda25a branch from 5168131 to 5791b4a Compare February 24, 2026 21:41
@slinder1 slinder1 changed the title [2/8]: [Clang] Default to async unwind tables for amdgcn [3/9]: [Clang] Default to async unwind tables for amdgcn Feb 24, 2026
@slinder1
slinder1 force-pushed the users/slinder1/I763d0cabe5990394670281d4afb5a170981e55d0 branch from b0a436f to e4505cb Compare February 25, 2026 20:58
@slinder1
slinder1 force-pushed the users/slinder1/I83625875966928c7c4411cd7b95174dc58bda25a branch from 5791b4a to 2f91d13 Compare February 25, 2026 20:58
@slinder1 slinder1 changed the title [3/9]: [Clang] Default to async unwind tables for amdgcn [amdgpu-cfi: 3/9]: [Clang] Default to async unwind tables for amdgcn Feb 25, 2026
@github-actions

github-actions Bot commented Feb 25, 2026

Copy link
Copy Markdown

🐧 Linux x64 Test Results

  • 117991 tests passed
  • 4729 tests skipped

✅ The build succeeded and all tests passed.

@slinder1
slinder1 marked this pull request as ready for review February 26, 2026 21:22
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:AMDGPU clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Feb 26, 2026
@llvmbot

llvmbot commented Feb 26, 2026

Copy link
Copy Markdown
Member

@llvm/pr-subscribers-backend-amdgpu

@llvm/pr-subscribers-clang

Author: Scott Linder (slinder1)

Changes

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:

  • #183147
  • #183149
  • #183150
  • #183146
  • #183153
  • #183152
  • #183148⬅
  • #183151
  • #183171
  • main

<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:

  • (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+1)
  • (added) clang/test/Driver/amdgpu-unwind.cl (+26)
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={{.*}}"

@llvmbot

llvmbot commented Feb 26, 2026

Copy link
Copy Markdown
Member

@llvm/pr-subscribers-clang-driver

Author: Scott Linder (slinder1)

Changes

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:

  • #183147
  • #183149
  • #183150
  • #183146
  • #183153
  • #183152
  • #183148⬅
  • #183151
  • #183171
  • main

<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:

  • (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+1)
  • (added) clang/test/Driver/amdgpu-unwind.cl (+26)
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
@slinder1
slinder1 force-pushed the users/slinder1/I83625875966928c7c4411cd7b95174dc58bda25a branch from 5545665 to fe270cf Compare May 19, 2026 17:42
@slinder1

Copy link
Copy Markdown
Contributor Author

🛠️ Changes since last push: none (likely a rebase)

@slinder1
slinder1 merged commit 3b51279 into main May 19, 2026
13 of 17 checks passed
@slinder1
slinder1 deleted the users/slinder1/I83625875966928c7c4411cd7b95174dc58bda25a branch May 19, 2026 18:50
@slinder1

Copy link
Copy Markdown
Contributor Author

🛠️ Changes since last push: none (likely a rebase)

8 similar comments
@slinder1

Copy link
Copy Markdown
Contributor Author

🛠️ Changes since last push: none (likely a rebase)

@slinder1

Copy link
Copy Markdown
Contributor Author

🛠️ Changes since last push: none (likely a rebase)

@slinder1

Copy link
Copy Markdown
Contributor Author

🛠️ Changes since last push: none (likely a rebase)

@slinder1

Copy link
Copy Markdown
Contributor Author

🛠️ Changes since last push: none (likely a rebase)

@slinder1

Copy link
Copy Markdown
Contributor Author

🛠️ Changes since last push: none (likely a rebase)

@slinder1

Copy link
Copy Markdown
Contributor Author

🛠️ Changes since last push: none (likely a rebase)

@slinder1

Copy link
Copy Markdown
Contributor Author

🛠️ Changes since last push: none (likely a rebase)

@slinder1

Copy link
Copy Markdown
Contributor Author

🛠️ Changes since last push: none (likely a rebase)

qundao-sync Bot pushed a commit to qundao/mirror-zig that referenced this pull request Aug 4, 2026
chengfeng-xie pushed a commit to chengfeng-xie/zig that referenced this pull request Aug 5, 2026
qundao-sync Bot pushed a commit to qundao/mirror-zig that referenced this pull request Aug 9, 2026
chengfeng-xie pushed a commit to chengfeng-xie/zig that referenced this pull request Aug 10, 2026
chengfeng-xie pushed a commit to chengfeng-xie/zig that referenced this pull request Aug 13, 2026
qundao-sync Bot pushed a commit to qundao/mirror-zig that referenced this pull request Aug 13, 2026
chengfeng-xie pushed a commit to chengfeng-xie/zig that referenced this pull request Aug 14, 2026
qundao-sync Bot pushed a commit to qundao/mirror-zig that referenced this pull request Aug 16, 2026
qundao-sync Bot pushed a commit to qundao/mirror-zig that referenced this pull request Aug 17, 2026
qundao-sync Bot pushed a commit to qundao/mirror-zig that referenced this pull request Aug 20, 2026
qundao-sync Bot pushed a commit to qundao/mirror-zig that referenced this pull request Aug 23, 2026
qundao-sync Bot pushed a commit to qundao/mirror-zig that referenced this pull request Aug 26, 2026
qundao-sync Bot pushed a commit to qundao/mirror-zig that referenced this pull request Aug 31, 2026
qundao-sync Bot pushed a commit to qundao/mirror-zig that referenced this pull request Sep 5, 2026
chengfeng-xie pushed a commit to chengfeng-xie/zig that referenced this pull request Sep 7, 2026
qundao-sync Bot pushed a commit to qundao/mirror-zig that referenced this pull request Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:AMDGPU clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants