Skip to content

Commit b130f71

Browse files
committed
[CIR] Add more user facing messages for -fno-clangir-call-conv-lowering
1 parent 467b1ec commit b130f71

16 files changed

+171
-164
lines changed

clang/include/clang/CIR/MissingFeatures.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ constexpr bool cirMissingFeatureAssertionMode =
1919
true; // Change to `false` to use llvm_unreachable
2020

2121
#define NOTE \
22-
" Target lowering is now required. Disable it with " \
23-
"-fno-clangir-call-conv-lowering."
22+
" Target lowering is now required. To workaround use " \
23+
"-fno-clangir-call-conv-lowering. This flag is going to be removed at some" \
24+
" point."
2425

2526
// Special assertion to be used in the target lowering library.
2627
#define cir_tl_assert(cond) assert((cond) && NOTE);
2728

29+
// Special
30+
#define cir_unreachable(msg) \
31+
do { \
32+
llvm_unreachable(msg NOTE); \
33+
} while (0)
34+
2835
// Some assertions knowingly generate incorrect code. This macro allows us to
2936
// switch between using `assert` and `llvm_unreachable` for these cases.
3037
#define cir_assert_or_abort(cond, msg) \

clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Type useFirstFieldIfTransparentUnion(Type Ty) {
4949
CIRCXXABI::RecordArgABI getRecordArgABI(const StructType RT,
5050
CIRCXXABI &CXXABI) {
5151
if (::cir::MissingFeatures::typeIsCXXRecordDecl()) {
52-
llvm_unreachable("NYI");
52+
cir_unreachable("NYI");
5353
}
5454
return CXXABI.getRecordArgABI(RT);
5555
}

clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ clang::TypeInfo CIRLowerContext::getTypeInfoImpl(const Type T) const {
9494
Align = Target->getDoubleAlign();
9595
break;
9696
}
97-
llvm_unreachable("Unknown builtin type!");
97+
cir_unreachable("Unknown builtin type!");
9898
break;
9999
}
100100
case clang::Type::Record: {
@@ -108,7 +108,7 @@ clang::TypeInfo CIRLowerContext::getTypeInfoImpl(const Type T) const {
108108
// Not sure if this is necessary in CIR.
109109

110110
if (::cir::MissingFeatures::typeGetAsEnumType()) {
111-
llvm_unreachable("NYI");
111+
cir_unreachable("NYI");
112112
}
113113

114114
const CIRRecordLayout &Layout = getCIRRecordLayout(RT);
@@ -118,7 +118,7 @@ clang::TypeInfo CIRLowerContext::getTypeInfoImpl(const Type T) const {
118118
break;
119119
}
120120
default:
121-
llvm_unreachable("Unhandled type class");
121+
cir_unreachable("Unhandled type class");
122122
}
123123

124124
cir_tl_assert(llvm::isPowerOf2_32(Align) && "Alignment must be power of 2");
@@ -135,7 +135,7 @@ Type CIRLowerContext::initBuiltinType(clang::BuiltinType::Kind K) {
135135
Ty = IntType::get(getMLIRContext(), 8, true);
136136
break;
137137
default:
138-
llvm_unreachable("NYI");
138+
cir_unreachable("NYI");
139139
}
140140

141141
Types.push_back(Ty);
@@ -153,7 +153,7 @@ void CIRLowerContext::initBuiltinTypes(const clang::TargetInfo &Target,
153153
if (LangOpts.CharIsSigned)
154154
CharTy = initBuiltinType(clang::BuiltinType::Char_S);
155155
else
156-
llvm_unreachable("NYI");
156+
cir_unreachable("NYI");
157157
}
158158

159159
/// Convert a size in bits to a size in characters.
@@ -168,7 +168,7 @@ int64_t CIRLowerContext::toBits(clang::CharUnits CharSize) const {
168168

169169
clang::TypeInfoChars CIRLowerContext::getTypeInfoInChars(Type T) const {
170170
if (auto arrTy = dyn_cast<ArrayType>(T))
171-
llvm_unreachable("NYI");
171+
cir_unreachable("NYI");
172172
clang::TypeInfo Info = getTypeInfo(T);
173173
return clang::TypeInfoChars(toCharUnitsFromBits(Info.Width),
174174
toCharUnitsFromBits(Info.Align),
@@ -179,7 +179,7 @@ bool CIRLowerContext::isPromotableIntegerType(Type T) const {
179179
// HLSL doesn't promote all small integer types to int, it
180180
// just uses the rank-based promotion rules for all types.
181181
if (::cir::MissingFeatures::langOpts())
182-
llvm_unreachable("NYI");
182+
cir_unreachable("NYI");
183183

184184
// FIXME(cir): CIR does not distinguish between char, short, etc. So we just
185185
// assume it is promotable if smaller than 32 bits. This is wrong since, for
@@ -198,7 +198,7 @@ bool CIRLowerContext::isPromotableIntegerType(Type T) const {
198198
// TODO(cir): CIR doesn't know if a integer originated from an enum. Improve
199199
// CIR or add an AST query here.
200200
if (::cir::MissingFeatures::typeGetAsEnumType()) {
201-
llvm_unreachable("NYI");
201+
cir_unreachable("NYI");
202202
}
203203

204204
return false;

clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRToCIRArgMapping.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class CIRToCIRArgMapping {
6969
const ::cir::ABIArgInfo &RetAI = FI.getReturnInfo();
7070

7171
if (RetAI.getKind() == ::cir::ABIArgInfo::Indirect) {
72-
llvm_unreachable("NYI");
72+
cir_unreachable("NYI");
7373
}
7474

7575
unsigned ArgNo = 0;
@@ -84,7 +84,7 @@ class CIRToCIRArgMapping {
8484
auto &IRArgs = ArgInfo[ArgNo];
8585

8686
if (::cir::MissingFeatures::argumentPadding()) {
87-
llvm_unreachable("NYI");
87+
cir_unreachable("NYI");
8888
}
8989

9090
switch (AI.getKind()) {
@@ -94,14 +94,14 @@ class CIRToCIRArgMapping {
9494
cir_tl_assert(AI.getCoerceToType() && "Missing coerced type!!");
9595
StructType STy = dyn_cast<StructType>(AI.getCoerceToType());
9696
if (AI.isDirect() && AI.getCanBeFlattened() && STy) {
97-
llvm_unreachable("NYI");
97+
cir_unreachable("NYI");
9898
} else {
9999
IRArgs.NumberOfArgs = 1;
100100
}
101101
break;
102102
}
103103
default:
104-
llvm_unreachable("Missing ABIArgInfo::Kind");
104+
cir_unreachable("Missing ABIArgInfo::Kind");
105105
}
106106

107107
if (IRArgs.NumberOfArgs > 0) {
@@ -117,7 +117,7 @@ class CIRToCIRArgMapping {
117117
cir_tl_assert(ArgNo == ArgInfo.size());
118118

119119
if (::cir::MissingFeatures::inallocaArgs()) {
120-
llvm_unreachable("NYI");
120+
cir_unreachable("NYI");
121121
}
122122

123123
TotalIRArgs = IRArgNo;

clang/lib/CIR/Dialect/Transforms/TargetLowering/ItaniumCXXABI.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ bool ItaniumCXXABI::classifyReturnType(LowerFunctionInfo &FI) const {
6262

6363
// If C++ prohibits us from making a copy, return by address.
6464
if (::cir::MissingFeatures::recordDeclCanPassInRegisters())
65-
llvm_unreachable("NYI");
65+
cir_unreachable("NYI");
6666

6767
return false;
6868
}
@@ -84,12 +84,12 @@ CIRCXXABI *CreateItaniumCXXABI(LowerModule &LM) {
8484
return new ItaniumCXXABI(LM);
8585

8686
case clang::TargetCXXABI::Microsoft:
87-
llvm_unreachable("Microsoft ABI is not Itanium-based");
87+
cir_unreachable("Microsoft ABI is not Itanium-based");
8888
default:
89-
llvm_unreachable("NYI");
89+
cir_unreachable("NYI");
9090
}
9191

92-
llvm_unreachable("bad ABI kind");
92+
cir_unreachable("bad ABI kind");
9393
}
9494

9595
} // namespace cir

clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerCall.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ arrangeFreeFunctionLikeCall(LowerTypes &LT, LowerModule &LM,
3838
cir_assert_or_abort(!::cir::MissingFeatures::isVarArg(), "NYI");
3939

4040
if (::cir::MissingFeatures::extParamInfo())
41-
llvm_unreachable("NYI");
41+
cir_unreachable("NYI");
4242
}
4343

4444
// TODO(cir): There's some CC stuff related to no-proto functions here, but
@@ -61,7 +61,7 @@ static void appendParameterTypes(SmallVectorImpl<Type> &prefix, FuncType fnTy) {
6161
}
6262

6363
cir_tl_assert(MissingFeatures::extParamInfo());
64-
llvm_unreachable("NYI");
64+
cir_unreachable("NYI");
6565
}
6666

6767
/// Arrange the LLVM function layout for a value of the given function
@@ -104,9 +104,9 @@ void LowerModule::constructAttributeList(StringRef Name,
104104
CallingConv = FI.getCallingConvention();
105105
// FIXME(cir): No-return should probably be set in CIRGen (ABI-agnostic).
106106
if (MissingFeatures::noReturn())
107-
llvm_unreachable("NYI");
107+
cir_unreachable("NYI");
108108
if (MissingFeatures::csmeCall())
109-
llvm_unreachable("NYI");
109+
cir_unreachable("NYI");
110110

111111
// TODO(cir): Implement AddAttributesFromFunctionProtoType here.
112112
// TODO(cir): Implement AddAttributesFromOMPAssumes here.
@@ -153,31 +153,31 @@ void LowerModule::constructAttributeList(StringRef Name,
153153
case ABIArgInfo::Ignore:
154154
break;
155155
default:
156-
llvm_unreachable("Missing ABIArgInfo::Kind");
156+
cir_unreachable("Missing ABIArgInfo::Kind");
157157
}
158158

159159
if (!IsThunk) {
160160
if (MissingFeatures::qualTypeIsReferenceType()) {
161-
llvm_unreachable("NYI");
161+
cir_unreachable("NYI");
162162
}
163163
}
164164

165165
// Attach attributes to sret.
166166
if (MissingFeatures::sretArgs()) {
167-
llvm_unreachable("sret is NYI");
167+
cir_unreachable("sret is NYI");
168168
}
169169

170170
// Attach attributes to inalloca arguments.
171171
if (MissingFeatures::inallocaArgs()) {
172-
llvm_unreachable("inalloca is NYI");
172+
cir_unreachable("inalloca is NYI");
173173
}
174174

175175
// Apply `nonnull`, `dereferencable(N)` and `align N` to the `this` argument,
176176
// unless this is a thunk function.
177177
// FIXME: fix this properly, https://reviews.llvm.org/D100388
178178
if (MissingFeatures::funcDeclIsCXXMethodDecl() ||
179179
MissingFeatures::inallocaArgs()) {
180-
llvm_unreachable("`this` argument attributes are NYI");
180+
cir_unreachable("`this` argument attributes are NYI");
181181
}
182182

183183
unsigned ArgNo = 0;
@@ -190,7 +190,7 @@ void LowerModule::constructAttributeList(StringRef Name,
190190

191191
// Add attribute for padding argument, if necessary.
192192
if (IRFunctionArgs.hasPaddingArg(ArgNo)) {
193-
llvm_unreachable("Padding argument is NYI");
193+
cir_unreachable("Padding argument is NYI");
194194
}
195195

196196
// TODO(cir): Mark noundef arguments and return values. Although this
@@ -212,18 +212,18 @@ void LowerModule::constructAttributeList(StringRef Name,
212212
[[fallthrough]];
213213
case ABIArgInfo::Direct:
214214
if (ArgNo == 0 && ::cir::MissingFeatures::chainCall())
215-
llvm_unreachable("ChainCall is NYI");
215+
cir_unreachable("ChainCall is NYI");
216216
else if (AI.getInReg())
217-
llvm_unreachable("InReg attribute is NYI");
217+
cir_unreachable("InReg attribute is NYI");
218218
// Attrs.addStackAlignmentAttr(llvm::MaybeAlign(AI.getDirectAlign()));
219219
cir_tl_assert(!::cir::MissingFeatures::noFPClass());
220220
break;
221221
default:
222-
llvm_unreachable("Missing ABIArgInfo::Kind");
222+
cir_unreachable("Missing ABIArgInfo::Kind");
223223
}
224224

225225
if (::cir::MissingFeatures::qualTypeIsReferenceType()) {
226-
llvm_unreachable("Reference handling is NYI");
226+
cir_unreachable("Reference handling is NYI");
227227
}
228228

229229
// TODO(cir): Missing some swift and nocapture stuff here.
@@ -243,7 +243,7 @@ void LowerModule::constructAttributeList(StringRef Name,
243243
/// definition of the given function.
244244
const LowerFunctionInfo &LowerTypes::arrangeFunctionDeclaration(FuncOp fnOp) {
245245
if (MissingFeatures::funcDeclIsCXXMethodDecl())
246-
llvm_unreachable("NYI");
246+
cir_unreachable("NYI");
247247

248248
cir_tl_assert(!MissingFeatures::qualifiedTypes());
249249
FuncType FTy = fnOp.getFunctionType();
@@ -283,7 +283,7 @@ const LowerFunctionInfo &LowerTypes::arrangeFreeFunctionType(FuncType FTy) {
283283
const LowerFunctionInfo &LowerTypes::arrangeGlobalDeclaration(FuncOp fnOp) {
284284
if (MissingFeatures::funcDeclIsCXXConstructorDecl() ||
285285
MissingFeatures::funcDeclIsCXXDestructorDecl())
286-
llvm_unreachable("NYI");
286+
cir_unreachable("NYI");
287287

288288
return arrangeFunctionDeclaration(fnOp);
289289
}
@@ -316,9 +316,9 @@ LowerTypes::arrangeLLVMFunctionInfo(Type resultType, FnInfoOpts opts,
316316

317317
// Compute ABI information.
318318
if (CC == llvm::CallingConv::SPIR_KERNEL) {
319-
llvm_unreachable("NYI");
319+
cir_unreachable("NYI");
320320
} else if (::cir::MissingFeatures::extParamInfo()) {
321-
llvm_unreachable("NYI");
321+
cir_unreachable("NYI");
322322
} else {
323323
// NOTE(cir): This corects the initial function info data.
324324
getABIInfo().computeInfo(*FI); // FIXME(cir): Args should be set to null.

0 commit comments

Comments
 (0)