-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cling] Emit const variables only once (#13614)
Otherwise they are emitted as internal and we get double-construction and -destruction on the same memory address due to the way we promote internal declarations in KeepLocalGVPass. According to upstream tests, the de-duplication doesn't work on Windows (yet), but I think this problem is severe enough to fix it on the other platforms sooner rather than later. Fixes #13429
- Loading branch information
Showing
4 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//------------------------------------------------------------------------------ | ||
// CLING - the C++ LLVM-based InterpreterG :) | ||
// | ||
// This file is dual-licensed: you can choose to license it under the University | ||
// of Illinois Open Source License or the GNU Lesser General Public License. See | ||
// LICENSE.TXT for details. | ||
//------------------------------------------------------------------------------ | ||
|
||
// RUN: cat %s | %cling 2>&1 | FileCheck %s | ||
|
||
extern "C" int printf(const char*, ...); | ||
|
||
struct A { | ||
int val; | ||
A(int v) : val(v) { | ||
printf("A(%d), this = %p\n", val, this); | ||
} | ||
~A() { | ||
printf("~A(%d), this = %p\n", val, this); | ||
} | ||
int getVal() const { return val; } | ||
}; | ||
|
||
const A a(1); | ||
// CHECK: A(1), this = [[PTR:.+]] | ||
|
||
a.val | ||
// CHECK-NEXT: (const int) 1 | ||
a.getVal() | ||
// CHECK-NEXT: (int) 1 | ||
a.val | ||
// CHECK-NEXT: (const int) 1 | ||
a.getVal() | ||
// CHECK-NEXT: (int) 1 | ||
|
||
// CHECK-NEXT: ~A(1), this = [[PTR]] | ||
// CHECK-NOT: ~A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ROOT-llvm13-20230921-01 | ||
ROOT-llvm13-20231003-01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters