llvm-project/llvm/test/Transforms/GlobalOpt
Nikita Popov f65c88c42f [GlobalOpt] Fix memset handling in global ctor evaluation (PR55859)
The global ctor evaluator currently handles by checking whether the
memset memory is already zero, and skips it in that case. However,
it only actually checks the first byte of the memory being set.

This patch extends the code to check all bytes being set. This is
done byte-by-byte to avoid converting undef values to zeros in
larger reads. However, the handling is still not completely correct,
because there might still be padding bytes (though probably this
doesn't matter much in practice, as I'd expect global variable
padding to be zero-initialized in practice).

Mostly fixes https://github.com/llvm/llvm-project/issues/55859.

Differential Revision: https://reviews.llvm.org/D128532
2022-06-27 16:50:49 +02:00
..
PowerPC [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2004-10-10-CastStoreOnce.ll
2005-06-15-LocalizeConstExprCrash.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2005-09-27-Crash.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2006-07-07-InlineAsmCrash.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2006-11-01-ShrinkGlobalPhiCrash.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2007-04-05-Crash.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2007-05-13-Crash.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2007-06-04-PackedStruct.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2007-11-09-GEP-GEP-Crash.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2008-01-03-Crash.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2008-01-13-OutOfRangeSROA.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2008-01-29-VolatileGlobal.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2008-04-26-SROA-Global-Align.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2008-07-17-addrspace.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2008-12-16-HeapSRACrash-2.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2008-12-16-HeapSRACrash.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2009-01-13-phi-user.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2009-02-15-BitcastAlias.ll
2009-02-15-ResolveAlias.ll [GlobalOpt] Don't replace alias with aliasee if either alias/aliasee may be preemptible 2022-03-18 14:17:05 -07:00
2009-03-05-dbg.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2009-03-06-Anonymous.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2009-03-07-PromotePtrToBool.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2009-06-01-RecursivePHI.ll [GlobalOpt][test] Remove br i1 undef 2022-06-10 20:36:22 -07:00
2009-11-16-BrokenPerformHeapAllocSRoA.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2009-11-16-MallocSingleStoreToGlobalVar.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2010-02-25-MallocPromote.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2010-02-26-MallocSROA.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2010-10-19-WeakOdr.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2011-04-09-EmptyGlobalCtors.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2012-05-11-blockaddress.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2021-08-02-CastStoreOnceP2I.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
2021-08-03-StoreOnceLoadMultiCasts.ll [GlobalOpt] Use generic type when converting malloc to global 2022-01-17 09:55:33 +01:00
GSROA-section.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
MallocSROA-section-no-null-opt.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
MallocSROA-section.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
SROA-section.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
address_space_initializer.ll [GlobalOpt] Simplify CleanupConstantGlobalUsers() 2021-12-01 21:06:25 +01:00
alias-resolve.ll [GlobalOpt] Don't replace alias with aliasee if either alias/aliasee may be preemptible 2022-03-18 14:17:05 -07:00
alias-used-address-space.ll [GlobalOpt] Don't replace alias with aliasee if either alias/aliasee may be preemptible 2022-03-18 14:17:05 -07:00
alias-used-section.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
alias-used.ll [GlobalOpt] Don't replace alias with aliasee if either alias/aliasee may be preemptible 2022-03-18 14:17:05 -07:00
amdgcn-ctor-alloca.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
analysis-invalidation.ll Reland [GlobalOpt] Preserve CFG analyses 2022-06-21 09:19:59 -07:00
array-elem-refs.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
assume.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
atexit.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
atomic.ll [GlobalOpt] Simplify CleanupConstantGlobalUsers() 2021-12-01 21:06:25 +01:00
available_externally_global_ctors.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
basictest.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
blockaddress.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
calloc-promote.ll [GlobalOpt] Generalize malloc-to-global for any allocation function 2022-01-17 15:06:23 -08:00
cleanup-pointer-root-users.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
coldcc_stress_test.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
compiler-used.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
const-return-status-atomic.ll [GlobalOpt] Simplify CleanupConstantGlobalUsers() 2021-12-01 21:06:25 +01:00
const-return-status.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
constant-can-trap.ll [GlobalOpt] don't hoist constant expressions that can trap 2021-08-27 08:10:20 -04:00
constantexpr-dangle.ll
constantfold-initializers.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
crash-2.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
crash.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
ctor-list-opt-constexpr.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
ctor-list-opt-inbounds.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
ctor-list-opt.ll [GlobalOpt] Enable optimization of constructors with different priorities 2022-05-13 22:19:29 +00:00
ctor-memset.ll [GlobalOpt] Fix memset handling in global ctor evaluation (PR55859) 2022-06-27 16:50:49 +02:00
cxx-dtor.ll
dead-constant-user.ll [GlobalStatus] Skip non-pointer dead constant users 2022-02-01 15:51:32 +01:00
dead-store-status.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
deaddeclaration.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
deadfunction.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
deadglobal-2.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
deadglobal-diarglist-use.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
deadglobal.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
evaluate-bitcast-2.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
evaluate-bitcast-3.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
evaluate-bitcast-4.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
evaluate-bitcast.ll
evaluate-call-errors.ll
evaluate-call.ll
evaluate-constfold-call.ll
evaluate-load-uniform.ll [ConstantFold] Check uniform value in ConstantFoldLoadFromConst() 2022-01-13 14:40:19 +01:00
externally-initialized-aggregate.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
externally-initialized-global-ctr.ll [GlobalOpt] Make global SRA offset based 2022-01-17 09:28:36 +01:00
externally-initialized.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
fastcc.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
global-constructor-opaque-ptr.ll [OpaquePtr][GlobalOpt] Don't attempt to evaluate global constructors with arguments 2022-04-27 19:00:44 -07:00
global-demotion.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
globalsra-align.ll [GlobalOpt] Make global SRA offset based 2022-01-17 09:28:36 +01:00
globalsra-generic-type.ll [GlobalOpt] Make global SRA offset based 2022-01-17 09:28:36 +01:00
globalsra-multigep.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
globalsra-opaque-ptr.ll [GlobalOpt] Make global SRA offset based 2022-01-17 09:28:36 +01:00
globalsra-partial.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
globalsra-recursive.ll [GlobalOpt] Make global SRA offset based 2022-01-17 09:28:36 +01:00
globalsra-unknown-index.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
globalsra.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
heap-sra-1-no-null-opt.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
heap-sra-1.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
heap-sra-2-no-null-opt.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
heap-sra-2.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
heap-sra-phi-no-null-opt.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
heap-sra-phi.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
int_sideeffect.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
integer-bool-dwarf.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
integer-bool.ll
invariant-nodatalayout.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
invariant.group.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
invariant.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
invoke.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
iterate.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
large-element-size.ll [IR] Handle large element size when calculating GEP indices 2021-09-24 22:20:20 +02:00
large-int-crash.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
load-store-global-no-null-opt.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
load-store-global.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
localize-constexpr-debuginfo.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
localize-constexpr.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
long-compilation-global-sra.ll [opt] Directly translate -O# to -passes='default<O#>' 2021-10-18 16:48:10 -07:00
malloc-promote-1-no-null-opt.ll Revert "[GlobalOpt] Perform store->dominated load forwarding for stored once globals" 2022-06-20 10:26:47 -07:00
malloc-promote-1.ll [test][GlobalOpt] Regenerate some tests 2022-06-18 21:34:38 -07:00
malloc-promote-2-no-null-opt.ll Revert "[GlobalOpt] Perform store->dominated load forwarding for stored once globals" 2022-06-20 10:26:47 -07:00
malloc-promote-2.ll [test][GlobalOpt] Regenerate some tests 2022-06-18 21:34:38 -07:00
malloc-promote-3.ll Revert "[GlobalOpt] Perform store->dominated load forwarding for stored once globals" 2022-06-20 10:26:47 -07:00
malloc-promote-4.ll [test][GlobalOpt] Regenerate some tests 2022-06-18 21:34:38 -07:00
malloc-promote-5.ll [test][GlobalOpt] Regenerate some tests 2022-06-18 21:34:38 -07:00
malloc-promote-6.ll [GlobalOpt] Iterate over replaced values deterministically to constprop 2022-05-02 09:43:20 -07:00
malloc-promote-opaque-ptr.ll [GlobalOpt] Use generic type when converting malloc to global 2022-01-17 09:55:33 +01:00
memcpy.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
memset-null.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
memset.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
metadata.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
musttail_cc.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
naked_functions.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
new-promote.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
null-check-global-value.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
null-check-is-use-pr35760.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
null-check-not-use-pr35760.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
phi-select.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
pr21191.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
pr33686.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
pr39751.ll [GlobalOpt] Add test for PR39751 (NFC) 2021-12-02 09:17:33 +01:00
pr51879.ll [GlobalOpt][Evaluator] Rewrite global ctor evaluation (fixes PR51879) 2022-01-04 09:30:54 +01:00
pr52994.ll [GlobalOpt][Evaluator] Don't create bitcast for same type (PR52994) 2022-01-05 09:17:07 +01:00
pr53002.ll [GlobalOpt][Evaluator] Fix off by one error in bounds check (PR53002) 2022-01-05 14:06:02 +01:00
pr54572.ll [GlobalOpt] Handle non-instruction MTI source (PR54572) 2022-03-28 14:28:47 +02:00
preallocated.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
preserve-comdats.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
recursively-delete-dead-inst-assertion.ll [GlobalOpt] Fix assertion failure during instruction deletion 2021-12-02 11:58:39 +01:00
shrink-address-to-bool.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
shrink-global-to-bool-check-debug.ll [GlobalOpt] Perform store->dominated load forwarding for stored once globals 2022-06-24 09:09:26 -07:00
shrink-global-to-bool-opaque-ptrs.ll [GlobalOpt] Fix global to select transform under opaque pointers 2022-01-13 11:13:06 +01:00
shrink-global-to-bool.ll [GlobalOpt] Perform store->dominated load forwarding for stored once globals 2022-06-24 09:09:26 -07:00
static-const-bitcast.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
store-struct-element.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
stored-once-different-type.ll [GlobalOpt] Support "stored once" optimization for different types 2022-01-12 09:39:31 +01:00
stored-once-forward-value.ll [GlobalOpt] Perform store->dominated load forwarding for stored once globals 2022-06-24 09:09:26 -07:00
stored-once-through-gep.ll [GlobalStatus] Look through non-constexpr casts 2022-01-11 16:02:35 +01:00
stored-once-value-type.ll [GlobalOpt] Support "stored once" optimization for different types 2022-01-12 09:39:31 +01:00
storepointer-compare-no-null-opt.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
storepointer-compare.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
storepointer-no-null-opt.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
storepointer.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
tls.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
trivialstore.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
undef-ctor-dtor.ll [GlobalOpt] Handle undef global_ctors gracefully 2022-03-10 16:02:12 +01:00
undef-init.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
unnamed-addr.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00
x86_mmx_load.ll [ConstantFold][GlobalOpt] Don't create x86_mmx null value 2021-12-21 09:11:41 +01:00
zeroinitializer-gep-load.ll [test] Use -passes syntax when specifying pipeline in some more tests 2021-11-27 09:52:55 +01:00