diff options
| author | Eli Friedman <efriedma@quicinc.com> | 2019-02-08 21:18:46 +0000 |
|---|---|---|
| committer | Eli Friedman <efriedma@quicinc.com> | 2019-02-08 21:18:46 +0000 |
| commit | 3bf72d7d64b8465acd4f4af1a469d68d9dc86058 (patch) | |
| tree | 1ef27b84d2b770c22d76b641a6e0c0446e14b7c4 /clang/lib/CodeGen | |
| parent | 57e60a501ed20f0e6483bad9535fac93312b8e77 (diff) | |
| download | bcm5719-llvm-3bf72d7d64b8465acd4f4af1a469d68d9dc86058.tar.gz bcm5719-llvm-3bf72d7d64b8465acd4f4af1a469d68d9dc86058.zip | |
[Sema] Make string literal init an rvalue.
This allows substantially simplifying the expression evaluation code,
because we don't have to special-case lvalues which are actually string
literal initialization.
This currently throws away an optimization where we would avoid creating
an array APValue for string literal initialization. If we really want
to optimize this case, we should fix APValue so it can store simple
arrays more efficiently, like llvm::ConstantDataArray. This shouldn't
affect the memory usage for other string literals. (Not sure if this is
a blocker; I don't think string literal init is common enough for this
to be a serious issue, but I could be wrong.)
The change to test/CodeGenObjC/encode-test.m is a weird side-effect of
these changes: we currently don't constant-evaluate arrays in C, so the
strlen call shouldn't be folded, but lvalue string init managed to get
around that check. I this this is fine.
Fixes https://bugs.llvm.org/show_bug.cgi?id=40430 .
llvm-svn: 353569
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 10 |
1 files changed, 0 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 48ab2522e83..8dbfab8345a 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -1649,16 +1649,6 @@ private: llvm::Constant *ConstantLValueEmitter::tryEmit() { const APValue::LValueBase &base = Value.getLValueBase(); - // Certain special array initializers are represented in APValue - // as l-values referring to the base expression which generates the - // array. This happens with e.g. string literals. These should - // probably just get their own representation kind in APValue. - if (DestType->isArrayType()) { - assert(!hasNonZeroOffset() && "offset on array initializer"); - auto expr = const_cast<Expr*>(base.get<const Expr*>()); - return ConstExprEmitter(Emitter).Visit(expr, DestType); - } - // Otherwise, the destination type should be a pointer or reference // type, but it might also be a cast thereof. // |

