diff options
| author | Adrian Prantl <aprantl@apple.com> | 2017-11-28 00:57:53 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2017-11-28 00:57:53 +0000 |
| commit | d7f6f1636d53c3e2faf55cdf20fbb44a1a149df1 (patch) | |
| tree | a900b43204f48973891654562ad894f5309a55ce /llvm/lib/Transforms/Scalar/SROA.cpp | |
| parent | 3e0e1d093435d753f66c51820f49528b91522743 (diff) | |
| download | bcm5719-llvm-d7f6f1636d53c3e2faf55cdf20fbb44a1a149df1.tar.gz bcm5719-llvm-d7f6f1636d53c3e2faf55cdf20fbb44a1a149df1.zip | |
SROA: Avoid creating a fragment expression that covers the entire variable.
Fixes PR35416.
https://bugs.llvm.org/show_bug.cgi?id=35416
llvm-svn: 319126
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SROA.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/SROA.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index 85479609f3d..93321076a85 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -4101,6 +4101,7 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) { if (!DbgDeclares.empty()) { auto *Var = DbgDeclares.front()->getVariable(); auto *Expr = DbgDeclares.front()->getExpression(); + auto VarSize = Var->getSizeInBits(); DIBuilder DIB(*AI.getModule(), /*AllowUnresolved*/ false); uint64_t AllocaSize = DL.getTypeSizeInBits(AI.getAllocatedType()); for (auto Fragment : Fragments) { @@ -4128,10 +4129,14 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) { "new fragment is outside of original fragment"); Start -= OrigFragment->OffsetInBits; } - if (auto E = DIExpression::createFragmentExpression(Expr, Start, Size)) - FragmentExpr = *E; - else - continue; + // Avoid creating a fragment expression that covers the entire variable. + if (!VarSize || *VarSize != Size) { + if (auto E = + DIExpression::createFragmentExpression(Expr, Start, Size)) + FragmentExpr = *E; + else + continue; + } } // Remove any existing intrinsics describing the same alloca. |

