1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
4 void *my_aligned_alloc(int size
, int alignment
) __attribute__((assume_aligned(32), alloc_align(2)));
6 // CHECK-LABEL: @t0_immediate0(
8 // CHECK-NEXT: [[CALL:%.*]] = call align 32 ptr @my_aligned_alloc(i32 noundef 320, i32 noundef 16)
9 // CHECK-NEXT: ret ptr [[CALL]]
11 void *t0_immediate0(void) {
12 return my_aligned_alloc(320, 16);
15 // CHECK-LABEL: @t1_immediate1(
17 // CHECK-NEXT: [[CALL:%.*]] = call align 32 ptr @my_aligned_alloc(i32 noundef 320, i32 noundef 32)
18 // CHECK-NEXT: ret ptr [[CALL]]
20 void *t1_immediate1(void) {
21 return my_aligned_alloc(320, 32);
24 // CHECK-LABEL: @t2_immediate2(
26 // CHECK-NEXT: [[CALL:%.*]] = call align 64 ptr @my_aligned_alloc(i32 noundef 320, i32 noundef 64)
27 // CHECK-NEXT: ret ptr [[CALL]]
29 void *t2_immediate2(void) {
30 return my_aligned_alloc(320, 64);
33 // CHECK-LABEL: @t3_variable(
35 // CHECK-NEXT: [[ALIGNMENT_ADDR:%.*]] = alloca i32, align 4
36 // CHECK-NEXT: store i32 [[ALIGNMENT:%.*]], ptr [[ALIGNMENT_ADDR]], align 4
37 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ALIGNMENT_ADDR]], align 4
38 // CHECK-NEXT: [[CALL:%.*]] = call align 32 ptr @my_aligned_alloc(i32 noundef 320, i32 noundef [[TMP0]])
39 // CHECK-NEXT: [[CASTED_ALIGN:%.*]] = zext i32 [[TMP0]] to i64
40 // CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[CALL]], i64 [[CASTED_ALIGN]]) ]
41 // CHECK-NEXT: ret ptr [[CALL]]
43 void *t3_variable(int alignment
) {
44 return my_aligned_alloc(320, alignment
);