llvm-project/llvm/lib/Transforms/Utils
Vedant Kumar a1778df474 [CodeExtractor] Do not extract unsafe lifetime markers
Lifetime markers which reference inputs to the extraction region are not
safe to extract. Example ('rhs' will be extracted):

```
               entry:
              +------------+
              | x = alloca |
              | y = alloca |
              +------------+
             /              \
   lhs:                      rhs:
  +-------------------+     +-------------------+
  | lifetime_start(x) |     | lifetime_start(x) |
  | use(x)            |     | lifetime_start(y) |
  | lifetime_end(x)   |     | use(x, y)         |
  | lifetime_start(y) |     | lifetime_end(y)   |
  | use(y)            |     | lifetime_end(x)   |
  | lifetime_end(y)   |     +-------------------+
  +-------------------+
```

Prior to extraction, the stack coloring pass sees that the slots for 'x'
and 'y' are in-use at the same time. After extraction, the coloring pass
infers that 'x' and 'y' are *not* in-use concurrently, because markers
from 'rhs' are no longer available to help decide otherwise.

This leads to a miscompile, because the stack slots actually are in-use
concurrently in the extracted function.

Fix this by moving lifetime start/end markers for memory regions defined
in the calling function around the call to the extracted function.

Fixes llvm.org/PR39671 (rdar://45939472).

Differential Revision: https://reviews.llvm.org/D55967

llvm-svn: 350420
2019-01-04 17:43:22 +00:00
..
ASanStackFrameLayout.cpp
AddDiscriminators.cpp [llvm] API for encoding/decoding DWARF discriminators. 2018-12-21 22:48:50 +00:00
BasicBlockUtils.cpp [TI removal] Remove `TerminatorInst` from BasicBlockUtils.h 2018-10-15 09:34:05 +00:00
BreakCriticalEdges.cpp [TI removal] Make variables declared as `TerminatorInst` and initialized 2018-10-15 10:04:59 +00:00
BuildLibCalls.cpp Add a emitUnaryFloatFnCall version that fetches the function name from TLI 2018-10-18 06:27:53 +00:00
BypassSlowDivision.cpp [BypassSlowDivision] Teach bypass slow division not to interfere with div by constant where constants have been constant hoisted, but not moved from their basic block 2018-08-21 17:15:33 +00:00
CMakeLists.txt [NFC] Move OrderedInstructions and InstructionPrecedenceTracking to Analysis 2018-08-30 04:49:03 +00:00
CallPromotionUtils.cpp [ICP] Remove incompatible attributes at indirect-call promoted callsites. 2018-11-26 22:03:52 +00:00
CloneFunction.cpp [CSP, Cloning] Update DuplicateInstructionsInSplitBetween to use DomTreeUpdater. 2018-11-13 17:54:43 +00:00
CloneModule.cpp Allow creating llvm::Function in non-zero address spaces 2018-08-23 09:25:17 +00:00
CodeExtractor.cpp [CodeExtractor] Do not extract unsafe lifetime markers 2019-01-04 17:43:22 +00:00
CtorUtils.cpp [Transforms] Prefer static and avoid namespaces, NFC 2018-11-19 22:19:05 +00:00
DemoteRegToStack.cpp [IR] Replace `isa<TerminatorInst>` with `isTerminator()`. 2018-08-26 09:51:22 +00:00
EntryExitInstrumenter.cpp EntryExitInstrumenter: Handle musttail calls 2018-04-06 10:14:09 +00:00
EscapeEnumerator.cpp [TI removal] Make variables declared as `TerminatorInst` and initialized 2018-10-15 10:04:59 +00:00
Evaluator.cpp [IR] Add Instruction::isLifetimeStartOrEnd, NFC 2018-12-21 21:49:40 +00:00
FlattenCFG.cpp [TI removal] Make variables declared as `TerminatorInst` and initialized 2018-10-15 10:04:59 +00:00
FunctionComparator.cpp Remove unnecessary fallthrough annotation after unreachable 2018-11-01 19:11:05 +00:00
FunctionImportUtils.cpp [ThinLTO] Compute synthetic function entry count 2018-12-13 19:54:27 +00:00
GlobalStatus.cpp [GlobalOpt] Fix exponential compile-time with selects. 2018-01-31 20:42:25 +00:00
GuardUtils.cpp Revert r340921 "[NFC] Unify guards detection" 2018-08-29 12:21:32 +00:00
ImportedFunctionsInliningStatistics.cpp Use the container form llvm::sort(C, ...) 2018-09-30 22:31:29 +00:00
InlineFunction.cpp [IR] Add Instruction::isLifetimeStartOrEnd, NFC 2018-12-21 21:49:40 +00:00
InstructionNamer.cpp Transforms: Introduce Transforms/Utils.h rather than spreading the declarations amongst Scalar.h and IPO.h 2018-03-28 17:44:36 +00:00
IntegerDivision.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
LCSSA.cpp [DebugInfo][LCSSA] Rewrite pre-existing debug values outside loop 2018-10-16 08:06:48 +00:00
LLVMBuild.txt
LibCallsShrinkWrap.cpp [TI removal] Remove `TerminatorInst` from BasicBlockUtils.h 2018-10-15 09:34:05 +00:00
Local.cpp [IR] Add Instruction::isLifetimeStartOrEnd, NFC 2018-12-21 21:49:40 +00:00
LoopRotationUtils.cpp Update MemorySSA in LoopRotate. 2018-10-24 22:46:45 +00:00
LoopSimplify.cpp [TI removal] Make variables declared as `TerminatorInst` and initialized 2018-10-15 10:04:59 +00:00
LoopUnroll.cpp [llvm] API for encoding/decoding DWARF discriminators. 2018-12-21 22:48:50 +00:00
LoopUnrollAndJam.cpp [llvm] API for encoding/decoding DWARF discriminators. 2018-12-21 22:48:50 +00:00
LoopUnrollPeel.cpp [LoopUnroll] Don't verify domtree by default with +Asserts. 2018-12-21 01:28:49 +00:00
LoopUnrollRuntime.cpp [UnrollRuntime] Move the DomTree verification under expensive checks 2019-01-03 19:43:33 +00:00
LoopUtils.cpp Introduce llvm.loop.parallel_accesses and llvm.access.group metadata. 2018-12-20 04:58:07 +00:00
LoopVersioning.cpp [LoopVersioning] Don't modify the list that we iterate over in addPHINodes 2018-05-22 08:33:02 +00:00
LowerInvoke.cpp Support a funclet operand bundle in LowerInvoke 2018-05-09 00:53:50 +00:00
LowerMemIntrinsics.cpp [TI removal] Remove `TerminatorInst` from BasicBlockUtils.h 2018-10-15 09:34:05 +00:00
LowerSwitch.cpp llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...) 2018-09-27 02:13:45 +00:00
Mem2Reg.cpp Transforms: Introduce Transforms/Utils.h rather than spreading the declarations amongst Scalar.h and IPO.h 2018-03-28 17:44:36 +00:00
MetaRenamer.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
ModuleUtils.cpp [NewPM] Port Msan 2019-01-03 13:42:44 +00:00
NameAnonGlobals.cpp
PredicateInfo.cpp ADT/STLExtras: Introduce llvm::empty; NFC 2018-10-31 00:23:23 +00:00
PromoteMemoryToRegister.cpp [IR] Add Instruction::isLifetimeStartOrEnd, NFC 2018-12-21 21:49:40 +00:00
SSAUpdater.cpp [DebugInfo][LCSSA] Rewrite pre-existing debug values outside loop 2018-10-16 08:06:48 +00:00
SSAUpdaterBulk.cpp Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
SanitizerStats.cpp
SimplifyCFG.cpp Introduce llvm.loop.parallel_accesses and llvm.access.group metadata. 2018-12-20 04:58:07 +00:00
SimplifyIndVar.cpp [IndVars] Drop "exact" flag from lshr and udiv when substituting their args 2018-10-11 07:22:26 +00:00
SimplifyLibCalls.cpp [NFC][InstCombine] Undo stray change 2018-10-19 20:57:45 +00:00
SplitModule.cpp llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...) 2018-09-27 02:13:45 +00:00
StripGCRelocates.cpp Fix a couple of layering violations in Transforms 2018-03-21 22:34:23 +00:00
StripNonLineTableDebugInfo.cpp Fix some layering in StripNonLineTableDebugInfo, moving its declaration from IPO.h to Utils.h to match its implementation 2018-03-29 22:42:08 +00:00
SymbolRewriter.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
UnifyFunctionExitNodes.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
Utils.cpp [instsimplify] Move the instsimplify pass to use more obvious file names 2018-06-29 23:36:03 +00:00
VNCoercion.cpp [GVN] Avoid casting a vector of size less than 8 bits to i8 2018-06-21 21:43:20 +00:00
ValueMapper.cpp Teach ValueMapper to use ODR uniqued types when available 2018-01-30 20:16:32 +00:00