[llvm] c6c5629 - [CodeGen] Do not call `emitGlobalConstantLargeInt` for constant requires 8 bytes to store

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 22:59:26 PDT 2020


Author: Simon Atanasyan
Date: 2020-09-26T08:58:46+03:00
New Revision: c6c5629f2fb4ddabd376fbe7c218733283e91d09

URL: https://github.com/llvm/llvm-project/commit/c6c5629f2fb4ddabd376fbe7c218733283e91d09
DIFF: https://github.com/llvm/llvm-project/commit/c6c5629f2fb4ddabd376fbe7c218733283e91d09.diff

LOG: [CodeGen] Do not call `emitGlobalConstantLargeInt` for constant requires 8 bytes to store

This is a fix for PR47630. The regression is caused by the D78011. After
this change the code starts to call the `emitGlobalConstantLargeInt` even
for constants which requires eight bytes to store.

Differential revision: https://reviews.llvm.org/D88261

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/test/CodeGen/Mips/emit-big-cst.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 210354624f90..5b4e347cf6c8 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2800,7 +2800,7 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *CV,
   if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
     const uint64_t StoreSize = DL.getTypeStoreSize(CV->getType());
 
-    if (StoreSize < 8) {
+    if (StoreSize <= 8) {
       if (AP.isVerbose())
         AP.OutStreamer->GetCommentOS() << format("0x%" PRIx64 "\n",
                                                  CI->getZExtValue());

diff  --git a/llvm/test/CodeGen/Mips/emit-big-cst.ll b/llvm/test/CodeGen/Mips/emit-big-cst.ll
index 67c2f107db19..679824ef047b 100644
--- a/llvm/test/CodeGen/Mips/emit-big-cst.ll
+++ b/llvm/test/CodeGen/Mips/emit-big-cst.ll
@@ -16,6 +16,14 @@
 ; LE-NEXT: .space 5
 ; LE-NEXT: .size bigCst, 16
 
+; BE-LABEL: notSoBigCst:
+; BE-NEXT:  .8byte  72057594037927935
+; BE-NEXT:  .size   notSoBigCst, 8
+
+; LE-LABEL: notSoBigCst:
+; LE-NEXT:  .8byte  72057594037927935
+; LE-NEXT:  .size   notSoBigCst, 8
+
 ; BE-LABEL: smallCst:
 ; BE-NEXT: .2byte 4386
 ; BE-NEXT: .byte 51
@@ -38,4 +46,14 @@ define void @accessBig(i64* %storage) {
   ret void
 }
 
+ at notSoBigCst = internal constant i57 72057594037927935
+
+define void @accessNotSoBig(i64* %storage) {
+  %addr = bitcast i64* %storage to i57*
+  %bigLoadedCst = load volatile i57, i57* @notSoBigCst
+  %tmp = add i57 %bigLoadedCst, 1
+  store i57 %tmp, i57* %addr
+  ret void
+}
+
 @smallCst = internal constant i24 1122867


        


More information about the llvm-commits mailing list