[clang] [clang][NFC] Assert not llvm_unreachable (PR #70149)

2023-10-30 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan closed 
https://github.com/llvm/llvm-project/pull/70149
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Assert not llvm_unreachable (PR #70149)

2023-10-28 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/70149
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Assert not llvm_unreachable (PR #70149)

2023-10-27 Thread Jon Roelofs via cfe-commits

https://github.com/jroelofs approved this pull request.


https://github.com/llvm/llvm-project/pull/70149
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Assert not llvm_unreachable (PR #70149)

2023-10-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nathan Sidwell (urnathan)


Changes

An assert is better here.

---
Full diff: https://github.com/llvm/llvm-project/pull/70149.diff


1 Files Affected:

- (modified) clang/lib/CodeGen/CGExprScalar.cpp (+4-5) 


``diff
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index c25ddeff9adc3a7..7633c6b17db88eb 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2084,11 +2084,10 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
 Value *Src = Visit(const_cast(E));
 llvm::Type *SrcTy = Src->getType();
 llvm::Type *DstTy = ConvertType(DestTy);
-if (SrcTy->isPtrOrPtrVectorTy() && DstTy->isPtrOrPtrVectorTy() &&
-SrcTy->getPointerAddressSpace() != DstTy->getPointerAddressSpace()) {
-  llvm_unreachable("wrong cast for pointers in different address spaces"
-   "(must be an address space cast)!");
-}
+assert(
+(!SrcTy->isPtrOrPtrVectorTy() || !DstTy->isPtrOrPtrVectorTy() ||
+ SrcTy->getPointerAddressSpace() == DstTy->getPointerAddressSpace()) &&
+"Address-space cast must be used to convert address spaces");
 
 if (CGF.SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
   if (auto *PT = DestTy->getAs()) {

``




https://github.com/llvm/llvm-project/pull/70149
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Assert not llvm_unreachable (PR #70149)

2023-10-25 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan ready_for_review 
https://github.com/llvm/llvm-project/pull/70149
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Assert not llvm_unreachable (PR #70149)

2023-10-24 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan created 
https://github.com/llvm/llvm-project/pull/70149

An assert is better here.

>From 1120a9bd5490dba672898f6902e60e461792b711 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Tue, 24 Oct 2023 20:20:18 -0400
Subject: [PATCH] [clang][NFC] Assert not llvm_unreachable

An assert is better here.
---
 clang/lib/CodeGen/CGExprScalar.cpp | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index c25ddeff9adc3a7..7633c6b17db88eb 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2084,11 +2084,10 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
 Value *Src = Visit(const_cast(E));
 llvm::Type *SrcTy = Src->getType();
 llvm::Type *DstTy = ConvertType(DestTy);
-if (SrcTy->isPtrOrPtrVectorTy() && DstTy->isPtrOrPtrVectorTy() &&
-SrcTy->getPointerAddressSpace() != DstTy->getPointerAddressSpace()) {
-  llvm_unreachable("wrong cast for pointers in different address spaces"
-   "(must be an address space cast)!");
-}
+assert(
+(!SrcTy->isPtrOrPtrVectorTy() || !DstTy->isPtrOrPtrVectorTy() ||
+ SrcTy->getPointerAddressSpace() == DstTy->getPointerAddressSpace()) &&
+"Address-space cast must be used to convert address spaces");
 
 if (CGF.SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
   if (auto *PT = DestTy->getAs()) {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits