Skip to content

Commit eb50e73

Browse files
committed
DAG: Check libcall function is supported before emission
Whether the libcall implementation is supported should always be checked before emission. Previously this would emit a call to a non-existent function, and then since r600 doesn't support calls it would error on the call. This switches it to a direct legalization failure. Also swap to use reportFatalInternalError. Probably should be reportFatalUsageError; we don't want a backtrace and this will never be fixed, but it is tested.
1 parent cca454b commit eb50e73

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,12 @@ TargetLowering::makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT,
178178
Args.push_back(Entry);
179179
}
180180

181-
if (LC == RTLIB::UNKNOWN_LIBCALL)
182-
report_fatal_error("Unsupported library call operation!");
183-
SDValue Callee = DAG.getExternalSymbol(getLibcallName(LC),
184-
getPointerTy(DAG.getDataLayout()));
181+
const char *LibcallName = getLibcallName(LC);
182+
if (LC == RTLIB::UNKNOWN_LIBCALL || !LibcallName)
183+
reportFatalInternalError("unsupported library call operation");
184+
185+
SDValue Callee =
186+
DAG.getExternalSymbol(LibcallName, getPointerTy(DAG.getDataLayout()));
185187

186188
Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
187189
TargetLowering::CallLoweringInfo CLI(DAG);

llvm/test/CodeGen/AMDGPU/fneg.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
; RUN: llc -mtriple=amdgcn -mcpu=tonga < %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI %s
44
; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -mattr=+real-true16 < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX11,GFX11-TRUE16 %s
55
; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -mattr=-real-true16 < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX11,GFX11-FAKE16 %s
6-
; RUN: not llc -mtriple=r600 -mcpu=redwood < %s
6+
; RUN: not --crash llc -mtriple=r600 -mcpu=redwood < %s 2>&1 | FileCheck -check-prefix=R600-ERR %s
7+
8+
; R600-ERR: LLVM ERROR: unsupported library call operation
79

810
define amdgpu_kernel void @s_fneg_f32(ptr addrspace(1) %out, float %in) {
911
; SI-LABEL: s_fneg_f32:

0 commit comments

Comments
 (0)