https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/93697
>From 8a6462df3f329aa939db4c8bff87bd57bb0d6445 Mon Sep 17 00:00:00 2001
From: Nikita Popov
Date: Tue, 28 May 2024 13:47:05 +0200
Subject: [PATCH 1/3] [ConstantFold] Remove notional over-indexing fold
The data-layout independent constant folding currently has some
rather gnarly code for canonicalizing GEP indices to reduce
"notional overindexing", and then infers inbounds based on that
canonicalization.
Now that we canonicalize to i8 GEPs, this canonicalization is
essentially useless, as we'll discard it as soon as the GEP
hits the data-layout aware constant folder anyway. As such, I'd
like to remove this code entirely.
This shouldn't have any impact on optimization capabilities.
---
clang/test/CodeGen/object-size.c | 2 +-
...initializer-stdinitializerlist-pr12086.cpp | 8 +-
clang/test/CodeGenHLSL/cbuf.hlsl | 4 +-
clang/test/Driver/linker-wrapper-image.c | 2 +-
llvm/lib/IR/ConstantFold.cpp | 196 --
llvm/test/Assembler/ConstantExprFold.ll | 4 +-
llvm/test/Assembler/getelementptr.ll | 15 +-
llvm/test/Assembler/getelementptr_vec_ce.ll | 2 +-
llvm/test/CodeGen/AMDGPU/opencl-printf.ll | 8 +-
llvm/test/Linker/comdat-largest.ll| 2 +-
.../gather-scatter-opt-inseltpoison.ll| 2 +-
.../AArch64/gather-scatter-opt.ll | 2 +-
.../X86/gather-scatter-opt-inseltpoison.ll| 2 +-
.../CodeGenPrepare/X86/gather-scatter-opt.ll | 2 +-
.../GlobalOpt/globalsra-opaque-ptr.ll | 10 +-
llvm/test/Transforms/GlobalSplit/basic.ll | 4 +-
.../AMDGPU/infer-address-space.ll | 2 +-
.../AMDGPU/infer-getelementptr.ll | 8 +-
.../old-pass-regressions-inseltpoison.ll | 2 +-
.../AMDGPU/old-pass-regressions.ll| 2 +-
.../InferAddressSpaces/NVPTX/bug31948.ll | 4 +-
.../Transforms/InferAlignment/gep-array.ll| 8 +-
.../test/Transforms/InstCombine/gep-vector.ll | 6 +-
.../InstSimplify/ConstProp/vectorgep-crash.ll | 2 +-
.../Transforms/InstSimplify/vector_gep.ll | 2 +-
.../NewGVN/2007-07-26-InterlockingLoops.ll| 2 +-
26 files changed, 51 insertions(+), 252 deletions(-)
diff --git a/clang/test/CodeGen/object-size.c b/clang/test/CodeGen/object-size.c
index b39b15fcc65b9..58561a5470f72 100644
--- a/clang/test/CodeGen/object-size.c
+++ b/clang/test/CodeGen/object-size.c
@@ -34,7 +34,7 @@ void test2(void) {
// CHECK-LABEL: define{{.*}} void @test3
void test3(void) {
- // CHECK: = call ptr @__strcpy_chk(ptr getelementptr inbounds ([63 x
i8], ptr @gbuf, i64 1, i64 37), ptr @.str, i64 0)
+ // CHECK: = call ptr @__strcpy_chk(ptr getelementptr inbounds ([63 x
i8], ptr @gbuf, i64 0, i64 100), ptr @.str, i64 0)
strcpy(&gbuf[100], "Hi there");
}
diff --git
a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
index c15a6183d15df..6fbe4c7fd17a7 100644
--- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
@@ -112,21 +112,21 @@ std::initializer_list> nested
= {
// CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr
@_ZGR6nested0_, i64 1)
// CHECK-DYNAMIC-BE: store ptr @_ZGR6nested0_,
// CHECK-DYNAMIC-BE: ptr @_ZGR6nested_, align 8
-// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr
@_ZGR6nested0_, i64 1, i64 0),
+// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr
@_ZGR6nested0_, i64 0, i64 2),
// CHECK-DYNAMIC-BE: ptr getelementptr inbounds ({{.*}}, ptr
@_ZGR6nested_, i32 0, i32 1), align 8
// CHECK-DYNAMIC-BE: store i32 3, ptr @_ZGR6nested1_
// CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr
@_ZGR6nested1_, i64 1)
// CHECK-DYNAMIC-BE: store ptr @_ZGR6nested1_,
// CHECK-DYNAMIC-BE: ptr getelementptr inbounds ({{.*}}, ptr
@_ZGR6nested_, i64 1), align 8
-// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr
@_ZGR6nested1_, i64 1, i64 0),
+// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr
@_ZGR6nested1_, i64 0, i64 2),
// CHECK-DYNAMIC-BE: ptr getelementptr inbounds ({{.*}}, ptr
@_ZGR6nested_, i64 1, i32 1), align 8
// CHECK-DYNAMIC-BE: store i32 5, ptr @_ZGR6nested2_
// CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr
@_ZGR6nested2_, i64 1)
// CHECK-DYNAMIC-BE: store ptr @_ZGR6nested2_,
// CHECK-DYNAMIC-BE: ptr getelementptr inbounds ({{.*}}, ptr
@_ZGR6nested_, i64 2), align 8
-// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr
@_ZGR6nested2_, i64 1, i64 0),
+// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr
@_ZGR6nested2_, i64 0, i64 2),
// CHECK-DYNAMIC-BE: ptr getelement