From: Joseph Huber Date: Tue, 20 Dec 2022 15:50:27 +0000 (-0600) Subject: [OpenMP] Remove folding logic for removed runtime function X-Git-Tag: upstream/17.0.6~23059 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb4c6e7a0643be9fe797ec7b5806ecbe83c7d512;p=platform%2Fupstream%2Fllvm.git [OpenMP] Remove folding logic for removed runtime function This function was removed from the device runtime at some point but we still have specialized code for it and an entry in the runtime kinds. Remove it as it is no longer necessary. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D140402 --- diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def index ce75085..8274953 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def +++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def @@ -481,8 +481,6 @@ __OMP_RTL(__kmpc_barrier_simple_generic, false, Void, IdentPtr, Int32) __OMP_RTL(__kmpc_warp_active_thread_mask, false, Int64,) __OMP_RTL(__kmpc_syncwarp, false, Void, Int64) -__OMP_RTL(__kmpc_is_generic_main_thread_id, false, Int8, Int32) - __OMP_RTL(__last, false, Void, ) #undef __OMP_RTL diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index d6cb75b..b8acf16 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -4522,9 +4522,6 @@ struct AAFoldRuntimeCallCallSiteReturned : AAFoldRuntimeCall { case OMPRTL___kmpc_is_spmd_exec_mode: Changed |= foldIsSPMDExecMode(A); break; - case OMPRTL___kmpc_is_generic_main_thread_id: - Changed |= foldIsGenericMainThread(A); - break; case OMPRTL___kmpc_parallel_level: Changed |= foldParallelLevel(A); break; @@ -4639,28 +4636,6 @@ private: : ChangeStatus::CHANGED; } - /// Fold __kmpc_is_generic_main_thread_id into a constant if possible. - ChangeStatus foldIsGenericMainThread(Attributor &A) { - std::optional SimplifiedValueBefore = SimplifiedValue; - - CallBase &CB = cast(getAssociatedValue()); - Function *F = CB.getFunction(); - const auto &ExecutionDomainAA = A.getAAFor( - *this, IRPosition::function(*F), DepClassTy::REQUIRED); - - if (!ExecutionDomainAA.isValidState()) - return indicatePessimisticFixpoint(); - - auto &Ctx = getAnchorValue().getContext(); - if (ExecutionDomainAA.isExecutedByInitialThreadOnly(CB)) - SimplifiedValue = ConstantInt::get(Type::getInt8Ty(Ctx), true); - else - return indicatePessimisticFixpoint(); - - return SimplifiedValue == SimplifiedValueBefore ? ChangeStatus::UNCHANGED - : ChangeStatus::CHANGED; - } - /// Fold __kmpc_parallel_level into a constant if possible. ChangeStatus foldParallelLevel(Attributor &A) { std::optional SimplifiedValueBefore = SimplifiedValue; diff --git a/llvm/test/Transforms/OpenMP/fold_generic_main_thread.ll b/llvm/test/Transforms/OpenMP/fold_generic_main_thread.ll deleted file mode 100644 index 8a818dc..0000000 --- a/llvm/test/Transforms/OpenMP/fold_generic_main_thread.ll +++ /dev/null @@ -1,153 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature -; RUN: opt -S -passes='openmp-opt' < %s | FileCheck %s -; RUN: opt -openmp-opt-disable-folding -S -passes='openmp-opt' < %s | FileCheck %s --check-prefix=CHECK-DISABLED -; ModuleID = 'single_threaded_exeuction.c' - -%struct.ident_t = type { i32, i32, i32, i32, i8* } - -@0 = private unnamed_addr constant [1 x i8] c"\00", align 1 -@1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @0, i32 0, i32 0) }, align 8 - -define void @kernel() { -; CHECK-LABEL: define {{[^@]+}}@kernel() { -; CHECK-NEXT: [[CALL:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* nonnull @[[GLOB1:[0-9]+]], i8 1, i1 false) -; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[CALL]], -1 -; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]] -; CHECK: if.then: -; CHECK-NEXT: call void @foo() -; CHECK-NEXT: br label [[IF_END:%.*]] -; CHECK: if.else: -; CHECK-NEXT: call void @bar() -; CHECK-NEXT: br label [[IF_END]] -; CHECK: if.end: -; CHECK-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* null, i8 1) -; CHECK-NEXT: ret void -; -; CHECK-DISABLED-LABEL: define {{[^@]+}}@kernel() { -; CHECK-DISABLED-NEXT: [[CALL:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* nonnull @[[GLOB1:[0-9]+]], i8 1, i1 false) -; CHECK-DISABLED-NEXT: [[CMP:%.*]] = icmp eq i32 [[CALL]], -1 -; CHECK-DISABLED-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]] -; CHECK-DISABLED: if.then: -; CHECK-DISABLED-NEXT: call void @foo() -; CHECK-DISABLED-NEXT: br label [[IF_END:%.*]] -; CHECK-DISABLED: if.else: -; CHECK-DISABLED-NEXT: call void @bar() -; CHECK-DISABLED-NEXT: br label [[IF_END]] -; CHECK-DISABLED: if.end: -; CHECK-DISABLED-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* null, i8 1) -; CHECK-DISABLED-NEXT: ret void -; - %call = call i32 @__kmpc_target_init(%struct.ident_t* nonnull @1, i8 1, i1 false) - %cmp = icmp eq i32 %call, -1 - br i1 %cmp, label %if.then, label %if.else -if.then: - call void @foo() - br label %if.end -if.else: - call void @bar() - br label %if.end -if.end: - call void @__kmpc_target_deinit(%struct.ident_t* null, i8 1) - ret void -} - -; Function Attrs: noinline -define internal void @foo() { -; CHECK-LABEL: define {{[^@]+}}@foo() { -; CHECK-NEXT: entry: -; CHECK-NEXT: [[TID:%.*]] = call i32 @__kmpc_get_hardware_thread_id() -; CHECK-NEXT: br label [[IF_THEN:%.*]] -; CHECK: if.then: -; CHECK-NEXT: call void @baz() -; CHECK-NEXT: br label [[IF_END:%.*]] -; CHECK: if.end: -; CHECK-NEXT: ret void -; -; CHECK-DISABLED-LABEL: define {{[^@]+}}@foo() { -; CHECK-DISABLED-NEXT: entry: -; CHECK-DISABLED-NEXT: [[TID:%.*]] = call i32 @__kmpc_get_hardware_thread_id() -; CHECK-DISABLED-NEXT: [[ISMAIN:%.*]] = call signext i8 @__kmpc_is_generic_main_thread_id(i32 [[TID]]) -; CHECK-DISABLED-NEXT: [[PRED:%.*]] = icmp eq i8 [[ISMAIN]], 1 -; CHECK-DISABLED-NEXT: br i1 [[PRED]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] -; CHECK-DISABLED: if.then: -; CHECK-DISABLED-NEXT: call void @baz() -; CHECK-DISABLED-NEXT: br label [[IF_END]] -; CHECK-DISABLED: if.end: -; CHECK-DISABLED-NEXT: ret void -; -entry: - %tid = call i32 @__kmpc_get_hardware_thread_id(); - %ismain = call signext i8 @__kmpc_is_generic_main_thread_id(i32 %tid) - %pred = icmp eq i8 %ismain, 1 - br i1 %pred, label %if.then, label %if.end - -if.then: - call void @baz() - br label %if.end - -if.end: - ret void -} - -; Function Attrs: noinline -define internal void @bar() { -; CHECK-LABEL: define {{[^@]+}}@bar() { -; CHECK-NEXT: entry: -; CHECK-NEXT: [[TID:%.*]] = call i32 @__kmpc_get_hardware_thread_id() -; CHECK-NEXT: [[ISMAIN:%.*]] = call signext i8 @__kmpc_is_generic_main_thread_id(i32 [[TID]]) -; CHECK-NEXT: [[PRED:%.*]] = icmp eq i8 [[ISMAIN]], 1 -; CHECK-NEXT: br i1 [[PRED]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] -; CHECK: if.then: -; CHECK-NEXT: call void @baz() -; CHECK-NEXT: br label [[IF_END]] -; CHECK: if.end: -; CHECK-NEXT: ret void -; -; CHECK-DISABLED-LABEL: define {{[^@]+}}@bar() { -; CHECK-DISABLED-NEXT: entry: -; CHECK-DISABLED-NEXT: [[TID:%.*]] = call i32 @__kmpc_get_hardware_thread_id() -; CHECK-DISABLED-NEXT: [[ISMAIN:%.*]] = call signext i8 @__kmpc_is_generic_main_thread_id(i32 [[TID]]) -; CHECK-DISABLED-NEXT: [[PRED:%.*]] = icmp eq i8 [[ISMAIN]], 1 -; CHECK-DISABLED-NEXT: br i1 [[PRED]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] -; CHECK-DISABLED: if.then: -; CHECK-DISABLED-NEXT: call void @baz() -; CHECK-DISABLED-NEXT: br label [[IF_END]] -; CHECK-DISABLED: if.end: -; CHECK-DISABLED-NEXT: ret void -; -entry: - %tid = call i32 @__kmpc_get_hardware_thread_id(); - %ismain = call signext i8 @__kmpc_is_generic_main_thread_id(i32 %tid) - %pred = icmp eq i8 %ismain, 1 - br i1 %pred, label %if.then, label %if.end - -if.then: - call void @baz() - br label %if.end - -if.end: - ret void -} - -declare void @baz() - -declare i8 @__kmpc_is_generic_main_thread_id(i32) - -declare i32 @__kmpc_get_hardware_thread_id() - -declare i32 @__kmpc_target_init(%struct.ident_t*, i8, i1) - -declare void @__kmpc_target_deinit(%struct.ident_t*, i8) - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!3, !4, !5, !6} -!nvvm.annotations = !{!7} - -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) -!1 = !DIFile(filename: "fold_generic_main_thread.c", directory: "/tmp/fold_generic_main_thread.c") -!2 = !{} -!3 = !{i32 2, !"Debug Info Version", i32 3} -!4 = !{i32 1, !"wchar_size", i32 4} -!5 = !{i32 7, !"openmp", i32 50} -!6 = !{i32 7, !"openmp-device", i32 50} -!7 = !{void ()* @kernel, !"kernel", i32 1}