Skip to content

Commit 0b43cda

Browse files
committed
AsmPrinter: Do not use report_fatal_error for unhandled ConstantExpr
1 parent da0c21b commit 0b43cda

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3603,10 +3603,11 @@ const MCExpr *AsmPrinter::lowerConstant(const Constant *CV,
36033603
// Otherwise report the problem to the user.
36043604
std::string S;
36053605
raw_string_ostream OS(S);
3606-
OS << "Unsupported expression in static initializer: ";
3606+
OS << "unsupported expression in static initializer: ";
36073607
CE->printAsOperand(OS, /*PrintType=*/false,
36083608
!MF ? nullptr : MF->getFunction().getParent());
3609-
report_fatal_error(Twine(S));
3609+
CE->getContext().emitError(S);
3610+
return MCConstantExpr::create(0, Ctx);
36103611
}
36113612

36123613
static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *C,

llvm/test/CodeGen/AMDGPU/addrspacecast-initializer-unsupported.ll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
; RUN: not --crash llc -mtriple=amdgcn -verify-machineinstrs -amdgpu-enable-lower-module-lds=false < %s 2>&1 | FileCheck -check-prefix=ERROR %s
1+
; RUN: not llc -mtriple=amdgcn -verify-machineinstrs -amdgpu-enable-lower-module-lds=false < %s 2> %t.err | FileCheck %s
2+
; RUN: FileCheck -check-prefix=ERROR %s < %t.err
3+
4+
; ERROR: error: unsupported expression in static initializer: addrspacecast (ptr addrspace(3) @lds.arr to ptr addrspace(4))
5+
6+
; CHECK: gv_flatptr_from_lds:
7+
; CHECK-NEXT: .quad 0+32
8+
; CHECK-NEXT: .size gv_flatptr_from_lds, 8
29

3-
; ERROR: LLVM ERROR: Unsupported expression in static initializer: addrspacecast (ptr addrspace(3) @lds.arr to ptr addrspace(4))
410

511
@lds.arr = unnamed_addr addrspace(3) global [256 x i32] poison, align 4
612

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
; RUN: not --crash llc < %s -mtriple=i386-linux 2>&1 | FileCheck %s
1+
; RUN: not llc < %s -mtriple=i386-linux 2>&1 | FileCheck %s
22

33
; ptrtoint expressions that cast to a wider integer type are not supported.
44
; A frontend can achieve a similar result by casting to the correct integer
55
; type and explicitly zeroing any additional bytes.
66
; { i32, i32 } { i32 ptrtoint (ptr @r to i32), i32 0 }
77

8-
; CHECK: LLVM ERROR: Unsupported expression in static initializer: ptrtoint (ptr @r to i64)
8+
; CHECK: error: unsupported expression in static initializer: ptrtoint (ptr @r to i64)
99

1010
@r = global i64 ptrtoint (ptr @r to i64)

0 commit comments

Comments
 (0)