- Notifications
You must be signed in to change notification settings - Fork14.5k
[CGData][GMF] Skip merging unnamed functions#148995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Merged
+36 −0
Conversation
This file contains hidden or 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
@llvm/pr-subscribers-backend-aarch64 Author: Kyungwoo Lee (kyulee-com) ChangesSkip merging unnamed functions for simplicity. Full diff:https://github.com/llvm/llvm-project/pull/148995.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/GlobalMergeFunctions.cpp b/llvm/lib/CodeGen/GlobalMergeFunctions.cppindex 92ecfadf97c99..73f11c1345daf 100644--- a/llvm/lib/CodeGen/GlobalMergeFunctions.cpp+++ b/llvm/lib/CodeGen/GlobalMergeFunctions.cpp@@ -95,6 +95,10 @@ bool isEligibleFunction(Function *F) { if (F->getCallingConv() == CallingConv::SwiftTail) return false;+ // Unnamed functions are skipped for simplicity.+ if (!F->hasName())+ return false;+ // If function contains callsites with musttail, if we merge // it, the merged function will have the musttail callsite, but // the number of parameters can change, thus the parameter countdiff --git a/llvm/test/CodeGen/AArch64/cgdata-no-merge-unnamed.ll b/llvm/test/CodeGen/AArch64/cgdata-no-merge-unnamed.llnew file mode 100644index 0000000000000..9986af7eb231c--- /dev/null+++ b/llvm/test/CodeGen/AArch64/cgdata-no-merge-unnamed.ll@@ -0,0 +1,32 @@+; This test checks if two similar functions, @0 and @1, are not merged as they are unnamed.++; RUN: opt -mtriple=arm64-apple-darwin -S --passes=global-merge-func %s | FileCheck %s+; RUN: llc -mtriple=arm64-apple-darwin -enable-global-merge-func=true < %s | FileCheck %s++; CHECK-NOT: .Tgm++@g = external local_unnamed_addr global [0 x i32], align 4+@g1 = external global i32, align 4+@g2 = external global i32, align 4++define i32 @0(i32 %a) {+entry:+ %idxprom = sext i32 %a to i64+ %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i64 0, i64 %idxprom+ %0 = load i32, i32* %arrayidx, align 4+ %1 = load volatile i32, i32* @g1, align 4+ %mul = mul nsw i32 %1, %0+ %add = add nsw i32 %mul, 1+ ret i32 %add+}++define i32 @1(i32 %a) {+entry:+ %idxprom = sext i32 %a to i64+ %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i64 0, i64 %idxprom+ %0 = load i32, i32* %arrayidx, align 4+ %1 = load volatile i32, i32* @g2, align 4+ %mul = mul nsw i32 %1, %0+ %add = add nsw i32 %mul, 1+ ret i32 %add+} |
DataCorrupted approved these changesJul 15, 2025
82404e3
intollvm:main 12 checks passed
Uh oh!
There was an error while loading.Please reload this page.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading.Please reload this page.
Skip merging unnamed functions to fix an assertion issue, since unnamed functions would otherwise receive the same merged name --https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/GlobalMergeFunctions.cpp#L191