Skip to content

Commit 5768f2e

Browse files
arsenmmiguelcsx
authored andcommitted
AsmPrinter: Do not use report_fatal_error for unhandled ConstantExpr (llvm#145275)
1 parent 75ff556 commit 5768f2e

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
@@ -3608,10 +3608,11 @@ const MCExpr *AsmPrinter::lowerConstant(const Constant *CV,
36083608
// Otherwise report the problem to the user.
36093609
std::string S;
36103610
raw_string_ostream OS(S);
3611-
OS << "Unsupported expression in static initializer: ";
3611+
OS << "unsupported expression in static initializer: ";
36123612
CE->printAsOperand(OS, /*PrintType=*/false,
36133613
!MF ? nullptr : MF->getFunction().getParent());
3614-
report_fatal_error(Twine(S));
3614+
CE->getContext().emitError(S);
3615+
return MCConstantExpr::create(0, Ctx);
36153616
}
36163617

36173618
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)