Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/Analysis/MemoryBuiltins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,8 @@ OffsetSpan ObjectSizeOffsetVisitor::visitGlobalAlias(GlobalAlias &GA) {
OffsetSpan ObjectSizeOffsetVisitor::visitGlobalVariable(GlobalVariable &GV) {
if (!GV.getValueType()->isSized() || GV.hasExternalWeakLinkage() ||
((!GV.hasInitializer() || GV.isInterposable()) &&
Options.EvalMode != ObjectSizeOpts::Mode::Min))
Options.EvalMode != ObjectSizeOpts::Mode::Min) ||
!isUIntN(IntTyBits, GV.getGlobalSize(DL)))
return ObjectSizeOffsetVisitor::unknown();

APInt Size(IntTyBits, GV.getGlobalSize(DL));
Expand Down
21 changes: 21 additions & 0 deletions llvm/test/Transforms/DeadStoreElimination/large-global-var.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes=dse -S | FileCheck %s

target datalayout = "e-m:e-p:32:32-i8:8-i32:32-i64:64"

; The data-layout only allows 32-bit indexing, but the array is too large to be
; fully accessible through that index-space.
@G = internal global [39969271929 x i32] zeroinitializer, align 4

define void @func() {
; CHECK-LABEL: define void @func() {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: store i32 0, ptr getelementptr (i8, ptr @G, i64 24), align 4
; CHECK-NEXT: store i32 0, ptr getelementptr (i8, ptr @G, i64 20), align 4
; CHECK-NEXT: ret void
;
entry:
store i32 0, ptr getelementptr (i8, ptr @G, i64 24), align 4
store i32 0, ptr getelementptr (i8, ptr @G, i64 20), align 4
ret void
}