[PATCH] D154270: [clang][CodeGen] Fix global variables initialized with an inheriting constructor.
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 2 14:25:48 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4bae3fd8ede: [clang][CodeGen] Fix global variables initialized with an inheriting… (authored by efriedma).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154270/new/
https://reviews.llvm.org/D154270
Files:
clang/lib/CodeGen/CGDecl.cpp
clang/test/CodeGenCXX/inheriting-constructor.cpp
Index: clang/test/CodeGenCXX/inheriting-constructor.cpp
===================================================================
--- clang/test/CodeGenCXX/inheriting-constructor.cpp
+++ clang/test/CodeGenCXX/inheriting-constructor.cpp
@@ -4,6 +4,24 @@
// RUN: %clang_cc1 -no-enable-noundef-analysis -std=c++11 -triple i386-windows -emit-llvm -o - %s | FileCheck %s --check-prefix=MSABI --check-prefix=WIN32
// RUN: %clang_cc1 -no-enable-noundef-analysis -std=c++11 -triple x86_64-windows -emit-llvm -o - %s | FileCheck %s --check-prefix=MSABI --check-prefix=WIN64
+// PR63618: make sure we generate definitions for all the globals defined in the test
+// MSABI: @"?b@@3UB@@A" = {{.*}} zeroinitializer
+// MSABI: @"?d@@3UD@@A" = {{.*}} zeroinitializer
+// MSABI: @"?b at noninline_nonvirt@@3UB at 1@A" = {{.*}} zeroinitializer
+// MSABI: @"?c at noninline_nonvirt@@3UC at 1@A" = {{.*}} zeroinitializer
+// MSABI: @"?b at noninline_virt@@3UB at 1@A" = {{.*}} zeroinitializer
+// MSABI: @"?c at noninline_virt@@3UC at 1@A" = {{.*}} zeroinitializer
+// MSABI: @"?b at inalloca_nonvirt@@3UB at 1@A" = {{.*}} zeroinitializer
+// MSABI: @"?c at inalloca_nonvirt@@3UC at 1@A" = {{.*}} zeroinitializer
+// MSABI: @"?b at inalloca_virt@@3UB at 1@A" = {{.*}} zeroinitializer
+// MSABI: @"?c at inalloca_virt@@3UC at 1@A" = {{.*}} zeroinitializer
+// MSABI: @"?b at inline_nonvirt@@3UB at 1@A" = {{.*}} zeroinitializer
+// MSABI: @"?c at inline_nonvirt@@3UC at 1@A" = {{.*}} zeroinitializer
+// MSABI: @"?b at inline_virt@@3UB at 1@A" = {{.*}} zeroinitializer
+// MSABI: @"?c at inline_virt@@3UC at 1@A" = {{.*}} zeroinitializer
+
+// MSABI-NOT: @this
+
// PR12219
struct A { A(int); virtual ~A(); };
struct B : A { using A::A; ~B(); };
Index: clang/lib/CodeGen/CGDecl.cpp
===================================================================
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2453,7 +2453,10 @@
assert((isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)) &&
"Invalid argument to EmitParmDecl");
- Arg.getAnyValue()->setName(D.getName());
+ // Set the name of the parameter's initial value to make IR easier to
+ // read. Don't modify the names of globals.
+ if (!isa<llvm::GlobalValue>(Arg.getAnyValue()))
+ Arg.getAnyValue()->setName(D.getName());
QualType Ty = D.getType();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154270.536625.patch
Type: text/x-patch
Size: 2256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230702/5e249aa4/attachment.bin>
More information about the cfe-commits
mailing list