[PATCH] D116161: [Clang] Add an overload for emitUnaryBuiltin.

Jun Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 22 04:56:50 PST 2021

junaire created this revision.
junaire added reviewers: fhahn, arsenm.
junaire requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

This patch adds an overload for emitUnaryBuiltin, which is addressed in D115429 <https://reviews.llvm.org/D115429>.
After this change, we can avoid some duplicate codes when emitting IR for

Signed-off-by: Jun Zhang <jun at junz.org>

  rG LLVM Github Monorepo



Index: clang/lib/CodeGen/CGBuiltin.cpp
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -541,6 +541,12 @@
   return CGF.Builder.CreateCall(F, Src0);
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,
+                               unsigned IntrinsicID, llvm::StringRef Name) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  return CGF.Builder.CreateUnaryIntrinsic(IntrinsicID, Src0, nullptr, Name);
 // Emit an intrinsic that has 2 operands of the same type as its result.
 static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
                                 const CallExpr *E,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116161.395844.patch
Type: text/x-patch
Size: 720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211222/116fe381/attachment.bin>

More information about the cfe-commits mailing list