@@ -182,8 +182,8 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
182
182
183
183
StringRef Str (" unknown" );
184
184
if (GVar && GVar->hasInitializer ()) {
185
- auto Init = GVar->getInitializer ();
186
- if (auto CA = dyn_cast<ConstantDataArray>(Init)) {
185
+ auto * Init = GVar->getInitializer ();
186
+ if (auto * CA = dyn_cast<ConstantDataArray>(Init)) {
187
187
if (CA->isString ())
188
188
Str = CA->getAsCString ();
189
189
} else if (isa<ConstantAggregateZero>(Init)) {
@@ -246,16 +246,15 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
246
246
}
247
247
}
248
248
if (shouldPrintAsStr (OpConvSpecifiers[ArgCount - 1 ], ArgType)) {
249
- if (ConstantExpr *ConstExpr = dyn_cast<ConstantExpr>(Arg)) {
250
- GlobalVariable *GV =
251
- dyn_cast<GlobalVariable>(ConstExpr->getOperand (0 ));
249
+ if (auto *ConstExpr = dyn_cast<ConstantExpr>(Arg)) {
250
+ auto *GV = dyn_cast<GlobalVariable>(ConstExpr->getOperand (0 ));
252
251
if (GV && GV->hasInitializer ()) {
253
252
Constant *Init = GV->getInitializer ();
254
- ConstantDataArray *CA = dyn_cast<ConstantDataArray>(Init );
255
- if (Init-> isZeroValue () || CA-> isString ()) {
256
- size_t SizeStr = Init-> isZeroValue ()
257
- ? 1
258
- : (strlen (CA->getAsCString ().data ()) + 1 );
253
+ bool IsZeroValue = Init-> isZeroValue ( );
254
+ auto *CA = dyn_cast<ConstantDataArray>(Init);
255
+ if (IsZeroValue || (CA && CA-> isString ())) {
256
+ size_t SizeStr =
257
+ IsZeroValue ? 1 : (strlen (CA->getAsCString ().data ()) + 1 );
259
258
size_t Rem = SizeStr % DWORD_ALIGN;
260
259
size_t NSizeStr = 0 ;
261
260
LLVM_DEBUG (dbgs () << " Printf string original size = " << SizeStr
@@ -430,9 +429,10 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
430
429
auto *GV = dyn_cast<GlobalVariable>(ConstExpr->getOperand (0 ));
431
430
if (GV && GV->hasInitializer ()) {
432
431
Constant *Init = GV->getInitializer ();
433
- ConstantDataArray *CA = dyn_cast<ConstantDataArray>(Init);
434
- if (Init->isZeroValue () || CA->isString ()) {
435
- S = Init->isZeroValue () ? " " : CA->getAsCString ().data ();
432
+ bool IsZeroValue = Init->isZeroValue ();
433
+ auto *CA = dyn_cast<ConstantDataArray>(Init);
434
+ if (IsZeroValue || (CA && CA->isString ())) {
435
+ S = IsZeroValue ? " " : CA->getAsCString ().data ();
436
436
}
437
437
}
438
438
}
0 commit comments