r365709 - NFC: Pass DataLayout into isBytewiseValue

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 10 15:53:52 PDT 2019


Author: vitalybuka
Date: Wed Jul 10 15:53:52 2019
New Revision: 365709

URL: http://llvm.org/viewvc/llvm-project?rev=365709&view=rev
Log:
NFC: Pass DataLayout into isBytewiseValue

Summary:
We will need to handle IntToPtr which I will submit in a separate patch as it's
not going to be NFC.

Reviewers: eugenis, pcc

Reviewed By: eugenis

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D63940

Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=365709&r1=365708&r2=365709&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Jul 10 15:53:52 2019
@@ -967,11 +967,12 @@ static bool shouldUseBZeroPlusStoresToIn
 /// FIXME We could be more clever, as we are for bzero above, and generate
 ///       memset followed by stores. It's unclear that's worth the effort.
 static llvm::Value *shouldUseMemSetToInitialize(llvm::Constant *Init,
-                                                uint64_t GlobalSize) {
+                                                uint64_t GlobalSize,
+                                                const llvm::DataLayout &DL) {
   uint64_t SizeLimit = 32;
   if (GlobalSize <= SizeLimit)
     return nullptr;
-  return llvm::isBytewiseValue(Init);
+  return llvm::isBytewiseValue(Init, DL);
 }
 
 /// Decide whether we want to split a constant structure or array store into a
@@ -1177,7 +1178,8 @@ static void emitStoresForConstant(CodeGe
   }
 
   // If the initializer is a repeated byte pattern, use memset.
-  llvm::Value *Pattern = shouldUseMemSetToInitialize(constant, ConstantSize);
+  llvm::Value *Pattern =
+      shouldUseMemSetToInitialize(constant, ConstantSize, CGM.getDataLayout());
   if (Pattern) {
     uint64_t Value = 0x00;
     if (!isa<llvm::UndefValue>(Pattern)) {




More information about the cfe-commits mailing list