[llvm] 3d5cf0d - Revert "[InstSimplify] Fold all global variables with initializers"
Alan Zhao via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 14 14:11:20 PDT 2023
Author: Alan Zhao
Date: 2023-06-14T14:10:31-07:00
New Revision: 3d5cf0df4f5a54ff4aeee69f4bb80b8e079c9f23
URL: https://github.com/llvm/llvm-project/commit/3d5cf0df4f5a54ff4aeee69f4bb80b8e079c9f23
DIFF: https://github.com/llvm/llvm-project/commit/3d5cf0df4f5a54ff4aeee69f4bb80b8e079c9f23.diff
LOG: Revert "[InstSimplify] Fold all global variables with initializers"
This reverts commit 17b7df3daee85c1a4d1d955e558d42b34ce17549.
Reason: causes chrome builds to crash: https://crbug.com/1454861
Added:
Modified:
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll
Removed:
llvm/test/Transforms/InstSimplify/gv-alloca-cmp.ll
################################################################################
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index 25fef925d78c1..6ff7aed0288a4 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -826,9 +826,7 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitGlobalAlias(GlobalAlias &GA) {
}
SizeOffsetType ObjectSizeOffsetVisitor::visitGlobalVariable(GlobalVariable &GV){
- if (GV.hasExternalWeakLinkage() ||
- ((!GV.hasInitializer() || GV.isInterposable()) &&
- Options.EvalMode != ObjectSizeOpts::Mode::Min))
+ if (!GV.hasDefinitiveInitializer())
return unknown();
APInt Size(IntTyBits, DL.getTypeAllocSize(GV.getValueType()));
diff --git a/llvm/test/Transforms/InstSimplify/gv-alloca-cmp.ll b/llvm/test/Transforms/InstSimplify/gv-alloca-cmp.ll
deleted file mode 100644
index 2bb04c2e594ec..0000000000000
--- a/llvm/test/Transforms/InstSimplify/gv-alloca-cmp.ll
+++ /dev/null
@@ -1,46 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
-; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
-
- at gv = global i64 zeroinitializer, align 16
-
-define i1 @cmp_gv_alloca() {
-; CHECK-LABEL: define i1 @cmp_gv_alloca() {
-; CHECK-NEXT: ret i1 false
-;
- %alloca = alloca i64, align 8
- %cmp = icmp eq ptr %alloca, @gv
- ret i1 %cmp
-}
-
- at gv_externally_init = externally_initialized global i64 zeroinitializer, align 16
-
-define i1 @cmp_gv_alloca_extern_init() {
-; CHECK-LABEL: define i1 @cmp_gv_alloca_extern_init() {
-; CHECK-NEXT: ret i1 false
-;
- %alloca = alloca i64, align 8
- %cmp = icmp eq ptr %alloca, @gv_externally_init
- ret i1 %cmp
-}
-
- at const_gv = protected addrspace(4) externally_initialized global [4096 x i64] zeroinitializer, align 16
-define i1 @cmp_gv_alloca_cast() {
-; CHECK-LABEL: define i1 @cmp_gv_alloca_cast() {
-; CHECK-NEXT: ret i1 false
-;
- %alloca = alloca i64, align 8, addrspace(5)
- %cast.alloca = addrspacecast ptr addrspace(5) %alloca to ptr
- %cmp = icmp eq ptr %cast.alloca, addrspacecast (ptr addrspace(4) @const_gv to ptr)
- ret i1 %cmp
-}
-
- at gv_weak = weak global i64 zeroinitializer, align 16
-
-define i1 @cmp_gv_weak_alloca() {
-; CHECK-LABEL: define i1 @cmp_gv_weak_alloca() {
-; CHECK-NEXT: ret i1 false
-;
- %alloca = alloca i64, align 8
- %cmp = icmp eq ptr %alloca, @gv_weak
- ret i1 %cmp
-}
diff --git a/llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll b/llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll
index c90d5152e1a09..52f4cbb212c32 100644
--- a/llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll
+++ b/llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll
@@ -146,41 +146,3 @@ define i64 @test_objectsize_malloc() {
%objsize = call i64 @llvm.objectsize.i64(ptr %ptr, i1 false, i1 true, i1 true)
ret i64 %objsize
}
-
- at gv_weak = weak global i64 zeroinitializer, align 16
-
-define i32 @promote_with_objectsize_min_false() {
-; CHECK-LABEL: @promote_with_objectsize_min_false(
-; CHECK-NEXT: ret i32 -1
-;
- %size = call i32 @llvm.objectsize.i32.p0(ptr @gv_weak, i1 false, i1 false, i1 false)
- ret i32 %size
-}
-
-define i32 @promote_with_objectsize_min_true() {
-; CHECK-LABEL: @promote_with_objectsize_min_true(
-; CHECK-NEXT: ret i32 8
-;
- %size = call i32 @llvm.objectsize.i32.p0(ptr @gv_weak, i1 true, i1 false, i1 false)
- ret i32 %size
-}
-
- at gv_extern = extern_weak global i64, align 16
-
-define i32 @promote_with_objectsize_nullunknown_false() {
-; CHECK-LABEL: @promote_with_objectsize_nullunknown_false(
-; CHECK-NEXT: ret i32 0
-;
- %size = call i32 @llvm.objectsize.i32.p0(ptr @gv_extern, i1 true, i1 false, i1 false)
- ret i32 %size
-}
-
-define i32 @promote_with_objectsize_nullunknown_true() {
-; CHECK-LABEL: @promote_with_objectsize_nullunknown_true(
-; CHECK-NEXT: ret i32 0
-;
- %size = call i32 @llvm.objectsize.i32.p0(ptr @gv_extern, i1 true, i1 true, i1 false)
- ret i32 %size
-}
-
-declare i32 @llvm.objectsize.i32.p0(ptr, i1, i1, i1)
More information about the llvm-commits
mailing list