[AbstractCallSite] Check that callback callee index is within call arguments

Summary:
AbstractCallSite::getCallbackUses() does not check that callback callee index from
the callback metadata does not exceed the total number of call arguments. This patch
add such validation check.

Reviewers: jdoerfert, sstefan1

Reviewed By: jdoerfert

Subscribers: hiraditya, arphaman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78112
This commit is contained in:
Sergey Dmitriev 2020-04-14 09:12:34 -07:00
parent d58107c3bf
commit c1a9dd9aea
2 changed files with 3 additions and 1 deletions

View File

@ -48,7 +48,8 @@ void AbstractCallSite::getCallbackUses(ImmutableCallSite ICS,
auto *CBCalleeIdxAsCM = cast<ConstantAsMetadata>(OpMD->getOperand(0));
uint64_t CBCalleeIdx =
cast<ConstantInt>(CBCalleeIdxAsCM->getValue())->getZExtValue();
CBUses.push_back(ICS.arg_begin() + CBCalleeIdx);
if (CBCalleeIdx < ICS.arg_size())
CBUses.push_back(ICS.arg_begin() + CBCalleeIdx);
}
}

View File

@ -1,4 +1,5 @@
; RUN: opt -S -openmpopt -stats < %s 2>&1 | FileCheck %s
; RUN: opt -S -attributor -attributor-disable=false -openmpopt -stats < %s 2>&1 | FileCheck %s
; REQUIRES: asserts
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"