https://github.com/kovdan01 updated 
https://github.com/llvm/llvm-project/pull/204226

>From ed37c72a50cbc61eaf083e30dde806a176549712 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev <[email protected]>
Date: Tue, 16 Jun 2026 21:43:12 +0300
Subject: [PATCH 1/4] [PAC][clang] Fix ptrauth module flags behavior

The `Error` merge behavior only has effect when module flags values
mismatch, while it allows the flag being present in one module and
absent in another one.

Always emit `ptrauth-elf-got` module flag for AArch64 targets and
`ptrauth-sign-personality` module flag for AArch64 Linux targets.
The value is either 0 or 1.
---
 clang/lib/CodeGen/CodeGenModule.cpp           | 12 +++++++-----
 clang/test/CodeGen/ptrauth-module-flags.c     | 12 ++++++++++--
 clang/test/CodeGen/ubsan-function-sugared.cpp |  2 +-
 clang/test/CodeGen/ubsan-function.cpp         |  2 +-
 clang/test/CodeGenCXX/pfp-memcpy.cpp          |  4 ++--
 5 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 41049d85121be..4d38fbdf20536 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1481,13 +1481,15 @@ void CodeGenModule::Release() {
       getModule().addModuleFlag(llvm::Module::Min,
                                 "sign-return-address-with-bkey", 2);
 
-    if (LangOpts.PointerAuthELFGOT)
-      getModule().addModuleFlag(llvm::Module::Error, "ptrauth-elf-got", 1);
+    getModule().addModuleFlag(
+        llvm::Module::Error, "ptrauth-elf-got",
+        static_cast<uint32_t>(LangOpts.PointerAuthELFGOT));
 
     if (getTriple().isOSLinux()) {
-      if (LangOpts.PointerAuthCalls)
-        getModule().addModuleFlag(llvm::Module::Error,
-                                  "ptrauth-sign-personality", 1);
+      getModule().addModuleFlag(
+          llvm::Module::Error, "ptrauth-sign-personality",
+          static_cast<uint32_t>(LangOpts.PointerAuthCalls));
+
       assert(getTriple().isOSBinFormatELF());
       using namespace llvm::ELF;
       uint64_t PAuthABIVersion =
diff --git a/clang/test/CodeGen/ptrauth-module-flags.c 
b/clang/test/CodeGen/ptrauth-module-flags.c
index 6c175c0aad781..ffe62ec25f655 100644
--- a/clang/test/CodeGen/ptrauth-module-flags.c
+++ b/clang/test/CodeGen/ptrauth-module-flags.c
@@ -4,10 +4,18 @@
 
 // ELFGOT:      !llvm.module.flags = !{
 // ELFGOT-SAME: !0
+// ELFGOT-SAME: !1
 // ELFGOT:      !0 = !{i32 1, !"ptrauth-elf-got", i32 1}
+// ELFGOT:      !1 = !{i32 1, !"ptrauth-sign-personality", i32 0}
 
 // PERSONALITY:      !llvm.module.flags = !{
 // PERSONALITY-SAME: !0
-// PERSONALITY:      !0 = !{i32 1, !"ptrauth-sign-personality", i32 1}
+// PERSONALITY-SAME: !1
+// PERSONALITY:      !0 = !{i32 1, !"ptrauth-elf-got", i32 0}
+// PERSONALITY:      !1 = !{i32 1, !"ptrauth-sign-personality", i32 1}
 
-// OFF-NOT: "ptrauth-
+// OFF:      !llvm.module.flags = !{
+// OFF-SAME: !0
+// OFF-SAME: !1
+// OFF:      !0 = !{i32 1, !"ptrauth-elf-got", i32 0}
+// OFF:      !1 = !{i32 1, !"ptrauth-sign-personality", i32 0}
diff --git a/clang/test/CodeGen/ubsan-function-sugared.cpp 
b/clang/test/CodeGen/ubsan-function-sugared.cpp
index 308edd8c0cd9b..2a6f8c81d7e0f 100644
--- a/clang/test/CodeGen/ubsan-function-sugared.cpp
+++ b/clang/test/CodeGen/ubsan-function-sugared.cpp
@@ -10,7 +10,7 @@ auto fun() {}
 
 // GNU-LABEL:  define{{.*}} void @_Z6callerv()
 // MSVC-LABEL: define{{.*}} void @"?caller@@YAXXZ"()
-// ARM:   call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize !5
+// ARM:   call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize
 // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 -1, i32 0, !nosanitize
 // CHECK: load i32, ptr {{.*}}, align {{.*}}, !nosanitize
 // CHECK: icmp eq i32 {{.*}}, -1056584962, !nosanitize
diff --git a/clang/test/CodeGen/ubsan-function.cpp 
b/clang/test/CodeGen/ubsan-function.cpp
index 817a9cbefe690..cf419fa5b4753 100644
--- a/clang/test/CodeGen/ubsan-function.cpp
+++ b/clang/test/CodeGen/ubsan-function.cpp
@@ -13,7 +13,7 @@ void fun() {}
 
 // GNU-LABEL:  define{{.*}} void @_Z6callerPFvvE(ptr noundef %f)
 // MSVC-LABEL: define{{.*}} void @"?caller@@YAXP6AXXZ@Z"(ptr noundef %f)
-// ARM:   call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize !6
+// ARM:   call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize
 // AUTH:  %[[STRIPPED:.*]] = ptrtoint ptr {{.*}} to i64, !nosanitize
 // AUTH:  call i64 @llvm.ptrauth.auth(i64 %[[STRIPPED]], i32 0, i64 0), 
!nosanitize
 // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 -1, i32 0, !nosanitize
diff --git a/clang/test/CodeGenCXX/pfp-memcpy.cpp 
b/clang/test/CodeGenCXX/pfp-memcpy.cpp
index be746fd8673a0..9621901c5c4c7 100644
--- a/clang/test/CodeGenCXX/pfp-memcpy.cpp
+++ b/clang/test/CodeGenCXX/pfp-memcpy.cpp
@@ -42,7 +42,7 @@ void trivial_copy(ClassWithTrivialCopy *s1) {
 // CHECK-NEXT: %a = getelementptr inbounds nuw %struct.ClassWithTrivialCopy, 
ptr %this1, i32 0, i32 0
 // CHECK-NEXT: %1 = ptrtoint ptr %this1 to i64
 // CHECK-NEXT: %2 = call ptr @llvm.protected.field.ptr.p0(ptr %a, i64 %1, i1 
true) [ "deactivation-symbol"(ptr @__pfp_ds__ZTS20ClassWithTrivialCopy.a) ]
-// CHECK-NEXT: %3 = load ptr, ptr %.addr, align 8, !nonnull !1, !align !2
+// CHECK-NEXT: %3 = load ptr, ptr %.addr, align 8, !nonnull ![[#]], !align 
![[#]]
 // CHECK-NEXT: %a2 = getelementptr inbounds nuw %struct.ClassWithTrivialCopy, 
ptr %3, i32 0, i32 0
 // CHECK-NEXT: %4 = ptrtoint ptr %3 to i64
 // CHECK-NEXT: %5 = call ptr @llvm.protected.field.ptr.p0(ptr %a2, i64 %4, i1 
true) [ "deactivation-symbol"(ptr @__pfp_ds__ZTS20ClassWithTrivialCopy.a) ]
@@ -51,7 +51,7 @@ void trivial_copy(ClassWithTrivialCopy *s1) {
 // CHECK-NEXT: %c = getelementptr inbounds nuw %struct.ClassWithTrivialCopy, 
ptr %this1, i32 0, i32 1
 // CHECK-NEXT: %7 = ptrtoint ptr %this1 to i64
 // CHECK-NEXT: %8 = call ptr @llvm.protected.field.ptr.p0(ptr %c, i64 %7, i1 
true) [ "deactivation-symbol"(ptr @__pfp_ds__ZTS20ClassWithTrivialCopy.c) ]
-// CHECK-NEXT: %9 = load ptr, ptr %.addr, align 8, !nonnull !1, !align !2
+// CHECK-NEXT: %9 = load ptr, ptr %.addr, align 8, !nonnull ![[#]], !align 
![[#]]
 // CHECK-NEXT: %c3 = getelementptr inbounds nuw %struct.ClassWithTrivialCopy, 
ptr %9, i32 0, i32 1
 // CHECK-NEXT: %10 = ptrtoint ptr %9 to i64
 // CHECK-NEXT: %11 = call ptr @llvm.protected.field.ptr.p0(ptr %c3, i64 %10, 
i1 true) [ "deactivation-symbol"(ptr @__pfp_ds__ZTS20ClassWithTrivialCopy.c) ]

>From ba1154796fb6e3374f06c4bc2d5c6c16810ce2bb Mon Sep 17 00:00:00 2001
From: Daniil Kovalev <[email protected]>
Date: Thu, 18 Jun 2026 20:07:32 +0300
Subject: [PATCH 2/4] Address review comments

---
 clang/lib/CodeGen/CodeGenModule.cpp | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 4d38fbdf20536..2942687bd37a0 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1480,7 +1480,8 @@ void CodeGenModule::Release() {
     if (!LangOpts.isSignReturnAddressWithAKey())
       getModule().addModuleFlag(llvm::Module::Min,
                                 "sign-return-address-with-bkey", 2);
-
+  }
+  if (T.isAArch64()) {
     getModule().addModuleFlag(
         llvm::Module::Error, "ptrauth-elf-got",
         static_cast<uint32_t>(LangOpts.PointerAuthELFGOT));
@@ -1520,14 +1521,12 @@ void CodeGenModule::Release() {
       static_assert(AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_FPTRTYPEDISCR ==
                         AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_LAST,
                     "Update when new enum items are defined");
-      if (PAuthABIVersion != 0) {
-        getModule().addModuleFlag(llvm::Module::Error,
-                                  "aarch64-elf-pauthabi-platform",
-                                  AARCH64_PAUTH_PLATFORM_LLVM_LINUX);
-        getModule().addModuleFlag(llvm::Module::Error,
-                                  "aarch64-elf-pauthabi-version",
-                                  PAuthABIVersion);
-      }
+
+      getModule().addModuleFlag(llvm::Module::Error,
+                                "aarch64-elf-pauthabi-platform",
+                                AARCH64_PAUTH_PLATFORM_LLVM_LINUX);
+      getModule().addModuleFlag(
+          llvm::Module::Error, "aarch64-elf-pauthabi-version", 
PAuthABIVersion);
     }
   }
   if ((T.isARM() || T.isThumb()) && getTriple().isTargetAEABI() &&

>From 2626bf63c82e310749948cc9354c2630cda53e8f Mon Sep 17 00:00:00 2001
From: Daniil Kovalev <[email protected]>
Date: Wed, 1 Jul 2026 15:31:45 +0300
Subject: [PATCH 3/4] Address review comments

---
 clang/lib/CodeGen/CodeGenModule.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 1e8ebc435c4c2..27d11d74d8c21 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1483,9 +1483,10 @@ void CodeGenModule::Release() {
                                 "sign-return-address-with-bkey", 2);
   }
   if (T.isAArch64()) {
-    getModule().addModuleFlag(
-        llvm::Module::Error, "ptrauth-elf-got",
-        static_cast<uint32_t>(LangOpts.PointerAuthELFGOT));
+    if (getTriple().isOSBinFormatELF())
+      getModule().addModuleFlag(
+          llvm::Module::Error, "ptrauth-elf-got",
+          static_cast<uint32_t>(LangOpts.PointerAuthELFGOT));
 
     if (getTriple().isOSLinux()) {
       getModule().addModuleFlag(

>From 309be5aad918002cfcfdbc677ceafb7341c52e5f Mon Sep 17 00:00:00 2001
From: Daniil Kovalev <[email protected]>
Date: Mon, 6 Jul 2026 17:09:06 +0300
Subject: [PATCH 4/4] Address review comments

---
 clang/lib/CodeGen/CodeGenModule.cpp           | 10 +++----
 clang/test/CodeGen/ubsan-function-sugared.cpp |  2 +-
 clang/test/CodeGen/ubsan-function.cpp         |  2 +-
 .../CodeGen/AArch64/arm64-tls-dynamics.ll     | 17 +++++++++++
 llvm/test/CodeGen/AArch64/basic-pic.ll        |  9 ++++++
 llvm/test/CodeGen/AArch64/elf-globals-pic.ll  | 11 ++++++++
 llvm/test/CodeGen/AArch64/extern-weak.ll      | 13 +++++++++
 llvm/test/CodeGen/AArch64/got-abuse.ll        | 10 +++++++
 .../ptrauth-elf-got-function-symbols.ll       | 28 +++++++++++++++++--
 .../CodeGen/AArch64/tagged-globals-pic.ll     | 12 ++++++++
 llvm/test/CodeGen/AArch64/tiny-model-pic.ll   | 12 ++++++++
 .../test/CodeGen/AArch64/tiny-model-static.ll | 13 +++++++++
 12 files changed, 128 insertions(+), 11 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 27d11d74d8c21..05554d2815a55 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1484,14 +1484,12 @@ void CodeGenModule::Release() {
   }
   if (T.isAArch64()) {
     if (getTriple().isOSBinFormatELF())
-      getModule().addModuleFlag(
-          llvm::Module::Error, "ptrauth-elf-got",
-          static_cast<uint32_t>(LangOpts.PointerAuthELFGOT));
+      getModule().addModuleFlag(llvm::Module::Error, "ptrauth-elf-got",
+                                LangOpts.PointerAuthELFGOT);
 
     if (getTriple().isOSLinux()) {
-      getModule().addModuleFlag(
-          llvm::Module::Error, "ptrauth-sign-personality",
-          static_cast<uint32_t>(LangOpts.PointerAuthCalls));
+      getModule().addModuleFlag(llvm::Module::Error, 
"ptrauth-sign-personality",
+                                LangOpts.PointerAuthCalls);
 
       assert(getTriple().isOSBinFormatELF());
       using namespace llvm::ELF;
diff --git a/clang/test/CodeGen/ubsan-function-sugared.cpp 
b/clang/test/CodeGen/ubsan-function-sugared.cpp
index 2a6f8c81d7e0f..308edd8c0cd9b 100644
--- a/clang/test/CodeGen/ubsan-function-sugared.cpp
+++ b/clang/test/CodeGen/ubsan-function-sugared.cpp
@@ -10,7 +10,7 @@ auto fun() {}
 
 // GNU-LABEL:  define{{.*}} void @_Z6callerv()
 // MSVC-LABEL: define{{.*}} void @"?caller@@YAXXZ"()
-// ARM:   call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize
+// ARM:   call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize !5
 // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 -1, i32 0, !nosanitize
 // CHECK: load i32, ptr {{.*}}, align {{.*}}, !nosanitize
 // CHECK: icmp eq i32 {{.*}}, -1056584962, !nosanitize
diff --git a/clang/test/CodeGen/ubsan-function.cpp 
b/clang/test/CodeGen/ubsan-function.cpp
index cf419fa5b4753..817a9cbefe690 100644
--- a/clang/test/CodeGen/ubsan-function.cpp
+++ b/clang/test/CodeGen/ubsan-function.cpp
@@ -13,7 +13,7 @@ void fun() {}
 
 // GNU-LABEL:  define{{.*}} void @_Z6callerPFvvE(ptr noundef %f)
 // MSVC-LABEL: define{{.*}} void @"?caller@@YAXP6AXXZ@Z"(ptr noundef %f)
-// ARM:   call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize
+// ARM:   call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize !6
 // AUTH:  %[[STRIPPED:.*]] = ptrtoint ptr {{.*}} to i64, !nosanitize
 // AUTH:  call i64 @llvm.ptrauth.auth(i64 %[[STRIPPED]], i32 0, i64 0), 
!nosanitize
 // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 -1, i32 0, !nosanitize
diff --git a/llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll 
b/llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll
index c12730bd3b0d7..81051d94cda70 100644
--- a/llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll
@@ -1,18 +1,30 @@
 ; Verify the call site info. If the call site info is not
 ; in the valid state, an assert should be triggered.
+
+; RUN: rm -rf %t && split-file %s %t && cd %t
+
 ; RUN: llc < %s -debug-entry-values -mtriple=arm64-none-linux-gnu 
-stop-after=machineverifier -relocation-model=pic 
-aarch64-elf-ldtls-generation=1 < %s
+; RUN: llc < src.ll -debug-entry-values -mtriple=arm64-none-linux-gnu 
-stop-after=machineverifier -relocation-model=pic 
-aarch64-elf-ldtls-generation=1 < %s
 
 ; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic 
-aarch64-elf-ldtls-generation=1 -verify-machineinstrs < %s | FileCheck %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic 
-aarch64-elf-ldtls-generation=1 -verify-machineinstrs < src.ll | FileCheck %s
 ; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic 
-aarch64-elf-ldtls-generation=1 -filetype=obj < %s | llvm-objdump -r - | 
FileCheck --check-prefix=CHECK-RELOC %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic 
-aarch64-elf-ldtls-generation=1 -filetype=obj < src.ll | llvm-objdump -r - | 
FileCheck --check-prefix=CHECK-RELOC %s
 ; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic 
-verify-machineinstrs < %s | FileCheck --check-prefix=CHECK-NOLD %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic 
-verify-machineinstrs < src.ll | FileCheck --check-prefix=CHECK-NOLD %s
 ; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic -filetype=obj < 
%s | llvm-objdump -r - | FileCheck --check-prefix=CHECK-NOLD-RELOC %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic -filetype=obj < 
src.ll | llvm-objdump -r - | FileCheck --check-prefix=CHECK-NOLD-RELOC %s
 ; FIXME: We currently produce "small" code for the tiny model
 ; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic 
-aarch64-elf-ldtls-generation=1 -code-model=tiny -verify-machineinstrs < %s | 
FileCheck %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic 
-aarch64-elf-ldtls-generation=1 -code-model=tiny -verify-machineinstrs < src.ll 
| FileCheck %s
 ; FIXME: We currently error for the large code model
 ; RUN: not --crash llc -mtriple=arm64-none-linux-gnu -relocation-model=pic 
-aarch64-elf-ldtls-generation=1 -code-model=large -verify-machineinstrs < %s 
2>&1 | FileCheck %s --check-prefix=CHECK-LARGE
+; RUN: not --crash llc -mtriple=arm64-none-linux-gnu -relocation-model=pic 
-aarch64-elf-ldtls-generation=1 -code-model=large -verify-machineinstrs < 
src.ll 2>&1 | FileCheck %s --check-prefix=CHECK-LARGE
 
 ; CHECK-LARGE: ELF TLS only supported in small memory model
 
+;--- src.ll
+
 @general_dynamic_var = external thread_local global i32
 
 define i32 @test_generaldynamic() {
@@ -177,3 +189,8 @@ define i32 @test_localdynamic_deduplicate() {
 
 ; CHECK: ret
 }
+
+;--- elf-got-flag.ll
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 8, !"ptrauth-elf-got", i32 0}
diff --git a/llvm/test/CodeGen/AArch64/basic-pic.ll 
b/llvm/test/CodeGen/AArch64/basic-pic.ll
index 8ef48d5a9c8ad..c94d3ee386fae 100644
--- a/llvm/test/CodeGen/AArch64/basic-pic.ll
+++ b/llvm/test/CodeGen/AArch64/basic-pic.ll
@@ -1,4 +1,8 @@
+; RUN: rm -rf %t && split-file %s %t && cd %t
 ; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs 
-relocation-model=pic %s -o - | FileCheck %s
+; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs 
-relocation-model=pic src.ll -o - | FileCheck %s
+
+;--- src.ll
 
 @var = global i32 0
 
@@ -20,3 +24,8 @@ define ptr @get_globalvaraddr() {
   %val = load i32, ptr @var
   ret ptr @var
 }
+
+;--- elf-got-flag.ll
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 8, !"ptrauth-elf-got", i32 0}
diff --git a/llvm/test/CodeGen/AArch64/elf-globals-pic.ll 
b/llvm/test/CodeGen/AArch64/elf-globals-pic.ll
index d0df0bbea07c2..8fe84b70c2005 100644
--- a/llvm/test/CodeGen/AArch64/elf-globals-pic.ll
+++ b/llvm/test/CodeGen/AArch64/elf-globals-pic.ll
@@ -1,5 +1,11 @@
+; RUN: rm -rf %t && split-file %s %t && cd %t
+
 ; RUN: llc -mtriple=arm64                -relocation-model=pic -o - %s 
-mcpu=cyclone | FileCheck %s --check-prefix=CHECK
+; RUN: llc -mtriple=arm64                -relocation-model=pic -o - src.ll 
-mcpu=cyclone | FileCheck %s --check-prefix=CHECK
 ; RUN: llc -mtriple=arm64 -O0 -fast-isel -relocation-model=pic -o - %s 
-mcpu=cyclone | FileCheck %s --check-prefix=CHECK-FAST
+; RUN: llc -mtriple=arm64 -O0 -fast-isel -relocation-model=pic -o - src.ll 
-mcpu=cyclone | FileCheck %s --check-prefix=CHECK-FAST
+
+;--- src.ll
 
 @var8 = external global i8, align 1
 @var16 = external global i16, align 2
@@ -68,3 +74,8 @@ define i64 @test_default_unaligned() {
   %val = load i64, ptr @var_default
   ret i64 %val
 }
+
+;--- elf-got-flag.ll
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 8, !"ptrauth-elf-got", i32 0}
diff --git a/llvm/test/CodeGen/AArch64/extern-weak.ll 
b/llvm/test/CodeGen/AArch64/extern-weak.ll
index b0e675c084848..19d5f1e18ce41 100644
--- a/llvm/test/CodeGen/AArch64/extern-weak.ll
+++ b/llvm/test/CodeGen/AArch64/extern-weak.ll
@@ -1,7 +1,15 @@
+; RUN: rm -rf %t && split-file %s %t && cd %t
+
 ; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -o - %s | 
FileCheck %s
+; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -o - src.ll | 
FileCheck %s
 ; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=static -o - < %s 
| FileCheck %s
+; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=static -o - < 
src.ll | FileCheck %s
 ; RUN: llc -mtriple=aarch64-none-linux-gnu -code-model=large -o - %s | 
FileCheck --check-prefix=CHECK-LARGE %s
+; RUN: llc -mtriple=aarch64-none-linux-gnu -code-model=large -o - src.ll | 
FileCheck --check-prefix=CHECK-LARGE %s
 ; RUN: llc -mtriple=aarch64-none-elf -code-model=tiny -o - %s | FileCheck 
--check-prefix=CHECK-TINY %s
+; RUN: llc -mtriple=aarch64-none-elf -code-model=tiny -o - src.ll | FileCheck 
--check-prefix=CHECK-TINY %s
+
+;--- src.ll
 
 declare extern_weak dso_local i32 @var()
 
@@ -61,3 +69,8 @@ define ptr @wibble() {
 
 ; CHECK-TINY:       adr x0, defined_weak_var
 }
+
+;--- elf-got-flag.ll
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 8, !"ptrauth-elf-got", i32 0}
diff --git a/llvm/test/CodeGen/AArch64/got-abuse.ll 
b/llvm/test/CodeGen/AArch64/got-abuse.ll
index 0b682d95db21a..13ebe9c512683 100644
--- a/llvm/test/CodeGen/AArch64/got-abuse.ll
+++ b/llvm/test/CodeGen/AArch64/got-abuse.ll
@@ -1,5 +1,9 @@
+; RUN: rm -rf %t && split-file %s %t && cd %t
+
 ; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -o - %s | 
FileCheck %s
+; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -o - src.ll | 
FileCheck %s
 ; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -filetype=obj 
-o - %s
+; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -filetype=obj 
-o - src.ll
 
 ; LLVM gives well-defined semantics to this horrible construct (though C says
 ; it's undefined). Regardless, we shouldn't crash. The important feature here 
is
@@ -9,6 +13,8 @@
 ;    + ldr wD, [xN, #:got_lo12:func]
 ;    + add xD, xN, #:got_lo12:func
 
+;--- src.ll
+
 declare void @consume(i32)
 declare void @func()
 
@@ -21,3 +27,7 @@ entry:
   ret void
 }
 
+;--- elf-got-flag.ll
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 8, !"ptrauth-elf-got", i32 0}
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-elf-got-function-symbols.ll 
b/llvm/test/CodeGen/AArch64/ptrauth-elf-got-function-symbols.ll
index e75acceaa0d12..bc74781693879 100644
--- a/llvm/test/CodeGen/AArch64/ptrauth-elf-got-function-symbols.ll
+++ b/llvm/test/CodeGen/AArch64/ptrauth-elf-got-function-symbols.ll
@@ -1,8 +1,18 @@
-; RUN: llc -mtriple aarch64-linux-pauthtest -mattr +pauth -filetype=asm %s -o 
- | \
+; RUN: rm -rf %t && split-file %s %t && cd %t
+; RUN: cat common.ll elf-got-flag-1.ll > auth.ll
+; RUN: cat common.ll elf-got-flag-0.ll > noauth1.ll
+; RUN: cat common.ll                   > noauth2.ll
+
+; RUN: llc -mtriple aarch64-linux-pauthtest -mattr +pauth -filetype=asm 
auth.ll -o - | \
 ; RUN:   FileCheck %s --check-prefix=ASM
-; RUN: llc -mtriple aarch64-linux-pauthtest -mattr +pauth -filetype=obj %s -o 
- | \
+; RUN: llc -mtriple aarch64-linux-pauthtest -mattr +pauth -filetype=obj 
auth.ll -o - | \
 ; RUN:   llvm-readelf -s - | FileCheck %s --check-prefix=OBJ
 
+; RUN: llc -mtriple aarch64-linux-gnu -mattr +pauth -filetype=obj noauth1.ll 
-o - | \
+; RUN:   llvm-readelf -s - | FileCheck %s --check-prefix=OBJ-NOAUTH
+; RUN: llc -mtriple aarch64-linux-gnu -mattr +pauth -filetype=obj noauth2.ll 
-o - | \
+; RUN:   llvm-readelf -s - | FileCheck %s --check-prefix=OBJ-NOAUTH
+
 ; ASM:               .type   foo,@function
 ; ASM-LABEL: foo:
 ; ASM:               adrp    x17, :got_auth:bar
@@ -28,6 +38,12 @@
 ; OBJ-NEXT:    Num:    Value          Size Type    Bind   Vis       Ndx Name
 ; OBJ:              0000000000000000     0 FUNC    GLOBAL DEFAULT   UND bar
 
+; OBJ-NOAUTH:      Symbol table '.symtab' contains [[#]] entries:
+; OBJ-NOAUTH-NEXT:    Num:    Value          Size Type    Bind   Vis       Ndx 
Name
+; OBJ-NOAUTH:              0000000000000000     0 NOTYPE  GLOBAL DEFAULT   UND 
bar
+
+;--- common.ll
+
 @fptr = private global ptr null
 
 define void @foo() {
@@ -37,6 +53,12 @@ define void @foo() {
 
 declare i32 @bar()
 
-!llvm.module.flags = !{!0}
+;--- elf-got-flag-1.ll
 
+!llvm.module.flags = !{!0}
 !0 = !{i32 8, !"ptrauth-elf-got", i32 1}
+
+;--- elf-got-flag-0.ll
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 8, !"ptrauth-elf-got", i32 0}
diff --git a/llvm/test/CodeGen/AArch64/tagged-globals-pic.ll 
b/llvm/test/CodeGen/AArch64/tagged-globals-pic.ll
index 3e3619834fbbc..a2617582c5300 100644
--- a/llvm/test/CodeGen/AArch64/tagged-globals-pic.ll
+++ b/llvm/test/CodeGen/AArch64/tagged-globals-pic.ll
@@ -1,4 +1,7 @@
+; RUN: rm -rf %t && split-file %s %t && cd %t
+
 ; RUN: llc --relocation-model=pic < %s | FileCheck %s
+; RUN: llc --relocation-model=pic < src.ll | FileCheck %s
 
 ; Ensure that GlobalISel lowers correctly. GlobalISel is the default ISel for
 ; -O0 on aarch64. GlobalISel lowers the instruction sequence in the static
@@ -13,6 +16,10 @@
 
 ; RUN: llc --aarch64-enable-global-isel-at-O=0 -O0 --relocation-model=pic < %s 
\
 ; RUN:   | FileCheck %s
+; RUN: llc --aarch64-enable-global-isel-at-O=0 -O0 --relocation-model=pic < \
+; RUN:   src.ll | FileCheck %s
+
+;--- src.ll
 
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 target triple = "aarch64-unknown-linux-android"
@@ -61,3 +68,8 @@ define ptr @func_addr() #0 {
 }
 
 attributes #0 = { "target-features"="+tagged-globals" }
+
+;--- elf-got-flag.ll
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 8, !"ptrauth-elf-got", i32 0}
diff --git a/llvm/test/CodeGen/AArch64/tiny-model-pic.ll 
b/llvm/test/CodeGen/AArch64/tiny-model-pic.ll
index 3868303a9fb70..28f7591f113d1 100644
--- a/llvm/test/CodeGen/AArch64/tiny-model-pic.ll
+++ b/llvm/test/CodeGen/AArch64/tiny-model-pic.ll
@@ -1,10 +1,18 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+
+; RUN: rm -rf %t && split-file %s %t && cd %t
+
 ; RUN: llc -verify-machineinstrs -mtriple=aarch64 -code-model=tiny 
-relocation-model=pic < %s | FileCheck %s --check-prefix=CHECK-PIC
+; RUN: llc -verify-machineinstrs -mtriple=aarch64 -code-model=tiny 
-relocation-model=pic < src.ll | FileCheck %s --check-prefix=CHECK-PIC
 ; RUN: llc -verify-machineinstrs -mtriple=aarch64 -code-model=tiny 
-relocation-model=pic -fast-isel < %s | FileCheck %s --check-prefix=CHECK-PIC
+; RUN: llc -verify-machineinstrs -mtriple=aarch64 -code-model=tiny 
-relocation-model=pic -fast-isel < src.ll | FileCheck %s 
--check-prefix=CHECK-PIC
 ; RUN: llc -verify-machineinstrs -mtriple=aarch64 -code-model=tiny 
-relocation-model=pic -global-isel < %s | FileCheck %s 
--check-prefix=CHECK-PIC-GLOBISEL
+; RUN: llc -verify-machineinstrs -mtriple=aarch64 -code-model=tiny 
-relocation-model=pic -global-isel < src.ll | FileCheck %s 
--check-prefix=CHECK-PIC-GLOBISEL
 
 ; Note fast-isel tests here will fall back to isel
 
+;--- src.ll
+
 @src = external local_unnamed_addr global [65536 x i8], align 1
 @dst = external global [65536 x i8], align 1
 @ptr = external local_unnamed_addr global ptr, align 8
@@ -250,3 +258,7 @@ entry:
       ret ptr @externfuncaddr
 }
 
+;--- elf-got-flag.ll
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 8, !"ptrauth-elf-got", i32 0}
diff --git a/llvm/test/CodeGen/AArch64/tiny-model-static.ll 
b/llvm/test/CodeGen/AArch64/tiny-model-static.ll
index 311ea9a31ab6a..2987da70aa7fe 100644
--- a/llvm/test/CodeGen/AArch64/tiny-model-static.ll
+++ b/llvm/test/CodeGen/AArch64/tiny-model-static.ll
@@ -1,7 +1,15 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+
+; RUN: rm -rf %t && split-file %s %t && cd %t
+
 ; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu 
-code-model=tiny < %s | FileCheck %s --check-prefix=CHECK --check-prefix=SDISEL
+; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu 
-code-model=tiny < src.ll | FileCheck %s --check-prefix=CHECK 
--check-prefix=SDISEL
 ; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu 
-code-model=tiny -fast-isel < %s | FileCheck %s --check-prefix=CHECK 
--check-prefix=FAST
+; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu 
-code-model=tiny -fast-isel < src.ll | FileCheck %s --check-prefix=CHECK 
--check-prefix=FAST
 ; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu 
-code-model=tiny -global-isel < %s | FileCheck %s --check-prefix=CHECK-GLOBISEL
+; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu 
-code-model=tiny -global-isel < src.ll | FileCheck %s 
--check-prefix=CHECK-GLOBISEL
+
+;--- src.ll
 
 ; Note fast-isel tests here will fall back to isel
 
@@ -326,3 +334,8 @@ define dso_local void @stackprot(ptr %callee) sspstrong {
   call void %callee(ptr %arr)
   ret void
 }
+
+;--- elf-got-flag.ll
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 8, !"ptrauth-elf-got", i32 0}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to