Index: lib/Target/AMDGPU/R600AsmPrinter.cpp =================================================================== --- lib/Target/AMDGPU/R600AsmPrinter.cpp +++ lib/Target/AMDGPU/R600AsmPrinter.cpp @@ -103,6 +103,10 @@ bool R600AsmPrinter::runOnMachineFunction(MachineFunction &MF) { + + // Functions needs to be cacheline (256B) aligned. + MF.ensureAlignment(8); + SetupMachineFunction(MF); MCContext &Context = getObjFileLowering().getContext(); Index: test/CodeGen/AMDGPU/r600.func-alignment.ll =================================================================== --- /dev/null +++ test/CodeGen/AMDGPU/r600.func-alignment.ll @@ -0,0 +1,14 @@ +; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s +; RUN: llc < %s -march=r600 -mcpu=rs880 | FileCheck %s + +; CHECK: .globl test +; Functions need to be cacheline (256B) aligned to prevent GPU hangs +; CHECK: .p2align 8 +; CHECK: {{^}}test: +; CHECK: CF_END + +define amdgpu_ps void @test(<4 x float> inreg %reg0) { +entry: + ret void +} +