[PATCH] D87104: [OpenMPOpt] Assume indirect call always changes ICV
Wei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 3 22:59:31 PDT 2020
weiwang updated this revision to Diff 289870.
weiwang added a comment.
Add test case for indirect call. Without the fix, the test will crash.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87104/new/
https://reviews.llvm.org/D87104
Files:
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/OpenMP/icv_tracking.ll
Index: llvm/test/Transforms/OpenMP/icv_tracking.ll
===================================================================
--- llvm/test/Transforms/OpenMP/icv_tracking.ll
+++ llvm/test/Transforms/OpenMP/icv_tracking.ll
@@ -30,6 +30,21 @@
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:%.*]])
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -1480,6 +1480,9 @@
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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87104.289870.patch
Type: text/x-patch
Size: 1497 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200904/05b273f6/attachment.bin>
More information about the llvm-commits
mailing list