diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-04-09 16:09:29 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-04-09 16:09:29 +0000 |
commit | b2b81439a39136ea5eda1a80f784efbbd61cc384 (patch) | |
tree | e3d009f15ecb894cfa4d52524122d98d83c682ba /clang/lib/CodeGen/CGExpr.cpp | |
parent | 504a5dccc4982e454d8fd8fdd35077eba3af93a9 (diff) | |
download | bcm5719-llvm-b2b81439a39136ea5eda1a80f784efbbd61cc384.tar.gz bcm5719-llvm-b2b81439a39136ea5eda1a80f784efbbd61cc384.zip |
[CodeGen] When promoting a reference temporary to a global use the inner type to fold it.
The MaterializeTemporaryExpr can have a different type than the inner
expression, miscompiling the constant. PR23165.
llvm-svn: 234499
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index f86e970c25a..dd66f6cc7a1 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -309,12 +309,13 @@ createReferenceTemporary(CodeGenFunction &CGF, (M->getType()->isArrayType() || M->getType()->isRecordType()) && CGF.CGM.isTypeConstant(M->getType(), true)) if (llvm::Constant *Init = - CGF.CGM.EmitConstantExpr(Inner, M->getType(), &CGF)) { + CGF.CGM.EmitConstantExpr(Inner, Inner->getType(), &CGF)) { auto *GV = new llvm::GlobalVariable( CGF.CGM.getModule(), Init->getType(), /*isConstant=*/true, llvm::GlobalValue::PrivateLinkage, Init, ".ref.tmp"); - GV->setAlignment( - CGF.getContext().getTypeAlignInChars(M->getType()).getQuantity()); + GV->setAlignment(CGF.getContext() + .getTypeAlignInChars(Inner->getType()) + .getQuantity()); // FIXME: Should we put the new global into a COMDAT? return GV; } |