[PATCH] D55967: [CodeExtractor] Do not extract unsafe lifetime markers
Vedant Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 20 15:45:04 PST 2018
vsk created this revision.
vsk added reviewers: davidxl, kachkov98.
Herald added subscribers: hiraditya, eraman.
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).
https://reviews.llvm.org/D55967
Files:
llvm/include/llvm/Transforms/Utils/CodeExtractor.h
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/test/Transforms/CodeExtractor/PartialInlineAlloca4.ll
llvm/test/Transforms/CodeExtractor/PartialInlineAlloca5.ll
llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55967.179182.patch
Type: text/x-patch
Size: 11717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181220/24e3c787/attachment.bin>
More information about the llvm-commits
mailing list