Skip to content

Commit 1e4b179

Browse files
atanasyanzmodem
authored andcommitted
[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 (cherry picked from commit c6c5629)
1 parent 184a13d commit 1e4b179

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2779,7 +2779,7 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *CV,
27792779
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
27802780
const uint64_t StoreSize = DL.getTypeStoreSize(CV->getType());
27812781

2782-
if (StoreSize < 8) {
2782+
if (StoreSize <= 8) {
27832783
if (AP.isVerbose())
27842784
AP.OutStreamer->GetCommentOS() << format("0x%" PRIx64 "\n",
27852785
CI->getZExtValue());

llvm/test/CodeGen/Mips/emit-big-cst.ll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
; LE-NEXT: .space 5
1717
; LE-NEXT: .size bigCst, 16
1818

19+
; BE-LABEL: notSoBigCst:
20+
; BE-NEXT: .8byte 72057594037927935
21+
; BE-NEXT: .size notSoBigCst, 8
22+
23+
; LE-LABEL: notSoBigCst:
24+
; LE-NEXT: .8byte 72057594037927935
25+
; LE-NEXT: .size notSoBigCst, 8
26+
1927
; BE-LABEL: smallCst:
2028
; BE-NEXT: .2byte 4386
2129
; BE-NEXT: .byte 51
@@ -38,4 +46,14 @@ define void @accessBig(i64* %storage) {
3846
ret void
3947
}
4048

49+
@notSoBigCst = internal constant i57 72057594037927935
50+
51+
define void @accessNotSoBig(i64* %storage) {
52+
%addr = bitcast i64* %storage to i57*
53+
%bigLoadedCst = load volatile i57, i57* @notSoBigCst
54+
%tmp = add i57 %bigLoadedCst, 1
55+
store i57 %tmp, i57* %addr
56+
ret void
57+
}
58+
4159
@smallCst = internal constant i24 1122867

0 commit comments

Comments
 (0)