llvm-project/llvm/lib/Transforms/Utils
Arthur Eubanks 5e71b9fa93 Explicitly pass type to cast load constant folding result
Previously we would use the type of the pointee to determine what to
cast the result of constant folding a load. To aid with opaque pointer
types, we should explicitly pass the type of the load rather than
looking at pointee types.

ConstantFoldLoadThroughBitcast() converts the const prop'd value to the
proper load type (e.g. [1 x i32] -> i32). Instead of calling this in
every intermediate step like bitcasts, we only call this when we
actually see the global initializer value.

In some existing uses of this API, we don't know the exact type we're
loading from immediately (e.g. first we visit a bitcast, then we visit
the load using the bitcast). In those cases we have to manually call
ConstantFoldLoadThroughBitcast() when simplifying the load to make sure
that we cast to the proper type.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D100718
2021-04-20 00:53:21 -07:00
..
AMDGPUEmitPrintf.cpp [OpaquePtrs] Remove some uses of type-less CreateLoad APIs (NFC) 2021-03-11 14:40:57 +01:00
ASanStackFrameLayout.cpp
AddDiscriminators.cpp
AssumeBundleBuilder.cpp Plumb AssumeInst through operand bundle apis [nfc] 2021-04-06 12:53:53 -07:00
AutoInitRemark.cpp [DebugInfo] Move the findDbg* functions into DebugInfo.cpp 2021-04-19 10:30:25 +01:00
BasicBlockUtils.cpp [NFCI][BasicBlockUtils] MergeBlockIntoPredecessor(): improve Dominator Tree updating 2021-04-11 23:56:23 +03:00
BreakCriticalEdges.cpp [SplitEdge] Update SplitCriticalEdge to return a nullptr only when the edge is not critical 2021-04-06 21:24:40 +00:00
BuildLibCalls.cpp [InferAttrs] Do not mark first argument of str(n)cat as writeonly. 2021-04-15 23:00:21 +01:00
BypassSlowDivision.cpp
CMakeLists.txt [SCCP] Create SCCP Solver 2021-04-14 14:58:03 +01:00
CallGraphUpdater.cpp [CGSCC][Coroutine][NewPM] Properly support function splitting/outlining 2021-01-06 11:19:15 -08:00
CallPromotionUtils.cpp [llvm] Construct SmallVector with iterator ranges (NFC) 2021-01-20 21:35:52 -08:00
CanonicalizeAliases.cpp
CanonicalizeFreezeInLoops.cpp [ValueTracking] Use assume's noundef operand bundle 2020-10-14 20:16:33 +09:00
CloneFunction.cpp [NFC] clang-format llvm/lib/Transforms/Utils/CloneFunction.cpp 2021-03-23 12:53:28 +00:00
CloneModule.cpp TransformUtils: Fix metadata handling in CloneModule (and improve CloneFunctionInto) 2021-02-15 11:56:00 -08:00
CodeExtractor.cpp Add a subclass of IntrinsicInst for llvm.assume [nfc] 2021-04-06 11:16:22 -07:00
CodeMoverUtils.cpp [CodeGen, Transforms] Use llvm::any_of (NFC) 2020-12-24 09:08:36 -08:00
CtorUtils.cpp
Debugify.cpp [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text 2021-04-06 07:23:31 -04:00
DemoteRegToStack.cpp
EntryExitInstrumenter.cpp [NFC][EntryExitInstrumenter] Mark Dominator Tree as preserved in legacy-PM too 2021-01-29 01:11:33 +03:00
EscapeEnumerator.cpp [ShadowStackGCLowering] Preserve Dominator Tree, if avaliable 2021-01-30 01:14:51 +03:00
Evaluator.cpp Explicitly pass type to cast load constant folding result 2021-04-20 00:53:21 -07:00
FixIrreducible.cpp [Transforms/Utils] Use range-based for loops (NFC) 2021-02-07 09:49:36 -08:00
FlattenCFG.cpp [NFC][AA] Prepare to convert AliasResult to class with PartialAlias offset. 2021-04-09 12:54:22 +03:00
FunctionComparator.cpp Fix use-of-uninitialized-value in rG75f50e15bf8f 2020-11-26 01:39:22 -07:00
FunctionImportUtils.cpp [LTO] Perform DSOLocal propagation in combined index 2021-02-12 22:58:26 -08:00
GlobalStatus.cpp [globalopt] Teach to look through `addrspacecast`. 2020-10-16 08:43:09 -04:00
GuardUtils.cpp [llvm] Construct SmallVector with iterator ranges (NFC) 2021-01-20 21:35:52 -08:00
HelloWorld.cpp [NewPM][HelloWorld] Move HelloWorld to Utils 2021-02-03 12:59:40 -08:00
InjectTLIMappings.cpp [NFC][Analysis] Change struct VecDesc to use ElementCount 2021-02-12 11:07:58 +00:00
InlineFunction.cpp [Inline] Don't add noalias metadata to inaccessiblememonly calls 2021-04-17 14:56:13 +02:00
InstructionNamer.cpp Port -instnamer to NPM 2020-10-22 12:08:36 -07:00
IntegerDivision.cpp
LCSSA.cpp [DebugInfo] Move the findDbg* functions into DebugInfo.cpp 2021-04-19 10:30:25 +01:00
LibCallsShrinkWrap.cpp
Local.cpp [DebugInfo] Move the findDbg* functions into DebugInfo.cpp 2021-04-19 10:30:25 +01:00
LoopPeel.cpp [NFC] One more use case for evaluatePredicate 2021-03-18 19:21:29 +07:00
LoopRotationUtils.cpp [DebugInfo] Move the findDbg* functions into DebugInfo.cpp 2021-04-19 10:30:25 +01:00
LoopSimplify.cpp [Transforms/Utils] Use range-based for loops (NFC) 2021-02-07 09:49:36 -08:00
LoopUnroll.cpp Add a subclass of IntrinsicInst for llvm.assume [nfc] 2021-04-06 11:16:22 -07:00
LoopUnrollAndJam.cpp [LoopUnrollAndJam] Avoid repeated instructions for UAJ analysis 2021-04-15 12:59:42 -04:00
LoopUnrollRuntime.cpp [LoopUnrollRuntime] Add option to assume the non latch exit block to be 2021-03-03 20:43:31 +00:00
LoopUtils.cpp Avoid unused variable warning in Release builds 2021-04-06 16:25:19 +02:00
LoopVersioning.cpp Revert "[LV] Unconditionally branch from middle to scalar preheader if the scalar loop must execute" 2021-02-05 12:51:03 +01:00
LowerInvoke.cpp [Transforms/Utils] Construct SmallVector with iterator ranges (NFC) 2020-12-29 19:23:23 -08:00
LowerMemIntrinsics.cpp
LowerSwitch.cpp [Transforms] Use llvm::erase_if (NFC) 2020-12-17 19:53:10 -08:00
MatrixUtils.cpp
Mem2Reg.cpp
MetaRenamer.cpp [Transforms/Utils] Use range-based for loops (NFC) 2021-02-07 09:49:36 -08:00
ModuleUtils.cpp Don't use $ as suffix for symbol names in ThinLTOBitcodeWriter and other places 2021-03-29 13:03:52 +02:00
NameAnonGlobals.cpp
PredicateInfo.cpp Revert of D49126 [PredicateInfo] Use custom mangling to support ssa_copy with unnamed types. 2021-03-20 11:37:09 +01:00
PromoteMemoryToRegister.cpp Add a subclass of IntrinsicInst for llvm.assume [nfc] 2021-04-06 11:16:22 -07:00
RelLookupTableConverter.cpp [Passes] Add relative lookup table converter pass 2021-04-13 01:29:41 +00:00
SCCPSolver.cpp [SCCP] Follow up of rGbbab9f986c6d. NFC. 2021-04-14 17:14:46 +01:00
SSAUpdater.cpp [Transforms/Utils] Use range-based for loops (NFC) 2021-02-02 22:52:47 -08:00
SSAUpdaterBulk.cpp
SampleProfileLoaderBaseUtil.cpp [SampleFDO] Third Try: Refactor SampleProfile.cpp 2021-02-17 15:31:50 -08:00
SanitizerStats.cpp
ScalarEvolutionExpander.cpp [SCEVExpander] ReuseOrCreateCast(): use IRBuilder to actually create the cast 2021-04-19 18:38:39 +03:00
SimplifyCFG.cpp [SimplifyCFG] Skip dbg intrinsics when checking for branch-only BBs. 2021-04-17 15:17:50 +01:00
SimplifyIndVar.cpp [IndVars] Sharpen context in eliminateIVComparison 2021-03-22 11:55:57 +07:00
SimplifyLibCalls.cpp Reland "Revert "[InstCombine] when calling conventions are compatible, don't convert the call to undef idiom"" 2021-04-12 14:50:54 -07:00
SizeOpts.cpp
SplitModule.cpp [LTO] Update splitCodeGen to take a reference to the module. (NFC) 2021-01-29 11:53:11 +00:00
StripGCRelocates.cpp Port StripGCRelocates pass to NPM 2020-10-07 14:41:29 -07:00
StripNonLineTableDebugInfo.cpp [NPM] Port strip nonlinetable debuginfo pass to the new pass manager 2020-10-07 14:35:36 -07:00
SymbolRewriter.cpp
UnifyFunctionExitNodes.cpp [NPM] Port -mergereturn to NPM 2020-10-20 10:33:58 -07:00
UnifyLoopExits.cpp Remove unnecessary header include which violates layering 2020-10-20 20:14:03 -07:00
Utils.cpp Revert "[Passes] Add relative lookup table converter pass" 2021-03-30 14:13:37 +02:00
VNCoercion.cpp [GVN][NFC] Refactor analyzeLoadFromClobberingWrite 2021-04-01 08:35:35 +08:00
ValueMapper.cpp Reapply "OpaquePtr: Turn inalloca into a type attribute" 2021-03-29 08:55:30 -04:00