Skip to content

[CodeGen] Remove extraneous ArrayRef (NFC) #96085

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 19, 2024

Conversation

kazutakahirata
Copy link
Contributor

@kazutakahirata kazutakahirata commented Jun 19, 2024

A C array can be implicitly cast to ArrayRef.

ArrayRef can infer the size of a C array.  Also, C arrays can be
implicitly cast to ArrayRef.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. labels Jun 19, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 19, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-codegen

Author: Kazu Hirata (kazutakahirata)

Changes

ArrayRef can infer the size of a C array. Also, C arrays can be
implicitly cast to ArrayRef.


Full diff: https://github.com/llvm/llvm-project/pull/96085.diff

1 Files Affected:

  • (modified) clang/lib/CodeGen/CodeGenPGO.cpp (+3-4)
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 2839697614595..f2cdeb5796d3a 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -1200,15 +1200,14 @@ void CodeGenPGO::emitCounterSetOrIncrement(CGBuilderTy &Builder, const Stmt *S,
 
   if (llvm::EnableSingleByteCoverage)
     Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_cover),
-                       ArrayRef(Args, 4));
+                       Args);
   else {
     if (!StepV)
       Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment),
-                         ArrayRef(Args, 4));
+                         Args);
     else
       Builder.CreateCall(
-          CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment_step),
-          ArrayRef(Args));
+          CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment_step), Args);
   }
 }
 

@kazutakahirata kazutakahirata requested a review from MaskRay June 19, 2024 15:46
@kazutakahirata kazutakahirata merged commit 09f88da into llvm:main Jun 19, 2024
5 of 6 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_ArrayRef_extra_clang branch June 19, 2024 16:49
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
A C array can be implicitly cast to ArrayRef.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants