Skip to content

Commit 7255c3a

Browse files
authored
DAG: Check libcall function is supported before emission (#144314)
1 parent ddb8493 commit 7255c3a

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
@@ -179,10 +179,12 @@ TargetLowering::makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT,
179179
Args.push_back(Entry);
180180
}
181181

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

187189
Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
188190
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)