Use the DataLayout-aware TargetFolder instead of ConstantFolder in Clang's CGBuilder. The primary impact of this change is that GEP constant expressions are now emitted in canonical `getelementptr i8` form. This is in preparation for the migration to ptradd, which requires this form. Part of the test updates were performed by Claude Code and reviewed by me.
21 lines
649 B
C++
21 lines
649 B
C++
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 3
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
|
|
|
|
struct S;
|
|
extern S a[10];
|
|
S(*b)[10] = &a;
|
|
struct S {
|
|
int x;
|
|
};
|
|
|
|
// The address calculation should be based on the size of the struct S
|
|
// declaration, not a dummy type like i8.
|
|
|
|
// CHECK-LABEL: define dso_local noundef i32 @_Z1fv(
|
|
// CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
|
|
// CHECK-NEXT: entry:
|
|
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr getelementptr inbounds nuw (i8, ptr @a, i64 12), align 4
|
|
// CHECK-NEXT: ret i32 [[TMP0]]
|
|
//
|
|
int f() { return a[3].x; }
|