[PATCH] D135926: [clang] Fix crash with -funique-internal-linkage-names
Ellis Hoag via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 17 08:57:43 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG970e1ea01aa0: [clang] Fix crash with -funique-internal-linkage-names (authored by ellis).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135926/new/
https://reviews.llvm.org/D135926
Files:
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/unique-internal-linkage-names.c
Index: clang/test/CodeGen/unique-internal-linkage-names.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/unique-internal-linkage-names.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -S -emit-llvm -funique-internal-linkage-names -o - | FileCheck %s
+
+// Check that we do not crash when overloading extern functions.
+
+inline void overloaded_external() {}
+extern void overloaded_external();
+
+// CHECK: define internal void @overloaded_internal() [[ATTR:#[0-9]+]] {
+static void overloaded_internal() {}
+extern void overloaded_internal();
+
+void markUsed() {
+ overloaded_external();
+ overloaded_internal();
+}
+
+// CHECK: attributes [[ATTR]] =
+// CHECK-SAME: "sample-profile-suffix-elision-policy"="selected"
Index: clang/lib/CodeGen/CGCall.cpp
===================================================================
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2264,9 +2264,8 @@
// Add "sample-profile-suffix-elision-policy" attribute for internal linkage
// functions with -funique-internal-linkage-names.
if (TargetDecl && CodeGenOpts.UniqueInternalLinkageNames) {
- if (isa<FunctionDecl>(TargetDecl)) {
- if (this->getFunctionLinkage(CalleeInfo.getCalleeDecl()) ==
- llvm::GlobalValue::InternalLinkage)
+ if (const auto *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl)) {
+ if (!FD->isExternallyVisible())
FuncAttrs.addAttribute("sample-profile-suffix-elision-policy",
"selected");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135926.468227.patch
Type: text/x-patch
Size: 1552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221017/08d1eda8/attachment.bin>
More information about the cfe-commits
mailing list