Skip to content

Commit d94b6c2

Browse files
author
git apple-llvm automerger
committed
Merge commit 'e99c565cd2f7' from llvm.org/main into next
2 parents e2ace1b + e99c565 commit d94b6c2

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,6 +2444,11 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,
24442444

24452445
void MCAsmStreamer::emitInstruction(const MCInst &Inst,
24462446
const MCSubtargetInfo &STI) {
2447+
if (CurFrag) {
2448+
MCSection *Sec = getCurrentSectionOnly();
2449+
Sec->setHasInstructions(true);
2450+
}
2451+
24472452
if (MAI->isAIX() && CurFrag)
24482453
// Now that a machine instruction has been assembled into this section, make
24492454
// a line entry for any .loc directive that has been seen.

llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,16 @@ bool AMDGPUAsmPrinter::doFinalization(Module &M) {
486486
// Pad with s_code_end to help tools and guard against instruction prefetch
487487
// causing stale data in caches. Arguably this should be done by the linker,
488488
// which is why this isn't done for Mesa.
489+
// Don't do it if there is no code.
489490
const MCSubtargetInfo &STI = *getGlobalSTI();
490491
if ((AMDGPU::isGFX10Plus(STI) || AMDGPU::isGFX90A(STI)) &&
491492
(STI.getTargetTriple().getOS() == Triple::AMDHSA ||
492493
STI.getTargetTriple().getOS() == Triple::AMDPAL)) {
493-
OutStreamer->switchSection(getObjFileLowering().getTextSection());
494-
getTargetStreamer()->EmitCodeEnd(STI);
494+
MCSection *TextSect = getObjFileLowering().getTextSection();
495+
if (TextSect->hasInstructions()) {
496+
OutStreamer->switchSection(TextSect);
497+
getTargetStreamer()->EmitCodeEnd(STI);
498+
}
495499
}
496500

497501
// Assign expressions which can only be resolved when all other functions are
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; Test that there is no s_code_end padding if .text is otherwise empty.
2+
3+
; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1200 < %s | FileCheck %s --check-prefixes=GCN
4+
5+
@globalVar = global i32 37
6+
7+
declare amdgpu_ps void @funcDecl()
8+
9+
; GCN-NOT: .fill

0 commit comments

Comments
 (0)