File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -1883,8 +1883,10 @@ llvm::Constant *ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl &D) {
1883
1883
1884
1884
// Try to emit the initializer. Note that this can allow some things that
1885
1885
// are not allowed by tryEmitPrivateForMemory alone.
1886
- if (APValue *value = D.evaluateValue ())
1887
- return tryEmitPrivateForMemory (*value, destType);
1886
+ if (APValue *value = D.evaluateValue ()) {
1887
+ if (!value->allowConstexprUnknown ())
1888
+ return tryEmitPrivateForMemory (*value, destType);
1889
+ }
1888
1890
1889
1891
return nullptr ;
1890
1892
}
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++23 %s -emit-llvm -o - | FileCheck %s
2
+
3
+ extern int & s;
4
+
5
+ // CHECK: @_Z4testv()
6
+ // CHECK-NEXT: entry:
7
+ // CHECK-NEXT: [[I:%.*]] = alloca ptr, align {{.*}}
8
+ // CHECK-NEXT: [[X:%.*]] = load ptr, ptr @s, align {{.*}}
9
+ // CHECK-NEXT: store ptr [[X]], ptr [[I]], align {{.*}}
10
+ int & test () {
11
+ auto &i = s;
12
+ return i;
13
+ }
You can’t perform that action at this time.
0 commit comments