Files
Sayan Sivakumaran 947dc92d1a [Clang][CodeGen] Emit alignment information for indirect arguments (#201999)
Previously, arguments with `ABIArgInfo::Indirect` would not be given
alignment information if it wasn't `byval`. This could prevent certain
optimizations, such as those guarded by
`isDereferenceableAndAlignedPointer` checks. The missing
dereferenceability information is pointed out in
https://github.com/llvm/llvm-project/issues/129337, for example.

This PR will fix the first half of this problem, which is emitting
alignment information. Dereferenceability information will be added in a
subsequent PR.
2026-07-02 09:35:24 -07:00

30 lines
592 B
C++

// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
struct Foo {
Foo();
Foo(const Foo&);
};
struct Bar {
Bar();
operator const Foo&() const;
};
void f(Foo);
// CHECK-LABEL: define{{.*}} void @_Z1g3Foo(ptr noundef align 1 dead_on_return %foo)
void g(Foo foo) {
// CHECK: call void @_ZN3BarC1Ev
// CHECK: @_ZNK3BarcvRK3FooEv
// CHECK: call void @_Z1f3Foo
f(Bar());
// CHECK: call void @_ZN3FooC1Ev
// CHECK: call void @_Z1f3Foo
f(Foo());
// CHECK: call void @_ZN3FooC1ERKS_
// CHECK: call void @_Z1f3Foo
f(foo);
// CHECK: ret
}