https://github.com/fzou1 updated 
https://github.com/llvm/llvm-project/pull/239937

>From 8199ef3372db97a7e05c74d57682b08e9cd8e271 Mon Sep 17 00:00:00 2001
From: "Zou, Feng" <[email protected]>
Date: Mon, 26 Oct 2026 04:20:17 +0530
Subject: [PATCH 1/3] [clang][X86] Use a sized byval type for an incomplete
 interrupt frame

x86_intrcc requires parameter 0 to be byval, and addX86InterruptAttrs
uses the frame's type as the byval type. When that type is incomplete,
as in GCC's documentation ("struct interrupt_frame;"), or a function
type, it is unsized, so the module fails verification ("Attribute
'byval' does not support unsized types") or, without the verifier,
instruction selection asserts when computing the type's size.

The backend places the frame at a fixed offset and uses the byval type
only to size its fixed stack object, so fall back to i8, the type
already used for "void *". Frame types that are complete when the
handler is emitted are unaffected; one completed only later in the
file, which used to keep its struct type, now also gets i8.

Assisted-by: Claude Opus 5.5 <[email protected]>
---
 clang/lib/CodeGen/Targets/X86.cpp             |  5 +++
 .../attr-x86-interrupt-incomplete-frame.c     | 45 +++++++++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index 5324c8d366b829..fc49756374fd80 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -1234,6 +1234,11 @@ static void addX86InterruptAttrs(const FunctionDecl *FD, 
llvm::GlobalValue *GV,
 
   const auto *PtrTy = FD->getParamDecl(0)->getType()->castAs<PointerType>();
   llvm::Type *ByValTy = CGM.getTypes().ConvertType(PtrTy->getPointeeType());
+  // byval needs a sized type, but the frame's type may be unsized, e.g. an
+  // incomplete struct ("struct interrupt_frame;" in GCC's documentation). The
+  // backend locates the frame itself, so use i8 as for "void *".
+  if (!ByValTy->isSized())
+    ByValTy = CGM.Int8Ty;
   llvm::Attribute NewAttr = llvm::Attribute::getWithByValType(
     Fn->getContext(), ByValTy);
   Fn->addParamAttr(0, NewAttr);
diff --git a/clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c 
b/clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c
new file mode 100644
index 00000000000000..f07c5307914834
--- /dev/null
+++ b/clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,X86_64
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,X86
+
+// The interrupt frame's type may be unsized: an incomplete type, as in GCC's
+// documentation, or a function type. byval needs a sized type, so i8 is used,
+// as for "void *".
+
+#ifdef __x86_64__
+typedef __UINT64_TYPE__ uword;
+#else
+typedef __UINT32_TYPE__ uword;
+#endif
+
+struct interrupt_frame;
+union frame_union;
+typedef struct frame_tag frame_t;
+
+// CHECK: define{{.*}} x86_intrcc void @frame_void(ptr noundef byval(i8) 
%{{.+}})
+__attribute__((interrupt)) void frame_void(void *f) {}
+
+// CHECK: define{{.*}} x86_intrcc void @frame_struct(ptr noundef byval(i8) 
%{{.+}})
+__attribute__((interrupt)) void frame_struct(struct interrupt_frame *f) {}
+
+// X86_64: define{{.*}} x86_intrcc void @frame_struct_ec(ptr noundef byval(i8) 
%{{.+}}, i64 noundef %{{.+}})
+// X86: define{{.*}} x86_intrcc void @frame_struct_ec(ptr noundef byval(i8) 
%{{.+}}, i32 noundef %{{.+}})
+__attribute__((interrupt)) void frame_struct_ec(struct interrupt_frame *f,
+                                                uword ec) {}
+
+// CHECK: define{{.*}} x86_intrcc void @frame_union(ptr noundef byval(i8) 
%{{.+}})
+__attribute__((interrupt)) void frame_union(union frame_union *f) {}
+
+// CHECK: define{{.*}} x86_intrcc void @frame_typedef(ptr noundef byval(i8) 
%{{.+}})
+__attribute__((interrupt)) void frame_typedef(frame_t *f) {}
+
+// CHECK: define{{.*}} x86_intrcc void @frame_func(ptr noundef byval(i8) 
%{{.+}})
+__attribute__((interrupt)) void frame_func(void (*f)(void)) {}
+
+// A type completed after the handler is still incomplete where the handler is
+// emitted.
+struct frame_later;
+// CHECK: define{{.*}} x86_intrcc void @frame_later(ptr noundef byval(i8) 
%{{.+}})
+__attribute__((interrupt)) void frame_later(struct frame_later *f) {}
+struct frame_later {
+  uword ip;
+};

>From 7cddf6514667b2c5a690d1f72de52c8c3577b42a Mon Sep 17 00:00:00 2001
From: "Zou, Feng" <[email protected]>
Date: Thu, 5 Nov 2026 22:45:41 +0530
Subject: [PATCH 2/3] Use the backend's frame size as the byval type

byval(i8) claims a one-byte object, so optimizations may treat a read of
any later frame slot as undefined. The backend lays out the interrupt
frame as five stack slots (CC_X86_Intr), so use [5 x iN] when the
frame's type gives no size, for void as well as for unsized types.

Assisted-by: Claude Opus 5.5 <[email protected]>
---
 clang/lib/CodeGen/Targets/X86.cpp             | 13 ++++++----
 .../attr-x86-interrupt-incomplete-frame.c     | 26 +++++++++----------
 2 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index fc49756374fd80..e7f47f87d13b58 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -1234,11 +1234,14 @@ static void addX86InterruptAttrs(const FunctionDecl 
*FD, llvm::GlobalValue *GV,
 
   const auto *PtrTy = FD->getParamDecl(0)->getType()->castAs<PointerType>();
   llvm::Type *ByValTy = CGM.getTypes().ConvertType(PtrTy->getPointeeType());
-  // byval needs a sized type, but the frame's type may be unsized, e.g. an
-  // incomplete struct ("struct interrupt_frame;" in GCC's documentation). The
-  // backend locates the frame itself, so use i8 as for "void *".
-  if (!ByValTy->isSized())
-    ByValTy = CGM.Int8Ty;
+  // byval marks parameter 0 as the address of the frame the processor pushed,
+  // which the backend models as five stack slots (CC_X86_Intr). The byval type
+  // must not claim less than that: optimizations treat accesses past its end
+  // as undefined. Use the five slots when the frame's type gives no size: 
void,
+  // or unsized, e.g. an incomplete struct ("struct interrupt_frame;" in GCC's
+  // documentation).
+  if (PtrTy->getPointeeType()->isVoidType() || !ByValTy->isSized())
+    ByValTy = llvm::ArrayType::get(CGM.IntPtrTy, 5);
   llvm::Attribute NewAttr = llvm::Attribute::getWithByValType(
     Fn->getContext(), ByValTy);
   Fn->addParamAttr(0, NewAttr);
diff --git a/clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c 
b/clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c
index f07c5307914834..d96168e62880ae 100644
--- a/clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c
+++ b/clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,X86_64
-// RUN: %clang_cc1 -triple i386-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,X86
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,X86_64 -DFRAME="[5 x i64]"
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,X86 -DFRAME="[5 x i32]"
 
-// The interrupt frame's type may be unsized: an incomplete type, as in GCC's
-// documentation, or a function type. byval needs a sized type, so i8 is used,
-// as for "void *".
+// When the frame's type gives no size (void, an incomplete type as in GCC's
+// documentation, or a function type), the byval type is the five stack slots
+// the backend assigns to the frame.
 
 #ifdef __x86_64__
 typedef __UINT64_TYPE__ uword;
@@ -15,30 +15,30 @@ struct interrupt_frame;
 union frame_union;
 typedef struct frame_tag frame_t;
 
-// CHECK: define{{.*}} x86_intrcc void @frame_void(ptr noundef byval(i8) 
%{{.+}})
+// CHECK: define{{.*}} x86_intrcc void @frame_void(ptr noundef 
byval([[FRAME]]) %{{.+}})
 __attribute__((interrupt)) void frame_void(void *f) {}
 
-// CHECK: define{{.*}} x86_intrcc void @frame_struct(ptr noundef byval(i8) 
%{{.+}})
+// CHECK: define{{.*}} x86_intrcc void @frame_struct(ptr noundef 
byval([[FRAME]]) %{{.+}})
 __attribute__((interrupt)) void frame_struct(struct interrupt_frame *f) {}
 
-// X86_64: define{{.*}} x86_intrcc void @frame_struct_ec(ptr noundef byval(i8) 
%{{.+}}, i64 noundef %{{.+}})
-// X86: define{{.*}} x86_intrcc void @frame_struct_ec(ptr noundef byval(i8) 
%{{.+}}, i32 noundef %{{.+}})
+// X86_64: define{{.*}} x86_intrcc void @frame_struct_ec(ptr noundef 
byval([[FRAME]]) %{{.+}}, i64 noundef %{{.+}})
+// X86: define{{.*}} x86_intrcc void @frame_struct_ec(ptr noundef 
byval([[FRAME]]) %{{.+}}, i32 noundef %{{.+}})
 __attribute__((interrupt)) void frame_struct_ec(struct interrupt_frame *f,
                                                 uword ec) {}
 
-// CHECK: define{{.*}} x86_intrcc void @frame_union(ptr noundef byval(i8) 
%{{.+}})
+// CHECK: define{{.*}} x86_intrcc void @frame_union(ptr noundef 
byval([[FRAME]]) %{{.+}})
 __attribute__((interrupt)) void frame_union(union frame_union *f) {}
 
-// CHECK: define{{.*}} x86_intrcc void @frame_typedef(ptr noundef byval(i8) 
%{{.+}})
+// CHECK: define{{.*}} x86_intrcc void @frame_typedef(ptr noundef 
byval([[FRAME]]) %{{.+}})
 __attribute__((interrupt)) void frame_typedef(frame_t *f) {}
 
-// CHECK: define{{.*}} x86_intrcc void @frame_func(ptr noundef byval(i8) 
%{{.+}})
+// CHECK: define{{.*}} x86_intrcc void @frame_func(ptr noundef 
byval([[FRAME]]) %{{.+}})
 __attribute__((interrupt)) void frame_func(void (*f)(void)) {}
 
 // A type completed after the handler is still incomplete where the handler is
 // emitted.
 struct frame_later;
-// CHECK: define{{.*}} x86_intrcc void @frame_later(ptr noundef byval(i8) 
%{{.+}})
+// CHECK: define{{.*}} x86_intrcc void @frame_later(ptr noundef 
byval([[FRAME]]) %{{.+}})
 __attribute__((interrupt)) void frame_later(struct frame_later *f) {}
 struct frame_later {
   uword ip;

>From d52d886915c2672a8eef5a76bf1442d4ff51f5b8 Mon Sep 17 00:00:00 2001
From: Feng Zou <[email protected]>
Date: Sat, 21 Nov 2026 23:05:07 +0800
Subject: [PATCH 3/3] Add an alignment attribute and merge the tests

Add align 8 (64-bit) / align 4 (32-bit) to the interrupt frame parameter:
in 64-bit mode the processor aligns the stack to 16 bytes before pushing
the five-slot frame, so the frame is slot-aligned.

Use i64 slots for x32 as well: CC_X86_Intr uses 8-byte slots whenever the
subtarget is 64-bit, but IntPtrTy is i32 on x32, which made the frame
[5 x i32].

Fold attr-x86-interrupt-incomplete-frame.c into attr-x86-interrupt.c.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 clang/lib/CodeGen/Targets/X86.cpp             | 11 ++-
 .../attr-x86-interrupt-incomplete-frame.c     | 45 -----------
 clang/test/CodeGen/attr-x86-interrupt.c       | 79 ++++++++++++-------
 clang/test/CodeGenCXX/attr-x86-interrupt.cpp  | 24 +++---
 4 files changed, 71 insertions(+), 88 deletions(-)
 delete mode 100644 clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index e7f47f87d13b58..bcd3ae5141a9c6 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -1239,12 +1239,19 @@ static void addX86InterruptAttrs(const FunctionDecl 
*FD, llvm::GlobalValue *GV,
   // must not claim less than that: optimizations treat accesses past its end
   // as undefined. Use the five slots when the frame's type gives no size: 
void,
   // or unsized, e.g. an incomplete struct ("struct interrupt_frame;" in GCC's
-  // documentation).
+  // documentation). The slots are 8 bytes in 64-bit mode, including x32, and 4
+  // bytes otherwise.
+  bool Is64Bit = CGM.getTarget().getTriple().isArch64Bit();
+  llvm::IntegerType *SlotTy = Is64Bit ? CGM.Int64Ty : CGM.Int32Ty;
   if (PtrTy->getPointeeType()->isVoidType() || !ByValTy->isSized())
-    ByValTy = llvm::ArrayType::get(CGM.IntPtrTy, 5);
+    ByValTy = llvm::ArrayType::get(SlotTy, 5);
   llvm::Attribute NewAttr = llvm::Attribute::getWithByValType(
     Fn->getContext(), ByValTy);
   Fn->addParamAttr(0, NewAttr);
+  // The frame is slot-aligned: in 64-bit mode the processor aligns the stack 
to
+  // 16 bytes before pushing the five slots and the error code, if any.
+  Fn->addParamAttr(0, llvm::Attribute::getWithAlignment(
+                          Fn->getContext(), llvm::Align(Is64Bit ? 8 : 4)));
 }
 
 void X86_32TargetCodeGenInfo::setTargetAttributes(
diff --git a/clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c 
b/clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c
deleted file mode 100644
index d96168e62880ae..00000000000000
--- a/clang/test/CodeGen/attr-x86-interrupt-incomplete-frame.c
+++ /dev/null
@@ -1,45 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,X86_64 -DFRAME="[5 x i64]"
-// RUN: %clang_cc1 -triple i386-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,X86 -DFRAME="[5 x i32]"
-
-// When the frame's type gives no size (void, an incomplete type as in GCC's
-// documentation, or a function type), the byval type is the five stack slots
-// the backend assigns to the frame.
-
-#ifdef __x86_64__
-typedef __UINT64_TYPE__ uword;
-#else
-typedef __UINT32_TYPE__ uword;
-#endif
-
-struct interrupt_frame;
-union frame_union;
-typedef struct frame_tag frame_t;
-
-// CHECK: define{{.*}} x86_intrcc void @frame_void(ptr noundef 
byval([[FRAME]]) %{{.+}})
-__attribute__((interrupt)) void frame_void(void *f) {}
-
-// CHECK: define{{.*}} x86_intrcc void @frame_struct(ptr noundef 
byval([[FRAME]]) %{{.+}})
-__attribute__((interrupt)) void frame_struct(struct interrupt_frame *f) {}
-
-// X86_64: define{{.*}} x86_intrcc void @frame_struct_ec(ptr noundef 
byval([[FRAME]]) %{{.+}}, i64 noundef %{{.+}})
-// X86: define{{.*}} x86_intrcc void @frame_struct_ec(ptr noundef 
byval([[FRAME]]) %{{.+}}, i32 noundef %{{.+}})
-__attribute__((interrupt)) void frame_struct_ec(struct interrupt_frame *f,
-                                                uword ec) {}
-
-// CHECK: define{{.*}} x86_intrcc void @frame_union(ptr noundef 
byval([[FRAME]]) %{{.+}})
-__attribute__((interrupt)) void frame_union(union frame_union *f) {}
-
-// CHECK: define{{.*}} x86_intrcc void @frame_typedef(ptr noundef 
byval([[FRAME]]) %{{.+}})
-__attribute__((interrupt)) void frame_typedef(frame_t *f) {}
-
-// CHECK: define{{.*}} x86_intrcc void @frame_func(ptr noundef 
byval([[FRAME]]) %{{.+}})
-__attribute__((interrupt)) void frame_func(void (*f)(void)) {}
-
-// A type completed after the handler is still incomplete where the handler is
-// emitted.
-struct frame_later;
-// CHECK: define{{.*}} x86_intrcc void @frame_later(ptr noundef 
byval([[FRAME]]) %{{.+}})
-__attribute__((interrupt)) void frame_later(struct frame_later *f) {}
-struct frame_later {
-  uword ip;
-};
diff --git a/clang/test/CodeGen/attr-x86-interrupt.c 
b/clang/test/CodeGen/attr-x86-interrupt.c
index 4e96920ba778fa..616c3464037818 100644
--- a/clang/test/CodeGen/attr-x86-interrupt.c
+++ b/clang/test/CodeGen/attr-x86-interrupt.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefix=X86_64_LINUX
-// RUN: %clang_cc1 -triple i386-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefix=X86_LINUX
-// RUN: %clang_cc1 -triple x86_64-pc-win32 %s -emit-llvm -o - | FileCheck %s 
--check-prefix=X86_64_WIN
-// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -o - | FileCheck %s 
--check-prefix=X86_WIN
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32 %s -emit-llvm -o - | 
FileCheck %s --check-prefix=X86_64_LINUX
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,LINUX -DUWORD=i64 -DFRAME="[5 x i64]" 
-DALIGN=8
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,LINUX -DUWORD=i32 -DFRAME="[5 x i32]" 
-DALIGN=4
+// RUN: %clang_cc1 -triple x86_64-pc-win32 %s -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,WIN -DUWORD=i64 -DFRAME="[5 x i64]" -DALIGN=8
+// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,WIN -DUWORD=i32 -DFRAME="[5 x i32]" -DALIGN=4
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32 %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,LINUX -DUWORD=i64 -DFRAME="[5 x i64]" 
-DALIGN=8
 
 #ifdef __x86_64__
 typedef __UINT64_TYPE__ uword;
@@ -10,31 +10,52 @@ typedef __UINT64_TYPE__ uword;
 typedef __UINT32_TYPE__ uword;
 #endif
 
+// LINUX: @llvm.compiler.used = appending global [10 x ptr] [ptr @foo7, ptr 
@foo8, ptr @foo_typedef, ptr @frame_void, ptr @frame_struct, ptr 
@frame_struct_ec, ptr @frame_union, ptr @frame_typedef, ptr @frame_func, ptr 
@frame_later], section "llvm.metadata"
+// WIN: @llvm.used = appending global [10 x ptr] [ptr @foo7, ptr @foo8, ptr 
@foo_typedef, ptr @frame_void, ptr @frame_struct, ptr @frame_struct_ec, ptr 
@frame_union, ptr @frame_typedef, ptr @frame_func, ptr @frame_later], section 
"llvm.metadata"
+
+// CHECK: define dso_local x86_intrcc void @foo7(ptr noundef byval(i32) align 
[[ALIGN]] %{{.+}}, [[UWORD]] noundef %{{.+}})
 __attribute__((interrupt)) void foo7(int *a, uword b) {}
+// CHECK: define dso_local x86_intrcc void @foo8(ptr noundef byval(i32) align 
[[ALIGN]] %{{.+}})
 __attribute__((interrupt)) void foo8(int *a) {}
 typedef int *int_ptr;
+// CHECK: define dso_local x86_intrcc void @foo_typedef(ptr noundef byval(i32) 
align [[ALIGN]] %{{.+}})
 __attribute__((interrupt)) void foo_typedef(int_ptr a) {}
-// X86_64_LINUX: @llvm.compiler.used = appending global [3 x ptr] [ptr @foo7, 
ptr @foo8, ptr @foo_typedef], section "llvm.metadata"
-// X86_64_LINUX: define{{.*}} x86_intrcc void @foo7(ptr noundef byval(i32) 
%{{.+}}, i64 noundef %{{.+}})
-// X86_64_LINUX: define{{.*}} x86_intrcc void @foo8(ptr noundef byval(i32) 
%{{.+}})
-// X86_64_LINUX: define{{.*}} x86_intrcc void @foo_typedef(ptr noundef 
byval(i32) %{{.+}})
-// X86_64_LINUX: "disable-tail-calls"="true"
-// X86_64_LINUX-NOT: "disable-tail-calls"="false"
-// X86_LINUX: @llvm.compiler.used = appending global [3 x ptr] [ptr @foo7, ptr 
@foo8, ptr @foo_typedef], section "llvm.metadata"
-// X86_LINUX: define{{.*}} x86_intrcc void @foo7(ptr noundef byval(i32) 
%{{.+}}, i32 noundef %{{.+}})
-// X86_LINUX: define{{.*}} x86_intrcc void @foo8(ptr noundef byval(i32) 
%{{.+}})
-// X86_LINUX: define{{.*}} x86_intrcc void @foo_typedef(ptr noundef byval(i32) 
%{{.+}})
-// X86_LINUX: "disable-tail-calls"="true"
-// X86_LINUX-NOT: "disable-tail-calls"="false"
-// X86_64_WIN: @llvm.used = appending global [3 x ptr] [ptr @foo7, ptr @foo8, 
ptr @foo_typedef], section "llvm.metadata"
-// X86_64_WIN: define dso_local x86_intrcc void @foo7(ptr noundef byval(i32) 
%{{.+}}, i64 noundef %{{.+}})
-// X86_64_WIN: define dso_local x86_intrcc void @foo8(ptr noundef byval(i32) 
%{{.+}})
-// X86_64_WIN: define dso_local x86_intrcc void @foo_typedef(ptr noundef 
byval(i32) %{{.+}})
-// X86_64_WIN: "disable-tail-calls"="true"
-// X86_64_WIN-NOT: "disable-tail-calls"="false"
-// X86_WIN: @llvm.used = appending global [3 x ptr] [ptr @foo7, ptr @foo8, ptr 
@foo_typedef], section "llvm.metadata"
-// X86_WIN: define dso_local x86_intrcc void @foo7(ptr noundef byval(i32) 
%{{.+}}, i32 noundef %{{.+}})
-// X86_WIN: define dso_local x86_intrcc void @foo8(ptr noundef byval(i32) 
%{{.+}})
-// X86_WIN: define dso_local x86_intrcc void @foo_typedef(ptr noundef 
byval(i32) %{{.+}})
-// X86_WIN: "disable-tail-calls"="true"
-// X86_WIN-NOT: "disable-tail-calls"="false"
+
+// When the frame's type gives no size (void, an incomplete type as in GCC's
+// documentation, or a function type), the byval type is the five stack slots
+// the backend assigns to the frame.
+
+struct interrupt_frame;
+union frame_union;
+typedef struct frame_tag frame_t;
+
+// CHECK: define dso_local x86_intrcc void @frame_void(ptr noundef 
byval([[FRAME]]) align [[ALIGN]] %{{.+}})
+__attribute__((interrupt)) void frame_void(void *f) {}
+
+// CHECK: define dso_local x86_intrcc void @frame_struct(ptr noundef 
byval([[FRAME]]) align [[ALIGN]] %{{.+}})
+__attribute__((interrupt)) void frame_struct(struct interrupt_frame *f) {}
+
+// CHECK: define dso_local x86_intrcc void @frame_struct_ec(ptr noundef 
byval([[FRAME]]) align [[ALIGN]] %{{.+}}, [[UWORD]] noundef %{{.+}})
+__attribute__((interrupt)) void frame_struct_ec(struct interrupt_frame *f,
+                                                uword ec) {}
+
+// CHECK: define dso_local x86_intrcc void @frame_union(ptr noundef 
byval([[FRAME]]) align [[ALIGN]] %{{.+}})
+__attribute__((interrupt)) void frame_union(union frame_union *f) {}
+
+// CHECK: define dso_local x86_intrcc void @frame_typedef(ptr noundef 
byval([[FRAME]]) align [[ALIGN]] %{{.+}})
+__attribute__((interrupt)) void frame_typedef(frame_t *f) {}
+
+// CHECK: define dso_local x86_intrcc void @frame_func(ptr noundef 
byval([[FRAME]]) align [[ALIGN]] %{{.+}})
+__attribute__((interrupt)) void frame_func(void (*f)(void)) {}
+
+// A type completed after the handler is still incomplete where the handler is
+// emitted.
+struct frame_later;
+// CHECK: define dso_local x86_intrcc void @frame_later(ptr noundef 
byval([[FRAME]]) align [[ALIGN]] %{{.+}})
+__attribute__((interrupt)) void frame_later(struct frame_later *f) {}
+struct frame_later {
+  uword ip;
+};
+
+// CHECK: "disable-tail-calls"="true"
+// CHECK-NOT: "disable-tail-calls"="false"
diff --git a/clang/test/CodeGenCXX/attr-x86-interrupt.cpp 
b/clang/test/CodeGenCXX/attr-x86-interrupt.cpp
index 863db4a05975ab..30f935a447daed 100644
--- a/clang/test/CodeGenCXX/attr-x86-interrupt.cpp
+++ b/clang/test/CodeGenCXX/attr-x86-interrupt.cpp
@@ -18,18 +18,18 @@ struct St {
 static void foo9(int *a) __attribute__((interrupt)) {}
 };
 // X86_64_LINUX: @llvm.compiler.used = appending global [3 x ptr] [ptr 
@{{.*}}foo7{{.*}}, ptr @{{.*}}foo8{{.*}}, ptr @{{.*}}foo9{{.*}}], section 
"llvm.metadata"
-// X86_64_LINUX: define{{.*}} x86_intrcc void @{{.*}}foo7{{.*}}(ptr noundef 
byval(i32) %{{.+}}, i64 noundef %{{.+}})
-// X86_64_LINUX: define{{.*}} x86_intrcc void @{{.*}}foo8{{.*}}(ptr noundef 
byval(i32) %{{.+}})
-// X86_64_LINUX: define linkonce_odr x86_intrcc void @{{.*}}foo9{{.*}}(ptr 
noundef byval(i32) %{{.+}})
+// X86_64_LINUX: define{{.*}} x86_intrcc void @{{.*}}foo7{{.*}}(ptr noundef 
byval(i32) align 8 %{{.+}}, i64 noundef %{{.+}})
+// X86_64_LINUX: define{{.*}} x86_intrcc void @{{.*}}foo8{{.*}}(ptr noundef 
byval(i32) align 8 %{{.+}})
+// X86_64_LINUX: define linkonce_odr x86_intrcc void @{{.*}}foo9{{.*}}(ptr 
noundef byval(i32) align 8 %{{.+}})
 // X86_LINUX: @llvm.compiler.used = appending global [3 x ptr] [ptr 
@{{.*}}foo7{{.*}}, ptr @{{.*}}foo8{{.*}}, ptr @{{.*}}foo9{{.*}}], section 
"llvm.metadata"
-// X86_LINUX: define{{.*}} x86_intrcc void @{{.*}}foo7{{.*}}(ptr noundef 
byval(i32) %{{.+}}, i32 noundef %{{.+}})
-// X86_LINUX: define{{.*}} x86_intrcc void @{{.*}}foo8{{.*}}(ptr noundef 
byval(i32) %{{.+}})
-// X86_LINUX: define linkonce_odr x86_intrcc void @{{.*}}foo9{{.*}}(ptr 
noundef byval(i32) %{{.+}})
+// X86_LINUX: define{{.*}} x86_intrcc void @{{.*}}foo7{{.*}}(ptr noundef 
byval(i32) align 4 %{{.+}}, i32 noundef %{{.+}})
+// X86_LINUX: define{{.*}} x86_intrcc void @{{.*}}foo8{{.*}}(ptr noundef 
byval(i32) align 4 %{{.+}})
+// X86_LINUX: define linkonce_odr x86_intrcc void @{{.*}}foo9{{.*}}(ptr 
noundef byval(i32) align 4 %{{.+}})
 // X86_64_WIN: @llvm.used = appending global [3 x ptr] [ptr @{{.*}}foo7{{.*}}, 
ptr @{{.*}}foo8{{.*}}, ptr @{{.*}}foo9{{.*}}], section "llvm.metadata"
-// X86_64_WIN: define dso_local x86_intrcc void @{{.*}}foo7{{.*}}(ptr noundef 
byval(i32) %{{.+}}, i64 noundef %{{.+}})
-// X86_64_WIN: define dso_local x86_intrcc void @{{.*}}foo8{{.*}}(ptr noundef 
byval(i32) %{{.+}})
-// X86_64_WIN: define linkonce_odr dso_local x86_intrcc void 
@{{.*}}foo9{{.*}}(ptr noundef byval(i32) %{{.+}})
+// X86_64_WIN: define dso_local x86_intrcc void @{{.*}}foo7{{.*}}(ptr noundef 
byval(i32) align 8 %{{.+}}, i64 noundef %{{.+}})
+// X86_64_WIN: define dso_local x86_intrcc void @{{.*}}foo8{{.*}}(ptr noundef 
byval(i32) align 8 %{{.+}})
+// X86_64_WIN: define linkonce_odr dso_local x86_intrcc void 
@{{.*}}foo9{{.*}}(ptr noundef byval(i32) align 8 %{{.+}})
 // X86_WIN: @llvm.used = appending global [3 x ptr] [ptr @{{.*}}foo7{{.*}}, 
ptr @{{.*}}foo8{{.*}}, ptr @{{.*}}foo9{{.*}}], section "llvm.metadata"
-// X86_WIN: define dso_local x86_intrcc void @{{.*}}foo7{{.*}}(ptr noundef 
byval(i32) %{{.+}}, i32 noundef %{{.+}})
-// X86_WIN: define dso_local x86_intrcc void @{{.*}}foo8{{.*}}(ptr noundef 
byval(i32) %{{.+}})
-// X86_WIN: define linkonce_odr dso_local x86_intrcc void 
@{{.*}}foo9{{.*}}(ptr noundef byval(i32) %{{.+}})
+// X86_WIN: define dso_local x86_intrcc void @{{.*}}foo7{{.*}}(ptr noundef 
byval(i32) align 4 %{{.+}}, i32 noundef %{{.+}})
+// X86_WIN: define dso_local x86_intrcc void @{{.*}}foo8{{.*}}(ptr noundef 
byval(i32) align 4 %{{.+}})
+// X86_WIN: define linkonce_odr dso_local x86_intrcc void 
@{{.*}}foo9{{.*}}(ptr noundef byval(i32) align 4 %{{.+}})

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

Reply via email to