https://github.com/durin42 updated 
https://github.com/llvm/llvm-project/pull/239730

>From 01087e63dc3a0f4108b077db0d6d22df3e68c33f Mon Sep 17 00:00:00 2001
From: Augie Fackler <[email protected]>
Date: Wed, 4 Nov 2026 13:04:37 -0500
Subject: [PATCH] clang: emit allocalign to LLVM for alloc_align attributes

LLVM is growing knowledge of this, so we should inform it when we have
the information available. As a bonus, since we now check return
alignments in the callee as of an earlier patch of mine, we can now drop
the redundant llvm.assume() that this previously emitted.

This patch is originally from 2023 and was rebased and revised with
assistance from an LLM. I have manually reviewed the diffs to the
limit of my abilities (I don't do much in LLVM, and this is my first
time touching clang in a meaningful way) and they appear sensible. The
commit messages are entirely written by me.

Differential Revision: https://reviews.llvm.org/D119271
---
 clang/lib/CodeGen/CGCall.cpp                  | 26 ++++-
 clang/test/CodeGen/alloc-align-attr.c         | 22 ++---
 clang/test/CodeGen/alloc-fns-alignment.c      |  6 +-
 clang/test/CodeGen/alloc-token.c              |  4 +-
 ...ssume-aligned-and-alloc-align-attributes.c | 10 +-
 ...ibute-alloc_align-on-function-variable.cpp | 99 +++----------------
 ...tion-attribute-alloc_align-on-function.cpp | 43 ++------
 .../non-power-of-2-alignment-assumptions.c    |  9 +-
 .../CodeGenCXX/align-avx-complete-objects.cpp |  4 +-
 clang/test/CodeGenCXX/alloc-token.cpp         |  2 +-
 .../builtin-operator-new-delete.cpp           |  2 +-
 .../CodeGenCXX/cxx1z-aligned-allocation.cpp   | 12 +--
 clang/test/CodeGenCXX/new_hot_cold.cpp        | 16 +--
 ...ibute-alloc_align-on-function-variable.cpp |  3 -
 ...sume-attribute-alloc_align-on-function.cpp |  3 -
 15 files changed, 80 insertions(+), 181 deletions(-)

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 02324187d2faf5..5565d221bbaa13 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5726,6 +5726,28 @@ class AllocAlignAttrEmitter final
                     .getRValue(CGF)
                     .getScalarVal();
   }
+
+  [[nodiscard]] llvm::AttributeList
+  TryEmitAsCallSiteAttribute(const llvm::AttributeList &Attrs,
+                             const ClangToLLVMArgMapping &IRFunctionArgs) {
+    llvm::AttributeList NewAttrs = Attrs;
+    if (AA) {
+      auto [FirstIRArg, NumIRArgs] =
+          IRFunctionArgs.getIRArgs(AA->getParamIndex().getLLVMIndex());
+      if (NumIRArgs == 1)
+        NewAttrs = NewAttrs.addParamAttribute(CGF.getLLVMContext(), FirstIRArg,
+                                              llvm::Attribute::AllocAlign);
+    }
+    // NOTE: we shouldn't _need_ to emit this `align` attribute here, but there
+    // are some interesting cases where LLVM can manage to delete the arguments
+    // to a function that has the `alloc_align` attribute on it, and then the
+    // alignment gets lost. An example of this is the failure you'll get in
+    // clang/test/Headers/mm_malloc.c if this `align` is omitted, because
+    // _mm_malloc ends up getting its arguments turned into constants that get
+    // passed to posix_memalign, which we don't have logic to handle in LLVM.
+    return AbstractAssumeAlignedAttrEmitter<
+        AllocAlignAttr>::TryEmitAsCallSiteAttribute(NewAttrs);
+  }
 };
 
 } // namespace
@@ -6442,7 +6464,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   Attrs = AssumeAlignedAttrEmitter.TryEmitAsCallSiteAttribute(Attrs);
 
   AllocAlignAttrEmitter AllocAlignAttrEmitter(*this, TargetDecl, CallArgs);
-  Attrs = AllocAlignAttrEmitter.TryEmitAsCallSiteAttribute(Attrs);
+  Attrs =
+      AllocAlignAttrEmitter.TryEmitAsCallSiteAttribute(Attrs, IRFunctionArgs);
 
   if (Attrs.hasFnAttr(llvm::Attribute::Convergent)) {
     addConvergenceControlBundle(BundleList);
@@ -6898,7 +6921,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   // Emit the assume_aligned check on the return value.
   if (Ret.isScalar() && TargetDecl) {
     AssumeAlignedAttrEmitter.EmitAsAnAssumption(Loc, RetTy, Ret);
-    AllocAlignAttrEmitter.EmitAsAnAssumption(Loc, RetTy, Ret);
   }
 
   // Emit the end lifetime markers for any temporary allocas created for the
diff --git a/clang/test/CodeGen/alloc-align-attr.c 
b/clang/test/CodeGen/alloc-align-attr.c
index c4c4e76eaaa045..77bb3d5896a094 100644
--- a/clang/test/CodeGen/alloc-align-attr.c
+++ b/clang/test/CodeGen/alloc-align-attr.c
@@ -9,9 +9,7 @@ __INT32_TYPE__*m1(__INT32_TYPE__ i) 
__attribute__((alloc_align(1)));
 // CHECK-NEXT:    [[A_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    store i32 [[A:%.*]], ptr [[A_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
-// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m1(i32 noundef [[TMP0]])
-// CHECK-NEXT:    [[CASTED_ALIGN:%.*]] = zext i32 [[TMP0]] to i64
-// CHECK-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr [[CALL]], i64 
[[CASTED_ALIGN]]) ]
+// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m1(i32 allocalign noundef [[TMP0]])
 // CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[CALL]], align 4
 // CHECK-NEXT:    ret i32 [[TMP1]]
 //
@@ -25,9 +23,7 @@ __INT32_TYPE__ test1(__INT32_TYPE__ a) {
 // CHECK-NEXT:    store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
 // CHECK-NEXT:    [[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
 // CHECK-NEXT:    [[CONV:%.*]] = trunc i64 [[TMP0]] to i32
-// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m1(i32 noundef [[CONV]])
-// CHECK-NEXT:    [[CASTED_ALIGN:%.*]] = zext i32 [[CONV]] to i64
-// CHECK-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr [[CALL]], i64 
[[CASTED_ALIGN]]) ]
+// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m1(i32 allocalign noundef [[CONV]])
 // CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[CALL]], align 4
 // CHECK-NEXT:    ret i32 [[TMP1]]
 //
@@ -43,8 +39,7 @@ __INT32_TYPE__ *m2(__SIZE_TYPE__ i) 
__attribute__((alloc_align(1)));
 // CHECK-NEXT:    store i32 [[A:%.*]], ptr [[A_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
 // CHECK-NEXT:    [[CONV:%.*]] = sext i32 [[TMP0]] to i64
-// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m2(i64 noundef [[CONV]])
-// CHECK-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr [[CALL]], i64 
[[CONV]]) ]
+// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m2(i64 allocalign noundef [[CONV]])
 // CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[CALL]], align 4
 // CHECK-NEXT:    ret i32 [[TMP1]]
 //
@@ -58,8 +53,7 @@ __INT32_TYPE__ test3(__INT32_TYPE__ a) {
 // CHECK-NEXT:    [[A_ADDR:%.*]] = alloca i64, align 8
 // CHECK-NEXT:    store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
 // CHECK-NEXT:    [[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
-// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m2(i64 noundef [[TMP0]])
-// CHECK-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr [[CALL]], i64 
[[TMP0]]) ]
+// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m2(i64 allocalign noundef [[TMP0]])
 // CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[CALL]], align 4
 // CHECK-NEXT:    ret i32 [[TMP1]]
 //
@@ -79,9 +73,7 @@ __INT32_TYPE__ *m3(struct Empty s, __int128_t i) 
__attribute__((alloc_align(2)))
 // CHECK-NEXT:    [[E:%.*]] = alloca [[STRUCT_EMPTY:%.*]], align 1
 // CHECK-NEXT:    store i128 [[A:%.*]], ptr [[A_ADDR]], align 16
 // CHECK-NEXT:    [[TMP0:%.*]] = load i128, ptr [[A_ADDR]], align 16
-// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m3(i128 noundef [[TMP0]])
-// CHECK-NEXT:    [[CASTED_ALIGN:%.*]] = trunc i128 [[TMP0]] to i64
-// CHECK-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr [[CALL]], i64 
[[CASTED_ALIGN]]) ]
+// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m3(i128 allocalign noundef [[TMP0]])
 // CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[CALL]], align 4
 // CHECK-NEXT:    ret i32 [[TMP1]]
 //
@@ -101,9 +93,7 @@ __INT32_TYPE__ *m4(struct MultiArgs s, __int128_t i) 
__attribute__((alloc_align(
 // CHECK-NEXT:    [[TMP2:%.*]] = load i64, ptr [[TMP1]], align 8
 // CHECK-NEXT:    [[TMP3:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr 
[[E]], i32 0, i32 1
 // CHECK-NEXT:    [[TMP4:%.*]] = load i64, ptr [[TMP3]], align 8
-// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m4(i64 [[TMP2]], i64 [[TMP4]], i128 
noundef [[TMP0]])
-// CHECK-NEXT:    [[CASTED_ALIGN:%.*]] = trunc i128 [[TMP0]] to i64
-// CHECK-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr [[CALL]], i64 
[[CASTED_ALIGN]]) ]
+// CHECK-NEXT:    [[CALL:%.*]] = call ptr @m4(i64 [[TMP2]], i64 [[TMP4]], i128 
allocalign noundef [[TMP0]])
 // CHECK-NEXT:    [[TMP5:%.*]] = load i32, ptr [[CALL]], align 4
 // CHECK-NEXT:    ret i32 [[TMP5]]
 //
diff --git a/clang/test/CodeGen/alloc-fns-alignment.c 
b/clang/test/CodeGen/alloc-fns-alignment.c
index 07261dfbaf5dd0..0d79be98c87a14 100644
--- a/clang/test/CodeGen/alloc-fns-alignment.c
+++ b/clang/test/CodeGen/alloc-fns-alignment.c
@@ -61,14 +61,12 @@ void *memalign_large_constant_test(size_t n) {
 // CHECK: declare ptr @realloc
 
 // CHECK-LABEL: @aligned_alloc_variable_test
-// CHECK:      %[[ALLOCATED:.*]] = call ptr @aligned_alloc({{i32|i64}} noundef 
%[[ALIGN:.*]], {{i32|i64}} noundef %[[NBYTES:.*]])
-// CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr %[[ALLOCATED]], 
{{i32|i64}} %[[ALIGN]]) ]
+// CHECK:      %[[ALLOCATED:.*]] = call ptr @aligned_alloc({{i32|i64}} 
allocalign noundef %[[ALIGN:.*]], {{i32|i64}} noundef %[[NBYTES:.*]])
 
 // CHECK: declare ptr @aligned_alloc
 
 // CHECK-LABEL: @memalign_variable_test
-// CHECK:      %[[ALLOCATED:.*]] = call ptr @memalign({{i32|i64}} noundef 
%[[ALIGN:.*]], {{i32|i64}} noundef %[[NBYTES:.*]])
-// CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr %[[ALLOCATED]], 
{{i32|i64}} %[[ALIGN]]) ]
+// CHECK:      %[[ALLOCATED:.*]] = call ptr @memalign({{i32|i64}} allocalign 
noundef %[[ALIGN:.*]], {{i32|i64}} noundef %[[NBYTES:.*]])
 
 // CHECK-LABEL: @aligned_alloc_constant_test
 // CHECK: call align 8 ptr @aligned_alloc
diff --git a/clang/test/CodeGen/alloc-token.c b/clang/test/CodeGen/alloc-token.c
index 3c9b4d8f0e910a..abd32c0f717a59 100644
--- a/clang/test/CodeGen/alloc-token.c
+++ b/clang/test/CodeGen/alloc-token.c
@@ -19,8 +19,8 @@ void *sink;
 // CHECK: call noalias ptr @calloc(i64 noundef 3, i64 noundef 4){{.*}} 
!alloc_token [[META_INT]]
 // CHECK: call noalias ptr @realloc(ptr noundef {{.*}}, i64 noundef 8){{.*}} 
!alloc_token [[META_LONG:![0-9]+]]
 // CHECK: call noalias ptr @reallocarray(ptr noundef {{.*}}, i64 noundef 5, 
i64 noundef 8), !alloc_token [[META_LONG]]
-// CHECK: call noalias align 128 ptr @aligned_alloc(i64 noundef 128, i64 
noundef 4){{.*}} !alloc_token [[META_INT]]
-// CHECK: call noalias align 16 ptr @memalign(i64 noundef 16, i64 noundef 
4){{.*}} !alloc_token [[META_INT]]
+// CHECK: call noalias align 128 ptr @aligned_alloc(i64 allocalign noundef 
128, i64 noundef 4){{.*}} !alloc_token [[META_INT]]
+// CHECK: call noalias align 16 ptr @memalign(i64 allocalign noundef 16, i64 
noundef 4){{.*}} !alloc_token [[META_INT]]
 // CHECK: call noalias ptr @valloc(i64 noundef 4), !alloc_token [[META_INT]]
 // CHECK: call noalias ptr @pvalloc(i64 noundef 4), !alloc_token [[META_INT]]
 // CHECK: call i32 @posix_memalign(ptr noundef @sink, i64 noundef 64, i64 
noundef 4)
diff --git a/clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c 
b/clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
index fb12b37a5cc0a0..b66efdc9501b81 100644
--- a/clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
+++ b/clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
@@ -5,7 +5,7 @@ void *my_aligned_alloc(int size, int alignment) 
__attribute__((assume_aligned(32
 
 // CHECK-LABEL: @t0_immediate0(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:    [[CALL:%.*]] = call align 32 ptr @my_aligned_alloc(i32 
noundef 320, i32 noundef 16)
+// CHECK-NEXT:    [[CALL:%.*]] = call align 32 ptr @my_aligned_alloc(i32 
noundef 320, i32 allocalign noundef 16)
 // CHECK-NEXT:    ret ptr [[CALL]]
 //
 void *t0_immediate0(void) {
@@ -14,7 +14,7 @@ void *t0_immediate0(void) {
 
 // CHECK-LABEL: @t1_immediate1(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:    [[CALL:%.*]] = call align 32 ptr @my_aligned_alloc(i32 
noundef 320, i32 noundef 32)
+// CHECK-NEXT:    [[CALL:%.*]] = call align 32 ptr @my_aligned_alloc(i32 
noundef 320, i32 allocalign noundef 32)
 // CHECK-NEXT:    ret ptr [[CALL]]
 //
 void *t1_immediate1(void) {
@@ -23,7 +23,7 @@ void *t1_immediate1(void) {
 
 // CHECK-LABEL: @t2_immediate2(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:    [[CALL:%.*]] = call align 64 ptr @my_aligned_alloc(i32 
noundef 320, i32 noundef 64)
+// CHECK-NEXT:    [[CALL:%.*]] = call align 64 ptr @my_aligned_alloc(i32 
noundef 320, i32 allocalign noundef 64)
 // CHECK-NEXT:    ret ptr [[CALL]]
 //
 void *t2_immediate2(void) {
@@ -35,9 +35,7 @@ void *t2_immediate2(void) {
 // CHECK-NEXT:    [[ALIGNMENT_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    store i32 [[ALIGNMENT:%.*]], ptr [[ALIGNMENT_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr [[ALIGNMENT_ADDR]], align 4
-// CHECK-NEXT:    [[CALL:%.*]] = call align 32 ptr @my_aligned_alloc(i32 
noundef 320, i32 noundef [[TMP0]])
-// CHECK-NEXT:    [[CASTED_ALIGN:%.*]] = zext i32 [[TMP0]] to i64
-// CHECK-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr [[CALL]], i64 
[[CASTED_ALIGN]]) ]
+// CHECK-NEXT:    [[CALL:%.*]] = call align 32 ptr @my_aligned_alloc(i32 
noundef 320, i32 allocalign noundef [[TMP0]])
 // CHECK-NEXT:    ret ptr [[CALL]]
 //
 void *t3_variable(int alignment) {
diff --git 
a/clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
 
b/clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
index 5af71455a14243..def1f14baeafa5 100644
--- 
a/clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
+++ 
b/clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
@@ -36,7 +36,7 @@ char **__attribute__((alloc_align(2)))
 // CHECK-SANITIZE-NORECOVER:       handler.return_alignment_assumption:
 // CHECK-SANITIZE-NORECOVER-NEXT:    [[TMP2:%.*]] = ptrtoint ptr 
[[RETURN_SLOC_LOAD]] to i64, !nosanitize [[META2]]
 // CHECK-SANITIZE-NORECOVER-NEXT:    [[TMP3:%.*]] = ptrtoint ptr [[TMP0]] to 
i64, !nosanitize [[META2]]
-// CHECK-SANITIZE-NORECOVER-NEXT:    call void 
@__ubsan_handle_return_alignment_assumption_abort(ptr @[[GLOB2:[0-9]+]], i64 
[[TMP2]], i64 [[TMP3]], i64 [[ALIGNMENT]], i64 0) #[[ATTR3:[0-9]+]], 
!nosanitize [[META2]]
+// CHECK-SANITIZE-NORECOVER-NEXT:    call void 
@__ubsan_handle_return_alignment_assumption_abort(ptr @[[GLOB2:[0-9]+]], i64 
[[TMP2]], i64 [[TMP3]], i64 [[ALIGNMENT]], i64 0) #[[ATTR2:[0-9]+]], 
!nosanitize [[META2]]
 // CHECK-SANITIZE-NORECOVER-NEXT:    unreachable, !nosanitize [[META2]]
 // CHECK-SANITIZE-NORECOVER:       cont:
 // CHECK-SANITIZE-NORECOVER-NEXT:    ret ptr [[TMP0]]
@@ -61,7 +61,7 @@ char **__attribute__((alloc_align(2)))
 // CHECK-SANITIZE-RECOVER:       handler.return_alignment_assumption:
 // CHECK-SANITIZE-RECOVER-NEXT:    [[TMP2:%.*]] = ptrtoint ptr 
[[RETURN_SLOC_LOAD]] to i64, !nosanitize [[META2]]
 // CHECK-SANITIZE-RECOVER-NEXT:    [[TMP3:%.*]] = ptrtoint ptr [[TMP0]] to 
i64, !nosanitize [[META2]]
-// CHECK-SANITIZE-RECOVER-NEXT:    call void 
@__ubsan_handle_return_alignment_assumption(ptr @[[GLOB2:[0-9]+]], i64 
[[TMP2]], i64 [[TMP3]], i64 [[ALIGNMENT]], i64 0) #[[ATTR3:[0-9]+]], 
!nosanitize [[META2]]
+// CHECK-SANITIZE-RECOVER-NEXT:    call void 
@__ubsan_handle_return_alignment_assumption(ptr @[[GLOB2:[0-9]+]], i64 
[[TMP2]], i64 [[TMP3]], i64 [[ALIGNMENT]], i64 0) #[[ATTR2:[0-9]+]], 
!nosanitize [[META2]]
 // CHECK-SANITIZE-RECOVER-NEXT:    br label [[CONT]], !nosanitize [[META2]]
 // CHECK-SANITIZE-RECOVER:       cont:
 // CHECK-SANITIZE-RECOVER-NEXT:    ret ptr [[TMP0]]
@@ -84,7 +84,7 @@ char **__attribute__((alloc_align(2)))
 // CHECK-SANITIZE-TRAP-NEXT:    [[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
 // CHECK-SANITIZE-TRAP-NEXT:    br i1 [[MASKCOND]], label [[CONT:%.*]], label 
[[TRAP:%.*]], !prof [[PROF1:![0-9]+]], !nosanitize [[META2:![0-9]+]]
 // CHECK-SANITIZE-TRAP:       trap:
-// CHECK-SANITIZE-TRAP-NEXT:    call void @llvm.ubsantrap(i8 25) 
#[[ATTR3:[0-9]+]], !nosanitize [[META2]]
+// CHECK-SANITIZE-TRAP-NEXT:    call void @llvm.ubsantrap(i8 25) 
#[[ATTR2:[0-9]+]], !nosanitize [[META2]]
 // CHECK-SANITIZE-TRAP-NEXT:    unreachable, !nosanitize [[META2]]
 // CHECK-SANITIZE-TRAP:       cont:
 // CHECK-SANITIZE-TRAP-NEXT:    ret ptr [[TMP0]]
@@ -93,90 +93,19 @@ passthrough(char **x, unsigned long alignment) {
   return x;
 }
 
-// CHECK-NOSANITIZE-LABEL: define dso_local noundef ptr @_Z6callerPPcm
-// CHECK-NOSANITIZE-SAME: (ptr noundef [[X:%.*]], i64 noundef 
[[ALIGNMENT:%.*]]) #[[ATTR0]] {
-// CHECK-NOSANITIZE-NEXT:  entry:
-// CHECK-NOSANITIZE-NEXT:    [[X_ADDR:%.*]] = alloca ptr, align 8
-// CHECK-NOSANITIZE-NEXT:    [[ALIGNMENT_ADDR:%.*]] = alloca i64, align 8
-// CHECK-NOSANITIZE-NEXT:    store ptr [[X]], ptr [[X_ADDR]], align 8
-// CHECK-NOSANITIZE-NEXT:    store i64 [[ALIGNMENT]], ptr [[ALIGNMENT_ADDR]], 
align 8
-// CHECK-NOSANITIZE-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
-// CHECK-NOSANITIZE-NEXT:    [[TMP1:%.*]] = load i64, ptr [[ALIGNMENT_ADDR]], 
align 8
-// CHECK-NOSANITIZE-NEXT:    [[CALL:%.*]] = call noundef ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 noundef [[TMP1]])
-// CHECK-NOSANITIZE-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr 
[[CALL]], i64 [[TMP1]]) ]
-// CHECK-NOSANITIZE-NEXT:    ret ptr [[CALL]]
-//
-// CHECK-SANITIZE-NORECOVER-LABEL: define dso_local noundef ptr @_Z6callerPPcm
-// CHECK-SANITIZE-NORECOVER-SAME: (ptr noundef [[X:%.*]], i64 noundef 
[[ALIGNMENT:%.*]]) #[[ATTR0]] {
-// CHECK-SANITIZE-NORECOVER-NEXT:  entry:
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[X_ADDR:%.*]] = alloca ptr, align 8
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[ALIGNMENT_ADDR:%.*]] = alloca i64, 
align 8
-// CHECK-SANITIZE-NORECOVER-NEXT:    store ptr [[X]], ptr [[X_ADDR]], align 8
-// CHECK-SANITIZE-NORECOVER-NEXT:    store i64 [[ALIGNMENT]], ptr 
[[ALIGNMENT_ADDR]], align 8
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], 
align 8
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[TMP1:%.*]] = load i64, ptr 
[[ALIGNMENT_ADDR]], align 8
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[CALL:%.*]] = call noundef ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 noundef [[TMP1]])
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[PTRINT:%.*]] = ptrtoint ptr [[CALL]] to 
i64
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[TMP2:%.*]] = sub i64 [[TMP1]], 1
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 
[[TMP2]]
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[MASKCOND:%.*]] = icmp eq i64 
[[MASKEDPTR]], 0
-// CHECK-SANITIZE-NORECOVER-NEXT:    br i1 [[MASKCOND]], label [[CONT:%.*]], 
label [[HANDLER_ALIGNMENT_ASSUMPTION:%.*]], !prof [[PROF1]], !nosanitize 
[[META2]]
-// CHECK-SANITIZE-NORECOVER:       handler.alignment_assumption:
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[TMP3:%.*]] = ptrtoint ptr [[CALL]] to 
i64, !nosanitize [[META2]]
-// CHECK-SANITIZE-NORECOVER-NEXT:    call void 
@__ubsan_handle_alignment_assumption_abort(ptr @[[GLOB3:[0-9]+]], i64 [[TMP3]], 
i64 [[TMP1]], i64 0) #[[ATTR3]], !nosanitize [[META2]]
-// CHECK-SANITIZE-NORECOVER-NEXT:    unreachable, !nosanitize [[META2]]
-// CHECK-SANITIZE-NORECOVER:       cont:
-// CHECK-SANITIZE-NORECOVER-NEXT:    call void @llvm.assume(i1 true) [ 
"align"(ptr [[CALL]], i64 [[TMP1]]) ]
-// CHECK-SANITIZE-NORECOVER-NEXT:    ret ptr [[CALL]]
-//
-// CHECK-SANITIZE-RECOVER-LABEL: define dso_local noundef ptr @_Z6callerPPcm
-// CHECK-SANITIZE-RECOVER-SAME: (ptr noundef [[X:%.*]], i64 noundef 
[[ALIGNMENT:%.*]]) #[[ATTR0]] {
-// CHECK-SANITIZE-RECOVER-NEXT:  entry:
-// CHECK-SANITIZE-RECOVER-NEXT:    [[X_ADDR:%.*]] = alloca ptr, align 8
-// CHECK-SANITIZE-RECOVER-NEXT:    [[ALIGNMENT_ADDR:%.*]] = alloca i64, align 8
-// CHECK-SANITIZE-RECOVER-NEXT:    store ptr [[X]], ptr [[X_ADDR]], align 8
-// CHECK-SANITIZE-RECOVER-NEXT:    store i64 [[ALIGNMENT]], ptr 
[[ALIGNMENT_ADDR]], align 8
-// CHECK-SANITIZE-RECOVER-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], 
align 8
-// CHECK-SANITIZE-RECOVER-NEXT:    [[TMP1:%.*]] = load i64, ptr 
[[ALIGNMENT_ADDR]], align 8
-// CHECK-SANITIZE-RECOVER-NEXT:    [[CALL:%.*]] = call noundef ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 noundef [[TMP1]])
-// CHECK-SANITIZE-RECOVER-NEXT:    [[PTRINT:%.*]] = ptrtoint ptr [[CALL]] to 
i64
-// CHECK-SANITIZE-RECOVER-NEXT:    [[TMP2:%.*]] = sub i64 [[TMP1]], 1
-// CHECK-SANITIZE-RECOVER-NEXT:    [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 
[[TMP2]]
-// CHECK-SANITIZE-RECOVER-NEXT:    [[MASKCOND:%.*]] = icmp eq i64 
[[MASKEDPTR]], 0
-// CHECK-SANITIZE-RECOVER-NEXT:    br i1 [[MASKCOND]], label [[CONT:%.*]], 
label [[HANDLER_ALIGNMENT_ASSUMPTION:%.*]], !prof [[PROF1]], !nosanitize 
[[META2]]
-// CHECK-SANITIZE-RECOVER:       handler.alignment_assumption:
-// CHECK-SANITIZE-RECOVER-NEXT:    [[TMP3:%.*]] = ptrtoint ptr [[CALL]] to 
i64, !nosanitize [[META2]]
-// CHECK-SANITIZE-RECOVER-NEXT:    call void 
@__ubsan_handle_alignment_assumption(ptr @[[GLOB3:[0-9]+]], i64 [[TMP3]], i64 
[[TMP1]], i64 0) #[[ATTR3]], !nosanitize [[META2]]
-// CHECK-SANITIZE-RECOVER-NEXT:    br label [[CONT]], !nosanitize [[META2]]
-// CHECK-SANITIZE-RECOVER:       cont:
-// CHECK-SANITIZE-RECOVER-NEXT:    call void @llvm.assume(i1 true) [ 
"align"(ptr [[CALL]], i64 [[TMP1]]) ]
-// CHECK-SANITIZE-RECOVER-NEXT:    ret ptr [[CALL]]
-//
-// CHECK-SANITIZE-TRAP-LABEL: define dso_local noundef ptr @_Z6callerPPcm
-// CHECK-SANITIZE-TRAP-SAME: (ptr noundef [[X:%.*]], i64 noundef 
[[ALIGNMENT:%.*]]) #[[ATTR0]] {
-// CHECK-SANITIZE-TRAP-NEXT:  entry:
-// CHECK-SANITIZE-TRAP-NEXT:    [[X_ADDR:%.*]] = alloca ptr, align 8
-// CHECK-SANITIZE-TRAP-NEXT:    [[ALIGNMENT_ADDR:%.*]] = alloca i64, align 8
-// CHECK-SANITIZE-TRAP-NEXT:    store ptr [[X]], ptr [[X_ADDR]], align 8
-// CHECK-SANITIZE-TRAP-NEXT:    store i64 [[ALIGNMENT]], ptr 
[[ALIGNMENT_ADDR]], align 8
-// CHECK-SANITIZE-TRAP-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 
8
-// CHECK-SANITIZE-TRAP-NEXT:    [[TMP1:%.*]] = load i64, ptr 
[[ALIGNMENT_ADDR]], align 8
-// CHECK-SANITIZE-TRAP-NEXT:    [[CALL:%.*]] = call noundef ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 noundef [[TMP1]])
-// CHECK-SANITIZE-TRAP-NEXT:    [[PTRINT:%.*]] = ptrtoint ptr [[CALL]] to i64
-// CHECK-SANITIZE-TRAP-NEXT:    [[TMP2:%.*]] = sub i64 [[TMP1]], 1
-// CHECK-SANITIZE-TRAP-NEXT:    [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 
[[TMP2]]
-// CHECK-SANITIZE-TRAP-NEXT:    [[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
-// CHECK-SANITIZE-TRAP-NEXT:    br i1 [[MASKCOND]], label [[CONT:%.*]], label 
[[TRAP:%.*]], !prof [[PROF1]], !nosanitize [[META2]]
-// CHECK-SANITIZE-TRAP:       trap:
-// CHECK-SANITIZE-TRAP-NEXT:    call void @llvm.ubsantrap(i8 23) #[[ATTR3]], 
!nosanitize [[META2]]
-// CHECK-SANITIZE-TRAP-NEXT:    unreachable, !nosanitize [[META2]]
-// CHECK-SANITIZE-TRAP:       cont:
-// CHECK-SANITIZE-TRAP-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr 
[[CALL]], i64 [[TMP1]]) ]
-// CHECK-SANITIZE-TRAP-NEXT:    ret ptr [[CALL]]
+// CHECK-LABEL: define dso_local noundef ptr @_Z6callerPPcm
+// CHECK-SAME: (ptr noundef [[X:%.*]], i64 noundef [[ALIGNMENT:%.*]]) 
#[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[X_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:    [[ALIGNMENT_ADDR:%.*]] = alloca i64, align 8
+// CHECK-NEXT:    store ptr [[X]], ptr [[X_ADDR]], align 8
+// CHECK-NEXT:    store i64 [[ALIGNMENT]], ptr [[ALIGNMENT_ADDR]], align 8
+// CHECK-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
+// CHECK-NEXT:    [[TMP1:%.*]] = load i64, ptr [[ALIGNMENT_ADDR]], align 8
+// CHECK-NEXT:    [[CALL:%.*]] = call noundef ptr @_Z11passthroughPPcm(ptr 
noundef [[TMP0]], i64 allocalign noundef [[TMP1]])
+// CHECK-NEXT:    ret ptr [[CALL]]
 //
 char **caller(char **x, unsigned long alignment) {
 #line 100
   return passthrough(x, alignment);
 }
-//// NOTE: These prefixes are unused and the list is autogenerated. Do not add 
tests below this line:
-// CHECK: {{.*}}
diff --git 
a/clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
 
b/clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
index 8fb70505eb573b..8b214da33f685b 100644
--- 
a/clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
+++ 
b/clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
@@ -36,7 +36,7 @@ char **__attribute__((alloc_align(2)))
 // CHECK-SANITIZE-NORECOVER:       handler.return_alignment_assumption:
 // CHECK-SANITIZE-NORECOVER-NEXT:    [[TMP2:%.*]] = ptrtoint ptr 
[[RETURN_SLOC_LOAD]] to i64, !nosanitize [[META2]]
 // CHECK-SANITIZE-NORECOVER-NEXT:    [[TMP3:%.*]] = ptrtoint ptr [[TMP0]] to 
i64, !nosanitize [[META2]]
-// CHECK-SANITIZE-NORECOVER-NEXT:    call void 
@__ubsan_handle_return_alignment_assumption_abort(ptr @[[GLOB2:[0-9]+]], i64 
[[TMP2]], i64 [[TMP3]], i64 [[ALIGNMENT]], i64 0) #[[ATTR3:[0-9]+]], 
!nosanitize [[META2]]
+// CHECK-SANITIZE-NORECOVER-NEXT:    call void 
@__ubsan_handle_return_alignment_assumption_abort(ptr @[[GLOB2:[0-9]+]], i64 
[[TMP2]], i64 [[TMP3]], i64 [[ALIGNMENT]], i64 0) #[[ATTR2:[0-9]+]], 
!nosanitize [[META2]]
 // CHECK-SANITIZE-NORECOVER-NEXT:    unreachable, !nosanitize [[META2]]
 // CHECK-SANITIZE-NORECOVER:       cont:
 // CHECK-SANITIZE-NORECOVER-NEXT:    ret ptr [[TMP0]]
@@ -61,7 +61,7 @@ char **__attribute__((alloc_align(2)))
 // CHECK-SANITIZE-RECOVER:       handler.return_alignment_assumption:
 // CHECK-SANITIZE-RECOVER-NEXT:    [[TMP2:%.*]] = ptrtoint ptr 
[[RETURN_SLOC_LOAD]] to i64, !nosanitize [[META2]]
 // CHECK-SANITIZE-RECOVER-NEXT:    [[TMP3:%.*]] = ptrtoint ptr [[TMP0]] to 
i64, !nosanitize [[META2]]
-// CHECK-SANITIZE-RECOVER-NEXT:    call void 
@__ubsan_handle_return_alignment_assumption(ptr @[[GLOB2:[0-9]+]], i64 
[[TMP2]], i64 [[TMP3]], i64 [[ALIGNMENT]], i64 0) #[[ATTR3:[0-9]+]], 
!nosanitize [[META2]]
+// CHECK-SANITIZE-RECOVER-NEXT:    call void 
@__ubsan_handle_return_alignment_assumption(ptr @[[GLOB2:[0-9]+]], i64 
[[TMP2]], i64 [[TMP3]], i64 [[ALIGNMENT]], i64 0) #[[ATTR2:[0-9]+]], 
!nosanitize [[META2]]
 // CHECK-SANITIZE-RECOVER-NEXT:    br label [[CONT]], !nosanitize [[META2]]
 // CHECK-SANITIZE-RECOVER:       cont:
 // CHECK-SANITIZE-RECOVER-NEXT:    ret ptr [[TMP0]]
@@ -84,7 +84,7 @@ char **__attribute__((alloc_align(2)))
 // CHECK-SANITIZE-TRAP-NEXT:    [[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
 // CHECK-SANITIZE-TRAP-NEXT:    br i1 [[MASKCOND]], label [[CONT:%.*]], label 
[[TRAP:%.*]], !prof [[PROF1:![0-9]+]], !nosanitize [[META2:![0-9]+]]
 // CHECK-SANITIZE-TRAP:       trap:
-// CHECK-SANITIZE-TRAP-NEXT:    call void @llvm.ubsantrap(i8 25) 
#[[ATTR3:[0-9]+]], !nosanitize [[META2]]
+// CHECK-SANITIZE-TRAP-NEXT:    call void @llvm.ubsantrap(i8 25) 
#[[ATTR2:[0-9]+]], !nosanitize [[META2]]
 // CHECK-SANITIZE-TRAP-NEXT:    unreachable, !nosanitize [[META2]]
 // CHECK-SANITIZE-TRAP:       cont:
 // CHECK-SANITIZE-TRAP-NEXT:    ret ptr [[TMP0]]
@@ -99,7 +99,7 @@ passthrough(char **x, unsigned long alignment) {
 // CHECK-NOSANITIZE-NEXT:    [[X_ADDR:%.*]] = alloca ptr, align 8
 // CHECK-NOSANITIZE-NEXT:    store ptr [[X]], ptr [[X_ADDR]], align 8
 // CHECK-NOSANITIZE-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
-// CHECK-NOSANITIZE-NEXT:    [[CALL:%.*]] = call noundef align 128 ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 noundef 128)
+// CHECK-NOSANITIZE-NEXT:    [[CALL:%.*]] = call noundef align 128 ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 allocalign noundef 128)
 // CHECK-NOSANITIZE-NEXT:    ret ptr [[CALL]]
 //
 // CHECK-SANITIZE-NORECOVER-LABEL: define dso_local noundef ptr @_Z6callerPPc
@@ -108,17 +108,7 @@ passthrough(char **x, unsigned long alignment) {
 // CHECK-SANITIZE-NORECOVER-NEXT:    [[X_ADDR:%.*]] = alloca ptr, align 8
 // CHECK-SANITIZE-NORECOVER-NEXT:    store ptr [[X]], ptr [[X_ADDR]], align 8
 // CHECK-SANITIZE-NORECOVER-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], 
align 8
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[CALL:%.*]] = call noundef ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 noundef 128)
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[PTRINT:%.*]] = ptrtoint ptr [[CALL]] to 
i64
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 
127
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[MASKCOND:%.*]] = icmp eq i64 
[[MASKEDPTR]], 0
-// CHECK-SANITIZE-NORECOVER-NEXT:    br i1 [[MASKCOND]], label [[CONT:%.*]], 
label [[HANDLER_ALIGNMENT_ASSUMPTION:%.*]], !prof [[PROF1]], !nosanitize 
[[META2]]
-// CHECK-SANITIZE-NORECOVER:       handler.alignment_assumption:
-// CHECK-SANITIZE-NORECOVER-NEXT:    [[TMP1:%.*]] = ptrtoint ptr [[CALL]] to 
i64, !nosanitize [[META2]]
-// CHECK-SANITIZE-NORECOVER-NEXT:    call void 
@__ubsan_handle_alignment_assumption_abort(ptr @[[GLOB3:[0-9]+]], i64 [[TMP1]], 
i64 128, i64 0) #[[ATTR3]], !nosanitize [[META2]]
-// CHECK-SANITIZE-NORECOVER-NEXT:    unreachable, !nosanitize [[META2]]
-// CHECK-SANITIZE-NORECOVER:       cont:
-// CHECK-SANITIZE-NORECOVER-NEXT:    call void @llvm.assume(i1 true) [ 
"align"(ptr [[CALL]], i64 128) ]
+// CHECK-SANITIZE-NORECOVER-NEXT:    [[CALL:%.*]] = call noundef ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 allocalign noundef 128)
 // CHECK-SANITIZE-NORECOVER-NEXT:    ret ptr [[CALL]]
 //
 // CHECK-SANITIZE-RECOVER-LABEL: define dso_local noundef ptr @_Z6callerPPc
@@ -127,17 +117,7 @@ passthrough(char **x, unsigned long alignment) {
 // CHECK-SANITIZE-RECOVER-NEXT:    [[X_ADDR:%.*]] = alloca ptr, align 8
 // CHECK-SANITIZE-RECOVER-NEXT:    store ptr [[X]], ptr [[X_ADDR]], align 8
 // CHECK-SANITIZE-RECOVER-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], 
align 8
-// CHECK-SANITIZE-RECOVER-NEXT:    [[CALL:%.*]] = call noundef ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 noundef 128)
-// CHECK-SANITIZE-RECOVER-NEXT:    [[PTRINT:%.*]] = ptrtoint ptr [[CALL]] to 
i64
-// CHECK-SANITIZE-RECOVER-NEXT:    [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 127
-// CHECK-SANITIZE-RECOVER-NEXT:    [[MASKCOND:%.*]] = icmp eq i64 
[[MASKEDPTR]], 0
-// CHECK-SANITIZE-RECOVER-NEXT:    br i1 [[MASKCOND]], label [[CONT:%.*]], 
label [[HANDLER_ALIGNMENT_ASSUMPTION:%.*]], !prof [[PROF1]], !nosanitize 
[[META2]]
-// CHECK-SANITIZE-RECOVER:       handler.alignment_assumption:
-// CHECK-SANITIZE-RECOVER-NEXT:    [[TMP1:%.*]] = ptrtoint ptr [[CALL]] to 
i64, !nosanitize [[META2]]
-// CHECK-SANITIZE-RECOVER-NEXT:    call void 
@__ubsan_handle_alignment_assumption(ptr @[[GLOB3:[0-9]+]], i64 [[TMP1]], i64 
128, i64 0) #[[ATTR3]], !nosanitize [[META2]]
-// CHECK-SANITIZE-RECOVER-NEXT:    br label [[CONT]], !nosanitize [[META2]]
-// CHECK-SANITIZE-RECOVER:       cont:
-// CHECK-SANITIZE-RECOVER-NEXT:    call void @llvm.assume(i1 true) [ 
"align"(ptr [[CALL]], i64 128) ]
+// CHECK-SANITIZE-RECOVER-NEXT:    [[CALL:%.*]] = call noundef ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 allocalign noundef 128)
 // CHECK-SANITIZE-RECOVER-NEXT:    ret ptr [[CALL]]
 //
 // CHECK-SANITIZE-TRAP-LABEL: define dso_local noundef ptr @_Z6callerPPc
@@ -146,16 +126,7 @@ passthrough(char **x, unsigned long alignment) {
 // CHECK-SANITIZE-TRAP-NEXT:    [[X_ADDR:%.*]] = alloca ptr, align 8
 // CHECK-SANITIZE-TRAP-NEXT:    store ptr [[X]], ptr [[X_ADDR]], align 8
 // CHECK-SANITIZE-TRAP-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 
8
-// CHECK-SANITIZE-TRAP-NEXT:    [[CALL:%.*]] = call noundef ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 noundef 128)
-// CHECK-SANITIZE-TRAP-NEXT:    [[PTRINT:%.*]] = ptrtoint ptr [[CALL]] to i64
-// CHECK-SANITIZE-TRAP-NEXT:    [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 127
-// CHECK-SANITIZE-TRAP-NEXT:    [[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
-// CHECK-SANITIZE-TRAP-NEXT:    br i1 [[MASKCOND]], label [[CONT:%.*]], label 
[[TRAP:%.*]], !prof [[PROF1]], !nosanitize [[META2]]
-// CHECK-SANITIZE-TRAP:       trap:
-// CHECK-SANITIZE-TRAP-NEXT:    call void @llvm.ubsantrap(i8 23) #[[ATTR3]], 
!nosanitize [[META2]]
-// CHECK-SANITIZE-TRAP-NEXT:    unreachable, !nosanitize [[META2]]
-// CHECK-SANITIZE-TRAP:       cont:
-// CHECK-SANITIZE-TRAP-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr 
[[CALL]], i64 128) ]
+// CHECK-SANITIZE-TRAP-NEXT:    [[CALL:%.*]] = call noundef ptr 
@_Z11passthroughPPcm(ptr noundef [[TMP0]], i64 allocalign noundef 128)
 // CHECK-SANITIZE-TRAP-NEXT:    ret ptr [[CALL]]
 //
 char **caller(char **x) {
diff --git a/clang/test/CodeGen/non-power-of-2-alignment-assumptions.c 
b/clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
index a03ba08265e960..3edde63fe64cf9 100644
--- a/clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
+++ b/clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
@@ -8,9 +8,7 @@ void *__attribute__((alloc_align(1))) alloc(int align);
 // CHECK-NEXT:    [[ALIGN_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    store i32 [[ALIGN:%.*]], ptr [[ALIGN_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr [[ALIGN_ADDR]], align 4
-// CHECK-NEXT:    [[CALL:%.*]] = call ptr @alloc(i32 noundef [[TMP0]])
-// CHECK-NEXT:    [[CASTED_ALIGN:%.*]] = zext i32 [[TMP0]] to i64
-// CHECK-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr [[CALL]], i64 
[[CASTED_ALIGN]]) ]
+// CHECK-NEXT:    [[CALL:%.*]] = call ptr @alloc(i32 allocalign noundef 
[[TMP0]])
 // CHECK-NEXT:    ret void
 //
 void t0(int align) {
@@ -20,8 +18,7 @@ void t0(int align) {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    [[ALIGN_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    store i32 [[ALIGN:%.*]], ptr [[ALIGN_ADDR]], align 4
-// CHECK-NEXT:    [[CALL:%.*]] = call ptr @alloc(i32 noundef 7)
-// CHECK-NEXT:    call void @llvm.assume(i1 true) [ "align"(ptr [[CALL]], i64 
7) ]
+// CHECK-NEXT:    [[CALL:%.*]] = call ptr @alloc(i32 allocalign noundef 7)
 // CHECK-NEXT:    ret void
 //
 void t1(int align) {
@@ -31,7 +28,7 @@ void t1(int align) {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    [[ALIGN_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    store i32 [[ALIGN:%.*]], ptr [[ALIGN_ADDR]], align 4
-// CHECK-NEXT:    [[CALL:%.*]] = call align 8 ptr @alloc(i32 noundef 8)
+// CHECK-NEXT:    [[CALL:%.*]] = call align 8 ptr @alloc(i32 allocalign 
noundef 8)
 // CHECK-NEXT:    ret void
 //
 void t2(int align) {
diff --git a/clang/test/CodeGenCXX/align-avx-complete-objects.cpp 
b/clang/test/CodeGenCXX/align-avx-complete-objects.cpp
index 38b522b2e7e034..8b50a299faa079 100644
--- a/clang/test/CodeGenCXX/align-avx-complete-objects.cpp
+++ b/clang/test/CodeGenCXX/align-avx-complete-objects.cpp
@@ -17,7 +17,7 @@ float TestAlign(void)
 
 // CHECK: [[R:%.*]] = alloca <8 x float>, align 32
 // PRE17-NEXT:  [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm(i64 
noundef 32)
-// CXX17-NEXT:  [[CALL:%.*]] = call noalias noundef nonnull align 32 ptr 
@_ZnwmSt11align_val_t(i64 noundef 32, i64 noundef 32)
+// CXX17-NEXT:  [[CALL:%.*]] = call noalias noundef nonnull align 32 ptr 
@_ZnwmSt11align_val_t(i64 noundef 32, i64 allocalign noundef 32)
 // CHECK-NEXT:  store ptr [[CALL]], ptr [[P:%.*]], align 8
 // CHECK-NEXT:  [[ONE:%.*]] = load ptr, ptr [[P]], align 8
 // CHECK-NEXT:  [[TWO:%.*]] = load volatile <8 x float>, ptr [[ONE]], align 16
@@ -49,7 +49,7 @@ float TestAlign2(void)
 
 // CHECK: [[R:%.*]] = alloca <8 x float>, align 32
 // PRE17-NEXT:  [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm(i64 
noundef 32)
-// CXX17-NEXT:  [[CALL:%.*]] = call noalias noundef nonnull align 32 ptr 
@_ZnwmSt11align_val_t(i64 noundef 32, i64 noundef 32)
+// CXX17-NEXT:  [[CALL:%.*]] = call noalias noundef nonnull align 32 ptr 
@_ZnwmSt11align_val_t(i64 noundef 32, i64 allocalign noundef 32)
 // CHECK-NEXT:  store ptr [[CALL]], ptr [[P:%.*]], align 8
 // CHECK-NEXT:  [[ONE:%.*]] = load ptr, ptr [[P]], align 8
 // CHECK-NEXT:  [[TWO:%.*]] = load volatile <8 x float>, ptr [[ONE]], align 32
diff --git a/clang/test/CodeGenCXX/alloc-token.cpp 
b/clang/test/CodeGenCXX/alloc-token.cpp
index 98842206dfc000..057ca668c9dd3a 100644
--- a/clang/test/CodeGenCXX/alloc-token.cpp
+++ b/clang/test/CodeGenCXX/alloc-token.cpp
@@ -30,7 +30,7 @@ void *sink; // prevent optimizations from removing the calls
 // CHECK: call noalias ptr @calloc(i64 noundef 3, i64 noundef 4){{.*}} 
!alloc_token [[META_INT]]
 // CHECK: call noalias ptr @realloc(ptr noundef {{.*}}, i64 noundef 8){{.*}} 
!alloc_token [[META_LONG:![0-9]+]]
 // CHECK: call noalias ptr @reallocarray(ptr noundef {{.*}}, i64 noundef 5, 
i64 noundef 8), !alloc_token [[META_LONG]]
-// CHECK: call noalias align 128 ptr @aligned_alloc(i64 noundef 128, i64 
noundef 4){{.*}} !alloc_token [[META_INT]]
+// CHECK: call noalias align 128 ptr @aligned_alloc(i64 allocalign noundef 
128, i64 noundef 4){{.*}} !alloc_token [[META_INT]]
 // CHECK: call noalias ptr @memalign(i64 noundef 16, i64 noundef 4), 
!alloc_token [[META_INT]]
 // CHECK: call noalias ptr @valloc(i64 noundef 4), !alloc_token [[META_INT]]
 // CHECK: call noalias ptr @pvalloc(i64 noundef 4), !alloc_token [[META_INT]]
diff --git a/clang/test/CodeGenCXX/builtin-operator-new-delete.cpp 
b/clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
index a44926e43b5e22..870c8f323f5419 100644
--- a/clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
+++ b/clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
@@ -47,7 +47,7 @@ extern "C" void test_basic() {
 
 // CHECK-LABEL: define{{.*}} void @test_aligned_alloc(
 extern "C" void test_aligned_alloc() {
-  // CHECK: call noalias noundef nonnull align 4 ptr @_ZnwmSt11align_val_t(i64 
noundef 4, i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
+  // CHECK: call noalias noundef nonnull align 4 ptr @_ZnwmSt11align_val_t(i64 
noundef 4, i64 allocalign noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
   // CHECK: call void @_ZdlPvSt11align_val_t({{.*}}, i64 noundef 4) 
[[ATTR_BUILTIN_DELETE:#[^ ]*]]
   __builtin_operator_delete(__builtin_operator_new(4, std::align_val_t(4)), 
std::align_val_t(4));
 }
diff --git a/clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp 
b/clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
index 03f4920c4baebc..7ae03a6ad2c5a2 100644
--- a/clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
+++ b/clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
@@ -27,10 +27,10 @@ namespace std { enum class align_val_t : size_t {}; }
 struct OVERALIGNED A { A(); int n[128]; };
 
 // CHECK-LABEL: define {{.*}} @_Z2a0v()
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr 
@_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr 
@_ZnwmSt11align_val_t(i64 noundef 512, i64 allocalign noundef 32)
 // CHECK: call void @_ZdlPvSt11align_val_t(ptr allocptr noundef %[[ALLOC]], 
i64 noundef 32)
 // CHECK-MS-LABEL: define {{.*}} @"?a0@@YAPEAXXZ"()
-// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr 
@"??2@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef 512, i64 noundef 32)
+// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr 
@"??2@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef 512, i64 allocalign noundef 32)
 // CHECK-MS: cleanuppad
 // CHECK-MS: call void @"??3@YAXPEAXW4align_val_t@std@@@Z"(ptr allocptr 
noundef %[[ALLOC]], i64 noundef 32)
 void *a0() { return new A; }
@@ -39,13 +39,13 @@ void *a0() { return new A; }
 // The size is known.
 //
 // CHECK-LABEL: define {{.*}} @_Z2a1l(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr 
@_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr 
@_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 allocalign noundef 32)
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1AC1Ev(
 // CHECK: call void @_ZdaPvSt11align_val_t(ptr allocptr noundef %[[ALLOC]], 
i64 noundef 32)
 // CHECK-MS-LABEL: define {{.*}} @"?a1@@YAPEAXJ@Z"(
-// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr 
@"??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr 
@"??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef %{{.*}}, i64 allocalign 
noundef 32)
 // No array cookie.
 // CHECK-MS-NOT: store
 // CHECK-MS: invoke noundef ptr @"??0A@@QEAA@XZ"(
@@ -84,7 +84,7 @@ struct OVERALIGNED B {
 void *b0() { return new B; }
 
 // CHECK-LABEL: define {{.*}} @_Z2b1l(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr 
@_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 ptr 
@_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 allocalign noundef 32)
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1BC1Ev(
@@ -169,7 +169,7 @@ void *d0() { return new (q) D; }
 
 #ifndef UNALIGNED
 // CHECK-LABEL: define {{.*}} @_Z2e0v(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 4 ptr 
@_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 4)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 4 ptr 
@_ZnwmSt11align_val_t(i64 noundef 512, i64 allocalign noundef 4)
 // CHECK: call void @_ZdlPvSt11align_val_t(ptr allocptr noundef %[[ALLOC]], 
i64 noundef 4)
 void *e0() { return new (std::align_val_t(4)) A; }
 
diff --git a/clang/test/CodeGenCXX/new_hot_cold.cpp 
b/clang/test/CodeGenCXX/new_hot_cold.cpp
index fe76d6ae1971c8..ee07ab1c940893 100644
--- a/clang/test/CodeGenCXX/new_hot_cold.cpp
+++ b/clang/test/CodeGenCXX/new_hot_cold.cpp
@@ -87,36 +87,36 @@ class alignas(32) alignedstruct {
 };
 
 void hot_cold_new_align() {
-  // CHECK: call noalias noundef nonnull align 32 ptr 
@_ZnwmSt11align_val_t12__hot_cold_t(i64 noundef 1, i64 noundef 32, i8 noundef 
zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias noundef nonnull align 32 ptr 
@_ZnwmSt11align_val_t12__hot_cold_t(i64 noundef 1, i64 allocalign noundef 32, 
i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
   operator new(1, (std::align_val_t)32, (__hot_cold_t)0);
-  // CHECK: call noalias noundef nonnull align 32 ptr 
@_ZnwmSt11align_val_t12__hot_cold_t(i64 noundef 32, i64 noundef 32, i8 noundef 
zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias noundef nonnull align 32 ptr 
@_ZnwmSt11align_val_t12__hot_cold_t(i64 noundef 32, i64 allocalign noundef 32, 
i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
   new ((__hot_cold_t)0) alignedstruct;
 }
 
 // CHECK: declare noundef nonnull ptr @_ZnwmSt11align_val_t12__hot_cold_t(i64 
noundef, i64 noundef, i8 noundef) [[ATTR_NOBUILTIN:#[^ ]*]]
 
 void hot_cold_new_align_array() {
-  // CHECK: call noalias noundef nonnull align 32 ptr 
@_ZnamSt11align_val_t12__hot_cold_t(i64 noundef 1, i64 noundef 32, i8 noundef 
zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias noundef nonnull align 32 ptr 
@_ZnamSt11align_val_t12__hot_cold_t(i64 noundef 1, i64 allocalign noundef 32, 
i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
   operator new[](1, (std::align_val_t)32, (__hot_cold_t)0);
-  // CHECK: call noalias noundef nonnull align 32 ptr 
@_ZnamSt11align_val_t12__hot_cold_t(i64 noundef 32, i64 noundef 32, i8 noundef 
zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
+  // CHECK: call noalias noundef nonnull align 32 ptr 
@_ZnamSt11align_val_t12__hot_cold_t(i64 noundef 32, i64 allocalign noundef 32, 
i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
   new ((__hot_cold_t)0) alignedstruct[1];
 }
 
 // CHECK: declare noundef nonnull ptr @_ZnamSt11align_val_t12__hot_cold_t(i64 
noundef, i64 noundef, i8 noundef) [[ATTR_NOBUILTIN:#[^ ]*]]
 
 void hot_cold_new_align_nothrow() {
-  // CHECK: call noalias noundef align 32 ptr 
@_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef 1, i64 noundef 
32, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_NOTHROW_CALL:#[^ 
]*]]
+  // CHECK: call noalias noundef align 32 ptr 
@_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef 1, i64 allocalign 
noundef 32, {{.*}} @nothrow, i8 noundef zeroext 0) 
[[ATTR_NO_BUILTIN_NOTHROW_CALL:#[^ ]*]]
   operator new(1, (std::align_val_t)32, nothrow, (__hot_cold_t)0);
-  // CHECK: call noalias noundef align 32 ptr 
@_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef 32, i64 noundef 
32, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_BUILTIN_NOTHROW_CALL:#[^ ]*]]
+  // CHECK: call noalias noundef align 32 ptr 
@_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef 32, i64 
allocalign noundef 32, {{.*}} @nothrow, i8 noundef zeroext 0) 
[[ATTR_BUILTIN_NOTHROW_CALL:#[^ ]*]]
   new (nothrow, (__hot_cold_t)0) alignedstruct;
 }
 
 // CHECK: declare noundef ptr 
@_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef, i64 noundef, ptr 
noundef nonnull align 1 dereferenceable(1), i8 noundef) 
[[ATTR_NOBUILTIN_NOTHROW:#[^ ]*]]
 
 void hot_cold_new_align_nothrow_array() {
-  // CHECK: call noalias noundef align 32 ptr 
@_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef 1, i64 noundef 
32, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_NOTHROW_CALL:#[^ 
]*]]
+  // CHECK: call noalias noundef align 32 ptr 
@_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef 1, i64 allocalign 
noundef 32, {{.*}} @nothrow, i8 noundef zeroext 0) 
[[ATTR_NO_BUILTIN_NOTHROW_CALL:#[^ ]*]]
   operator new[](1, (std::align_val_t)32, nothrow, (__hot_cold_t)0);
-  // CHECK: call noalias noundef align 32 ptr 
@_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef 32, i64 noundef 
32, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_BUILTIN_NOTHROW_CALL:#[^ ]*]]
+  // CHECK: call noalias noundef align 32 ptr 
@_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef 32, i64 
allocalign noundef 32, {{.*}} @nothrow, i8 noundef zeroext 0) 
[[ATTR_BUILTIN_NOTHROW_CALL:#[^ ]*]]
   new (nothrow, (__hot_cold_t)0) alignedstruct[1];
 }
 
diff --git 
a/compiler-rt/test/ubsan/TestCases/Pointer/align-assume-attribute-alloc_align-on-function-variable.cpp
 
b/compiler-rt/test/ubsan/TestCases/Pointer/align-assume-attribute-alloc_align-on-function-variable.cpp
index 7cd6adbe28b698..8066b6e9402673 100644
--- 
a/compiler-rt/test/ubsan/TestCases/Pointer/align-assume-attribute-alloc_align-on-function-variable.cpp
+++ 
b/compiler-rt/test/ubsan/TestCases/Pointer/align-assume-attribute-alloc_align-on-function-variable.cpp
@@ -26,9 +26,6 @@ int main(int argc, char* argv[]) {
   // CHECK: {{.*}}align-assume-{{.*}}.cpp:[[@LINE-11]]:3: runtime error: 
assumption of 32768 byte alignment for pointer of type 'char *' failed
   // CHECK: {{.*}}align-assume-{{.*}}.cpp:[[@LINE-14]]:22: note: alignment 
assumption was specified here
   // CHECK: 0x{{.*}}: note: address is {{.*}} aligned, misalignment offset is 
{{.*}} byte
-  // CHECK: {{.*}}align-assume-{{.*}}.cpp:[[@LINE-4]]:3: runtime error: 
assumption of 32768 byte alignment for pointer of type 'char *' failed
-  // CHECK: {{.*}}align-assume-{{.*}}.cpp:[[@LINE-17]]:22: note: alignment 
assumption was specified here
-  // CHECK: 0x{{.*}}: note: address is {{.*}} aligned, misalignment offset is 
{{.*}} byte
 
   free(ptr);
 
diff --git 
a/compiler-rt/test/ubsan/TestCases/Pointer/align-assume-attribute-alloc_align-on-function.cpp
 
b/compiler-rt/test/ubsan/TestCases/Pointer/align-assume-attribute-alloc_align-on-function.cpp
index 59242da994e08d..4d25bb417d6120 100644
--- 
a/compiler-rt/test/ubsan/TestCases/Pointer/align-assume-attribute-alloc_align-on-function.cpp
+++ 
b/compiler-rt/test/ubsan/TestCases/Pointer/align-assume-attribute-alloc_align-on-function.cpp
@@ -22,9 +22,6 @@ int main(int argc, char* argv[]) {
   // CHECK: {{.*}}align-assume-{{.*}}.cpp:[[@LINE-7]]:3: runtime error: 
assumption of 32768 byte alignment for pointer of type 'char *' failed
   // CHECK: {{.*}}align-assume-{{.*}}.cpp:[[@LINE-10]]:22: note: alignment 
assumption was specified here
   // CHECK: 0x{{.*}}: note: address is {{.*}} aligned, misalignment offset is 
{{.*}} byte
-  // CHECK: {{.*}}align-assume-{{.*}}.cpp:[[@LINE-4]]:3: runtime error: 
assumption of 32768 byte alignment for pointer of type 'char *' failed
-  // CHECK: {{.*}}align-assume-{{.*}}.cpp:[[@LINE-13]]:22: note: alignment 
assumption was specified here
-  // CHECK: 0x{{.*}}: note: address is {{.*}} aligned, misalignment offset is 
{{.*}} byte
 
   free(ptr);
 

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

Reply via email to