@@ -3391,21 +3391,23 @@ static void findStoresToUninstrumentedArgAllocas(
3391
3391
}
3392
3392
}
3393
3393
3394
- StringRef getAllocaName (AllocaInst *AI) {
3394
+ static StringRef getAllocaName (AllocaInst *AI) {
3395
3395
// Alloca could have been renamed for uniqueness. Its true name will have been
3396
3396
// recorded as an annotation.
3397
3397
if (AI->hasMetadata (LLVMContext::MD_annotation)) {
3398
- MDTuple *Annotation =
3399
- (MDTuple *)AI->getMetadata (LLVMContext::MD_annotation);
3400
- for (int i = 0 ; i < Annotation->getNumOperands (); i++) {
3401
- if (auto Tuple = dyn_cast<MDTuple>(Annotation->getOperand (i))) {
3402
- for (int i = 0 ; i < Tuple->getNumOperands (); i++) {
3403
- if (auto stringMetadata = dyn_cast<MDString>(Tuple->getOperand (i))) {
3404
- if (stringMetadata->getString () == " alloca_name_altered" ) {
3405
- return ((MDString *)Tuple->getOperand (i + 1 ).get ())->getString ();
3406
- }
3407
- }
3408
- }
3398
+ MDTuple *AllocaAnnotations =
3399
+ cast<MDTuple>(AI->getMetadata (LLVMContext::MD_annotation));
3400
+ for (auto &Annotation : AllocaAnnotations->operands ()) {
3401
+ if (!isa<MDTuple>(Annotation))
3402
+ continue ;
3403
+ auto AnnotationTuple = cast<MDTuple>(Annotation);
3404
+ for (int Index = 0 ; Index < AnnotationTuple->getNumOperands (); Index++) {
3405
+ // All annotations are strings
3406
+ auto MetadataString =
3407
+ cast<MDString>(AnnotationTuple->getOperand (Index));
3408
+ if (MetadataString->getString () == " alloca_name_altered" )
3409
+ return cast<MDString>(AnnotationTuple->getOperand (Index + 1 ))
3410
+ ->getString ();
3409
3411
}
3410
3412
}
3411
3413
}
@@ -3446,8 +3448,7 @@ void FunctionStackPoisoner::processStaticAllocas() {
3446
3448
ArgInitInst->moveBefore (InsBefore);
3447
3449
3448
3450
// If we have a call to llvm.localescape, keep it in the entry block.
3449
- if (LocalEscapeCall)
3450
- LocalEscapeCall->moveBefore (InsBefore);
3451
+ if (LocalEscapeCall) LocalEscapeCall->moveBefore (InsBefore);
3451
3452
3452
3453
SmallVector<ASanStackVariableDescription, 16 > SVD;
3453
3454
SVD.reserve (AllocaVec.size ());
0 commit comments