Skip to content

Commit fff24c7

Browse files
eskarnPatriceBlin
authored andcommitted
BasicBlock: add a workaround for a segfault after splitBasicBlock for functions with a probe-stack
1 parent fb3d146 commit fff24c7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

split/SplitBasicBlocks.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,24 @@ void SplitBasicBlock::split(Function *f) {
123123
last = test[i];
124124
if (toSplit->size() < 2)
125125
continue;
126+
127+
/* TODO: find a real fix or try with the probe-stack inline-asm when its
128+
* ready. See https://github.com/Rust-for-Linux/linux/issues/355.
129+
* Sometimes moving an alloca from the entry block to the second block
130+
* causes a segfault when using the "probe-stack" attribute (observed with
131+
* with Rust programs). To avoid this issue we just split the entry block
132+
* after the allocas in this case.
133+
*/
134+
if (f->hasFnAttribute("probe-stack") &&
135+
#if LLVM_VERSION_MAJOR < 13
136+
(curr == &curr->getParent()->getEntryBlock())
137+
#else
138+
curr->isEntryBlock()
139+
#endif
140+
&& isa<AllocaInst>(it)) {
141+
continue;
142+
}
143+
126144
toSplit = toSplit->splitBasicBlock(it, toSplit->getName() + ".split");
127145
}
128146

0 commit comments

Comments
 (0)