summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2015-04-09 22:50:07 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2015-04-09 22:50:07 +0000
commitf3e67de85aed2c3582755845d39474948c0cc63a (patch)
tree8992c1ad8c7ab7a30f323757812ab9275e97e52f /clang/lib/CodeGen/CGExpr.cpp
parent8f9a3f2d7eb7cdcea9e8e3eb7a4766397443b68e (diff)
downloadbcm5719-llvm-f3e67de85aed2c3582755845d39474948c0cc63a.tar.gz
bcm5719-llvm-f3e67de85aed2c3582755845d39474948c0cc63a.zip
[CodeGen] Do a more principled fix for PR231653, always use the inner type.
We were still using the MaterializeTemporaryExpr's type to check if the transform is legal. Always use the inner Expr type. llvm-svn: 234543
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index dd66f6cc7a1..4147317963b 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -300,27 +300,26 @@ createReferenceTemporary(CodeGenFunction &CGF,
const MaterializeTemporaryExpr *M, const Expr *Inner) {
switch (M->getStorageDuration()) {
case SD_FullExpression:
- case SD_Automatic:
+ case SD_Automatic: {
// If we have a constant temporary array or record try to promote it into a
// constant global under the same rules a normal constant would've been
// promoted. This is easier on the optimizer and generally emits fewer
// instructions.
+ QualType Ty = Inner->getType();
if (CGF.CGM.getCodeGenOpts().MergeAllConstants &&
- (M->getType()->isArrayType() || M->getType()->isRecordType()) &&
- CGF.CGM.isTypeConstant(M->getType(), true))
- if (llvm::Constant *Init =
- CGF.CGM.EmitConstantExpr(Inner, Inner->getType(), &CGF)) {
+ (Ty->isArrayType() || Ty->isRecordType()) &&
+ CGF.CGM.isTypeConstant(Ty, true))
+ if (llvm::Constant *Init = CGF.CGM.EmitConstantExpr(Inner, Ty, &CGF)) {
auto *GV = new llvm::GlobalVariable(
CGF.CGM.getModule(), Init->getType(), /*isConstant=*/true,
llvm::GlobalValue::PrivateLinkage, Init, ".ref.tmp");
- GV->setAlignment(CGF.getContext()
- .getTypeAlignInChars(Inner->getType())
- .getQuantity());
+ GV->setAlignment(
+ CGF.getContext().getTypeAlignInChars(Ty).getQuantity());
// FIXME: Should we put the new global into a COMDAT?
return GV;
}
- return CGF.CreateMemTemp(Inner->getType(), "ref.tmp");
-
+ return CGF.CreateMemTemp(Ty, "ref.tmp");
+ }
case SD_Thread:
case SD_Static:
return CGF.CGM.GetAddrOfGlobalTemporary(M, Inner);
OpenPOWER on IntegriCloud