summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2014-07-14 06:22:36 +0000
committerBill Wendling <isanbard@gmail.com>2014-07-14 06:22:36 +0000
commit151b44d653e0e90c59fae22831be39925308354e (patch)
tree9757d3812015b125e1a6dd5d91cff7fbe03d673a /llvm/lib
parent5c40508457c573e3153f7bdcd1b190ccab6eb8ee (diff)
downloadbcm5719-llvm-151b44d653e0e90c59fae22831be39925308354e.tar.gz
bcm5719-llvm-151b44d653e0e90c59fae22831be39925308354e.zip
Support lowering of empty aggregates.
This crash was pretty common while compiling Rust for iOS (armv7). Reason - SjLj preparation step was lowering aggregate arguments as ExtractValue + InsertValue. ExtractValue has assertion which checks that there is some data in value, which is not true in case of empty (no fields) structures. Rust uses them quite extensively so this patch uses a 'select true, %val, undef' instruction to lower the argument. Patch by Valerii Hiora. llvm-svn: 212922
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SjLjEHPrepare.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/SjLjEHPrepare.cpp b/llvm/lib/CodeGen/SjLjEHPrepare.cpp
index d2f39559486..f53408a0f12 100644
--- a/llvm/lib/CodeGen/SjLjEHPrepare.cpp
+++ b/llvm/lib/CodeGen/SjLjEHPrepare.cpp
@@ -249,18 +249,18 @@ void SjLjEHPrepare::lowerIncomingArguments(Function &F) {
++AI) {
Type *Ty = AI->getType();
- // Aggregate types can't be cast, but are legal argument types, so we have
- // to handle them differently. We use an extract/insert pair as a
- // lightweight method to achieve the same goal.
if (isa<StructType>(Ty) || isa<ArrayType>(Ty)) {
- Instruction *EI = ExtractValueInst::Create(AI, 0, "", AfterAllocaInsPt);
- Instruction *NI = InsertValueInst::Create(AI, EI, 0);
- NI->insertAfter(EI);
- AI->replaceAllUsesWith(NI);
-
- // Set the operand of the instructions back to the AllocaInst.
- EI->setOperand(0, AI);
- NI->setOperand(0, AI);
+ // Aggregate types can't be cast, but are legal argument types,
+ // so we have to handle them differently. We use
+ // select i8 true, %arg, undef to achieve the same goal
+ Value *TrueValue = ConstantInt::getTrue(F.getContext());
+ Value *UndefValue = UndefValue::get(Ty);
+ Instruction *SI = SelectInst::Create(TrueValue, AI, UndefValue,
+ AI->getName() + ".tmp",
+ AfterAllocaInsPt);
+ AI->replaceAllUsesWith(SI);
+
+ SI->setOperand(1, AI);
} else {
// This is always a no-op cast because we're casting AI to AI->getType()
// so src and destination types are identical. BitCast is the only
OpenPOWER on IntegriCloud