1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[OpenMPOpt] Assume indirect call always changes ICV

When checking call sites, give special handling to indirect call, as the
callee may be unknown and can lead to nullptr dereference later. Assume
conservatively that the ICV always changes in such case.

Reviewed By: sstefan1

Differential Revision: https://reviews.llvm.org/D87104
This commit is contained in:
Wei Wang 2020-09-04 09:05:13 -07:00 committed by Wenlei He
parent 03ab03eb46
commit b71380c837
2 changed files with 18 additions and 0 deletions

View File

@ -1480,6 +1480,9 @@ struct AAICVTrackerFunction : public AAICVTracker {
auto &SetterRFI = OMPInfoCache.RFIs[OMPInfoCache.ICVs[ICV].Setter];
Function *CalledFunction = CB->getCalledFunction();
// Indirect call, assume ICV changes.
if (CalledFunction == nullptr)
return nullptr;
if (CalledFunction == GetterRFI.Declaration)
return None;
if (CalledFunction == SetterRFI.Declaration) {

View File

@ -30,6 +30,21 @@ define i32 @bad_use(i32 %0) {
ret i32 %2
}
define void @indirect_call(void ()* %0) {
; CHECK-LABEL: define {{[^@]+}}@indirect_call
; CHECK-SAME: (void ()* [[TMP0:%.*]])
; CHECK-NEXT: call void @omp_set_num_threads(i32 4)
; CHECK-NEXT: tail call void [[TMP0]]()
; CHECK-NEXT: [[TMP2:%.*]] = tail call i32 @omp_get_max_threads()
; CHECK-NEXT: tail call void @use(i32 [[TMP2]])
; CHECK-NEXT: ret void
call void @omp_set_num_threads(i32 4)
tail call void %0()
%2 = tail call i32 @omp_get_max_threads()
tail call void @use(i32 %2)
ret void
}
define dso_local i32 @foo(i32 %0, i32 %1) {
; CHECK-LABEL: define {{[^@]+}}@foo
; CHECK-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]])