[PATCH] D88800: [AtomicExpand] Avoid creating an unnamed libcall
Alexander Richardson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 2 09:53:57 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5bc438efcf96: [AtomicExpand] Avoid creating an unnamed libcall (authored by arichardson).
Changed prior to commit:
https://reviews.llvm.org/D88800?vs=296067&id=302324#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88800/new/
https://reviews.llvm.org/D88800
Files:
llvm/lib/CodeGen/AtomicExpandPass.cpp
llvm/test/Transforms/AtomicExpand/AMDGPU/unaligned-atomic.ll
Index: llvm/test/Transforms/AtomicExpand/AMDGPU/unaligned-atomic.ll
===================================================================
--- llvm/test/Transforms/AtomicExpand/AMDGPU/unaligned-atomic.ll
+++ llvm/test/Transforms/AtomicExpand/AMDGPU/unaligned-atomic.ll
@@ -1,8 +1,6 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -atomic-expand %s | FileCheck -check-prefix=GCN %s
-
-; FIXME: This should not introduce a libcall, much less one to an
-; anonymous function.
+; RUN: not --crash opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -atomic-expand %s 2>&1 | FileCheck %s
+; The AtomicExpand pass cannot handle missing libcalls (yet) so reports a fatal error.
+; CHECK: LLVM ERROR: expandAtomicOpToLibcall shouldn't fail for Load
define i32 @atomic_load_global_align1(i32 addrspace(1)* %ptr) {
; GCN-LABEL: @atomic_load_global_align1(
Index: llvm/lib/CodeGen/AtomicExpandPass.cpp
===================================================================
--- llvm/lib/CodeGen/AtomicExpandPass.cpp
+++ llvm/lib/CodeGen/AtomicExpandPass.cpp
@@ -1507,8 +1507,8 @@
bool expanded = expandAtomicOpToLibcall(
I, Size, I->getAlign(), I->getPointerOperand(), nullptr, nullptr,
I->getOrdering(), AtomicOrdering::NotAtomic, Libcalls);
- (void)expanded;
- assert(expanded && "expandAtomicOpToLibcall shouldn't fail tor Load");
+ if (!expanded)
+ report_fatal_error("expandAtomicOpToLibcall shouldn't fail for Load");
}
void AtomicExpand::expandAtomicStoreToLibcall(StoreInst *I) {
@@ -1520,8 +1520,8 @@
bool expanded = expandAtomicOpToLibcall(
I, Size, I->getAlign(), I->getPointerOperand(), I->getValueOperand(),
nullptr, I->getOrdering(), AtomicOrdering::NotAtomic, Libcalls);
- (void)expanded;
- assert(expanded && "expandAtomicOpToLibcall shouldn't fail tor Store");
+ if (!expanded)
+ report_fatal_error("expandAtomicOpToLibcall shouldn't fail for Store");
}
void AtomicExpand::expandAtomicCASToLibcall(AtomicCmpXchgInst *I) {
@@ -1535,8 +1535,8 @@
I, Size, I->getAlign(), I->getPointerOperand(), I->getNewValOperand(),
I->getCompareOperand(), I->getSuccessOrdering(), I->getFailureOrdering(),
Libcalls);
- (void)expanded;
- assert(expanded && "expandAtomicOpToLibcall shouldn't fail tor CAS");
+ if (!expanded)
+ report_fatal_error("expandAtomicOpToLibcall shouldn't fail for CAS");
}
static ArrayRef<RTLIB::Libcall> GetRMWLibcall(AtomicRMWInst::BinOp Op) {
@@ -1685,6 +1685,11 @@
return false;
}
+ if (!TLI->getLibcallName(RTLibType)) {
+ // This target does not implement the requested atomic libcall so give up.
+ return false;
+ }
+
// Build up the function call. There's two kinds. First, the sized
// variants. These calls are going to be one of the following (with
// N=1,2,4,8,16):
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88800.302324.patch
Type: text/x-patch
Size: 2882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201102/5d8566cd/attachment.bin>
More information about the llvm-commits
mailing list