Revert "[SPIRV] Emit intrinsics for globals only in function that references them (#178143)#179268
Conversation
|
@llvm/pr-subscribers-backend-spir-v Author: Juan Manuel Martinez Caamaño (jmmartinez) ChangesThis reverts commit 1daef59. Patch is 25.25 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/179268.diff 5 Files Affected:
diff --git a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
index b14136647481b..bf6d1d7a7328c 100644
--- a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
@@ -62,94 +62,6 @@ namespace llvm::SPIRV {
} // namespace llvm::SPIRV
namespace {
-// This class keeps track of which functions reference which global variables.
-class GlobalVariableUsers {
- template <typename T1, typename T2>
- using OneToManyMapTy = DenseMap<T1, SmallPtrSet<T2, 4>>;
-
- OneToManyMapTy<const GlobalVariable *, const Function *> GlobalIsUsedByFun;
-
- void collectGlobalUsers(
- const GlobalVariable *GV,
- OneToManyMapTy<const GlobalVariable *, const GlobalVariable *>
- &GlobalIsUsedByGlobal) {
- SmallVector<const Value *> Stack = {GV->user_begin(), GV->user_end()};
- while (!Stack.empty()) {
- const Value *V = Stack.pop_back_val();
-
- if (const Instruction *I = dyn_cast<Instruction>(V)) {
- GlobalIsUsedByFun[GV].insert(I->getFunction());
- continue;
- }
-
- if (const GlobalVariable *UserGV = dyn_cast<GlobalVariable>(V)) {
- GlobalIsUsedByGlobal[GV].insert(UserGV);
- continue;
- }
-
- if (const Constant *C = dyn_cast<Constant>(V))
- Stack.append(C->user_begin(), C->user_end());
- }
- }
-
- bool propagateGlobalToGlobalUsers(
- OneToManyMapTy<const GlobalVariable *, const GlobalVariable *>
- &GlobalIsUsedByGlobal) {
- SmallVector<const GlobalVariable *> OldUsersGlobals;
- bool Changed = false;
- for (auto &[GV, UserGlobals] : GlobalIsUsedByGlobal) {
- OldUsersGlobals.assign(UserGlobals.begin(), UserGlobals.end());
- for (const GlobalVariable *UserGV : OldUsersGlobals) {
- auto It = GlobalIsUsedByGlobal.find(UserGV);
- if (It == GlobalIsUsedByGlobal.end())
- continue;
- Changed |= set_union(UserGlobals, It->second);
- }
- }
- return Changed;
- }
-
- void propagateGlobalToFunctionReferences(
- OneToManyMapTy<const GlobalVariable *, const GlobalVariable *>
- &GlobalIsUsedByGlobal) {
- for (auto &[GV, UserGlobals] : GlobalIsUsedByGlobal) {
- auto &UserFunctions = GlobalIsUsedByFun[GV];
- for (const GlobalVariable *UserGV : UserGlobals) {
- auto It = GlobalIsUsedByFun.find(UserGV);
- if (It == GlobalIsUsedByFun.end())
- continue;
- set_union(UserFunctions, It->second);
- }
- }
- }
-
-public:
- void init(Module &M) {
- // Collect which global variables are referenced by which global variables
- // and which functions reference each global variables.
- OneToManyMapTy<const GlobalVariable *, const GlobalVariable *>
- GlobalIsUsedByGlobal;
- GlobalIsUsedByFun.clear();
- for (GlobalVariable &GV : M.globals())
- collectGlobalUsers(&GV, GlobalIsUsedByGlobal);
-
- // Compute indirect references by iterating until a fixed point is reached.
- while (propagateGlobalToGlobalUsers(GlobalIsUsedByGlobal))
- (void)0;
-
- propagateGlobalToFunctionReferences(GlobalIsUsedByGlobal);
- }
-
- const auto &getTransitiveUserFunctions(const GlobalVariable &GV) const {
- auto It = GlobalIsUsedByFun.find(&GV);
- if (It != GlobalIsUsedByFun.end())
- return It->second;
-
- using FunctionSetType = typename decltype(GlobalIsUsedByFun)::mapped_type;
- const static FunctionSetType Empty;
- return Empty;
- }
-};
class SPIRVEmitIntrinsics
: public ModulePass,
@@ -162,7 +74,6 @@ class SPIRVEmitIntrinsics
DenseMap<Instruction *, Constant *> AggrConsts;
DenseMap<Instruction *, Type *> AggrConstTypes;
DenseSet<Instruction *> AggrStores;
- GlobalVariableUsers GVUsers;
std::unordered_set<Value *> Named;
// map of function declarations to <pointer arg index => element type>
@@ -293,6 +204,7 @@ class SPIRVEmitIntrinsics
bool postprocessTypes(Module &M);
bool processFunctionPointers(Module &M);
void parseFunDeclarations(Module &M);
+
void useRoundingMode(ConstrainedFPIntrinsic *FPI, IRBuilder<> &B);
void emitUnstructuredLoopControls(Function &F, IRBuilder<> &B);
@@ -2207,36 +2119,13 @@ Instruction *SPIRVEmitIntrinsics::visitUnreachableInst(UnreachableInst &I) {
return &I;
}
-static bool
-shouldEmitIntrinsicsForGlobalValue(const GlobalVariableUsers &GVUsers,
- const GlobalVariable &GV,
- const Function *F) {
+void SPIRVEmitIntrinsics::processGlobalValue(GlobalVariable &GV,
+ IRBuilder<> &B) {
// Skip special artificial variables.
static const StringSet<> ArtificialGlobals{"llvm.global.annotations",
"llvm.compiler.used"};
- if (ArtificialGlobals.contains(GV.getName()))
- return false;
- auto &UserFunctions = GVUsers.getTransitiveUserFunctions(GV);
- if (UserFunctions.contains(F))
- return true;
-
- // Do not emit the intrinsics in this function, it's going to be emitted on
- // the functions that reference it.
- if (!UserFunctions.empty())
- return false;
-
- // Emit definitions for globals that are not referenced by any function on the
- // first function definition.
- const Module &M = *F->getParent();
- const Function &FirstDefinition = *M.getFunctionDefs().begin();
- return F == &FirstDefinition;
-}
-
-void SPIRVEmitIntrinsics::processGlobalValue(GlobalVariable &GV,
- IRBuilder<> &B) {
-
- if (!shouldEmitIntrinsicsForGlobalValue(GVUsers, GV, CurrF))
+ if (ArtificialGlobals.contains(GV.getName()))
return;
Constant *Init = nullptr;
@@ -3252,7 +3141,6 @@ bool SPIRVEmitIntrinsics::runOnModule(Module &M) {
parseFunDeclarations(M);
insertConstantsForFPFastMathDefault(M);
- GVUsers.init(M);
TodoType.clear();
for (auto &F : M)
diff --git a/llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_float_controls2/exec_mode3.ll b/llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_float_controls2/exec_mode3.ll
index 656030b4f5916..9cc9870c2cfe1 100644
--- a/llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_float_controls2/exec_mode3.ll
+++ b/llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_float_controls2/exec_mode3.ll
@@ -8,54 +8,39 @@
; CHECK: OpEntryPoint Kernel %[[#KERNEL_FLOAT_V:]] "k_float_controls_float_v"
; CHECK: OpEntryPoint Kernel %[[#KERNEL_ALL_V:]] "k_float_controls_all_v"
-; CHECK-DAG: %[[#INT32_TYPE:]] = OpTypeInt 32 0
-; CHECK-DAG: %[[#HALF_TYPE:]] = OpTypeFloat 16
-; CHECK-DAG: %[[#FLOAT_TYPE:]] = OpTypeFloat 32
-; CHECK-DAG: %[[#DOUBLE_TYPE:]] = OpTypeFloat 64
-; CHECK-DAG: %[[#CONST0:]] = OpConstantNull %[[#INT32_TYPE]]
-; CHECK-DAG: %[[#CONST131079:]] = OpConstant %[[#INT32_TYPE]] 131079
-
-; CHECK-DAG: %[[#HALF_V_TYPE:]] = OpTypeVector %[[#HALF_TYPE]]
-; CHECK-DAG: %[[#FLOAT_V_TYPE:]] = OpTypeVector %[[#FLOAT_TYPE]]
-; CHECK-DAG: %[[#DOUBLE_V_TYPE:]] = OpTypeVector %[[#DOUBLE_TYPE]]
-
; We expect 130179 for float type.
-; CHECK-DAG: OpExecutionModeId %[[#KERNEL_FLOAT]] FPFastMathDefault %[[#FLOAT_TYPE]] %[[#CONST131079]]
-; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL]] FPFastMathDefault %[[#FLOAT_TYPE]] %[[#CONST131079]]
+; CHECK-DAG: OpExecutionModeId %[[#KERNEL_FLOAT]] FPFastMathDefault %[[#FLOAT_TYPE:]] %[[#CONST131079:]]
+; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL]] FPFastMathDefault %[[#FLOAT_TYPE:]] %[[#CONST131079]]
; We expect 0 for the rest of types because it's SignedZeroInfNanPreserve.
-; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL]] FPFastMathDefault %[[#HALF_TYPE]] %[[#CONST0]]
-; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL]] FPFastMathDefault %[[#DOUBLE_TYPE]] %[[#CONST0]]
+; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL]] FPFastMathDefault %[[#HALF_TYPE:]] %[[#CONST0:]]
+; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL]] FPFastMathDefault %[[#DOUBLE_TYPE:]] %[[#CONST0]]
; We expect 130179 for float type.
-; CHECK-DAG: OpExecutionModeId %[[#KERNEL_FLOAT_V]] FPFastMathDefault %[[#FLOAT_TYPE]] %[[#CONST131079]]
-; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL_V]] FPFastMathDefault %[[#FLOAT_TYPE]] %[[#CONST131079]]
+; CHECK-DAG: OpExecutionModeId %[[#KERNEL_FLOAT_V]] FPFastMathDefault %[[#FLOAT_TYPE:]] %[[#CONST131079]]
+; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL_V]] FPFastMathDefault %[[#FLOAT_TYPE:]] %[[#CONST131079]]
; We expect 0 for the rest of types because it's SignedZeroInfNanPreserve.
-; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL_V]] FPFastMathDefault %[[#DOUBLE_TYPE]] %[[#CONST0]]
-; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL_V]] FPFastMathDefault %[[#HALF_TYPE]] %[[#CONST0]]
+; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL_V]] FPFastMathDefault %[[#DOUBLE_TYPE:]] %[[#CONST0]]
+; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL_V]] FPFastMathDefault %[[#HALF_TYPE:]] %[[#CONST0]]
+
+; CHECK-DAG: OpDecorate %[[#addRes:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
+; CHECK-DAG: OpDecorate %[[#addResH:]] FPFastMathMode None
+; CHECK-DAG: OpDecorate %[[#addResF:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
+; CHECK-DAG: OpDecorate %[[#addResD:]] FPFastMathMode None
+; CHECK-DAG: OpDecorate %[[#addRes_V:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
+; CHECK-DAG: OpDecorate %[[#addResH_V:]] FPFastMathMode None
+; CHECK-DAG: OpDecorate %[[#addResF_V:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
+; CHECK-DAG: OpDecorate %[[#addResD_V:]] FPFastMathMode None
-; CHECK-DAG: OpName %[[#G_addResH:]] "G_addResH"
-; CHECK-DAG: OpName %[[#G_addResF:]] "G_addResF"
-; CHECK-DAG: OpName %[[#G_addResD:]] "G_addResD"
-; CHECK-DAG: OpName %[[#G_addResV:]] "G_addResV"
-; CHECK-DAG: OpName %[[#G_addResH_V:]] "G_addResH_V"
-; CHECK-DAG: OpName %[[#G_addResF_V:]] "G_addResF_V"
-; CHECK-DAG: OpName %[[#G_addResD_V:]] "G_addResD_V"
-
-; CHECK-DAG: OpStore %[[#G_addResH]] %[[#addResH:]]
-; CHECK-DAG: OpStore %[[#G_addResF]] %[[#addResF:]]
-; CHECK-DAG: OpStore %[[#G_addResD]] %[[#addResD:]]
-; CHECK-DAG: OpStore %[[#G_addResV]] %[[#addResV:]]
-; CHECK-DAG: OpStore %[[#G_addResH_V]] %[[#addResH_V:]]
-; CHECK-DAG: OpStore %[[#G_addResF_V]] %[[#addResF_V:]]
-; CHECK-DAG: OpStore %[[#G_addResD_V]] %[[#addResD_V:]]
+; CHECK-DAG: %[[#INT32_TYPE:]] = OpTypeInt 32 0
+; CHECK-DAG: %[[#HALF_TYPE]] = OpTypeFloat 16
+; CHECK-DAG: %[[#FLOAT_TYPE]] = OpTypeFloat 32
+; CHECK-DAG: %[[#DOUBLE_TYPE]] = OpTypeFloat 64
+; CHECK-DAG: %[[#CONST0]] = OpConstantNull %[[#INT32_TYPE]]
+; CHECK-DAG: %[[#CONST131079]] = OpConstant %[[#INT32_TYPE]] 131079
-; CHECK-DAG: OpDecorate %[[#addResH]] FPFastMathMode None
-; CHECK-DAG: OpDecorate %[[#addResF]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
-; CHECK-DAG: OpDecorate %[[#addResD]] FPFastMathMode None
-; CHECK-DAG: OpDecorate %[[#addResV]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
-; CHECK-DAG: OpDecorate %[[#addResH_V]] FPFastMathMode None
-; CHECK-DAG: OpDecorate %[[#addResF_V]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
-; CHECK-DAG: OpDecorate %[[#addResD_V]] FPFastMathMode None
+; CHECK-DAG: %[[#HALF_V_TYPE:]] = OpTypeVector %[[#HALF_TYPE]]
+; CHECK-DAG: %[[#FLOAT_V_TYPE:]] = OpTypeVector %[[#FLOAT_TYPE]]
+; CHECK-DAG: %[[#DOUBLE_V_TYPE:]] = OpTypeVector %[[#DOUBLE_TYPE]]
@G_addRes = global float 0.0
@G_addResH = global half 0.0
@@ -68,8 +53,7 @@
define dso_local dllexport spir_kernel void @k_float_controls_float(float %f) {
entry:
-; CHECK-DAG: %[[#addRes:]] = OpFAdd %[[#FLOAT_TYPE]]
-; CHECK-DAG: OpDecorate %[[#addRes]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
+; CHECK-DAG: %[[#addRes]] = OpFAdd %[[#FLOAT_TYPE]]
%addRes = fadd float %f, %f
store volatile float %addRes, ptr @G_addRes
ret void
@@ -91,7 +75,7 @@ entry:
define dso_local dllexport spir_kernel void @k_float_controls_float_v(<2 x float> %f) {
entry:
-; CHECK-DAG: %[[#addResV]] = OpFAdd %[[#FLOAT_V_TYPE]]
+; CHECK-DAG: %[[#addRes_V]] = OpFAdd %[[#FLOAT_V_TYPE]]
%addRes = fadd <2 x float> %f, %f
store volatile <2 x float> %addRes, ptr @G_addResV
ret void
diff --git a/llvm/test/CodeGen/SPIRV/extensions/SPV_NV_shader_atomic_fp16_vector/atomicrmw_faddfsub_vec_float16.ll b/llvm/test/CodeGen/SPIRV/extensions/SPV_NV_shader_atomic_fp16_vector/atomicrmw_faddfsub_vec_float16.ll
index 733b356d82ff5..36f6e38fc75de 100644
--- a/llvm/test/CodeGen/SPIRV/extensions/SPV_NV_shader_atomic_fp16_vector/atomicrmw_faddfsub_vec_float16.ll
+++ b/llvm/test/CodeGen/SPIRV/extensions/SPV_NV_shader_atomic_fp16_vector/atomicrmw_faddfsub_vec_float16.ll
@@ -8,20 +8,20 @@
; CHECK-DAG: Capability AtomicFloat16VectorNV
; CHECK: Extension "SPV_NV_shader_atomic_fp16_vector"
; CHECK-DAG: %[[TyF16:[0-9]+]] = OpTypeFloat 16
-; CHECK-DAG: %[[TyF16Vec2:[0-9]+]] = OpTypeVector %[[TyF16]] 2
-; CHECK-DAG: %[[TyF16Vec4:[0-9]+]] = OpTypeVector %[[TyF16]] 4
-; CHECK-DAG: %[[TyF16Vec4Ptr:[0-9]+]] = OpTypePointer {{[a-zA-Z]+}} %[[TyF16Vec4]]
-; CHECK-DAG: %[[TyF16Vec2Ptr:[0-9]+]] = OpTypePointer {{[a-zA-Z]+}} %[[TyF16Vec2]]
-; CHECK-DAG: %[[TyInt32:[0-9]+]] = OpTypeInt 32 0
-; CHECK-DAG: %[[ConstF16:[0-9]+]] = OpConstant %[[TyF16]] 20800{{$}}
-; CHECK-DAG: %[[Const0F16Vec2:[0-9]+]] = OpConstantNull %[[TyF16Vec2]]
-; CHECK-DAG: %[[f:[0-9]+]] = OpVariable %[[TyF16Vec2Ptr]] CrossWorkgroup %[[Const0F16Vec2]]
-; CHECK-DAG: %[[Const0F16Vec4:[0-9]+]] = OpConstantNull %[[TyF16Vec4]]
-; CHECK-DAG: %[[g:[0-9]+]] = OpVariable %[[TyF16Vec4Ptr]] CrossWorkgroup %[[Const0F16Vec4]]
-; CHECK-DAG: %[[ConstF16Vec2:[0-9]+]] = OpConstantComposite %[[TyF16Vec2]] %[[ConstF16]] %[[ConstF16]]
-; CHECK-DAG: %[[ScopeAllSvmDevices:[0-9]+]] = OpConstantNull %[[TyInt32]]
-; CHECK-DAG: %[[MemSeqCst:[0-9]+]] = OpConstant %[[TyInt32]] 16{{$}}
-; CHECK-DAG: %[[ConstF16Vec4:[0-9]+]] = OpConstantComposite %[[TyF16Vec4]] %[[ConstF16]] %[[ConstF16]] %[[ConstF16]] %[[ConstF16]]
+; CHECK: %[[TyF16Vec2:[0-9]+]] = OpTypeVector %[[TyF16]] 2
+; CHECK: %[[TyF16Vec4:[0-9]+]] = OpTypeVector %[[TyF16]] 4
+; CHECK: %[[TyF16Vec4Ptr:[0-9]+]] = OpTypePointer {{[a-zA-Z]+}} %[[TyF16Vec4]]
+; CHECK: %[[TyF16Vec2Ptr:[0-9]+]] = OpTypePointer {{[a-zA-Z]+}} %[[TyF16Vec2]]
+; CHECK: %[[TyInt32:[0-9]+]] = OpTypeInt 32 0
+; CHECK: %[[ConstF16:[0-9]+]] = OpConstant %[[TyF16]] 20800{{$}}
+; CHECK: %[[Const0F16Vec2:[0-9]+]] = OpConstantNull %[[TyF16Vec2]]
+; CHECK: %[[f:[0-9]+]] = OpVariable %[[TyF16Vec2Ptr]] CrossWorkgroup %[[Const0F16Vec2]]
+; CHECK: %[[Const0F16Vec4:[0-9]+]] = OpConstantNull %[[TyF16Vec4]]
+; CHECK: %[[g:[0-9]+]] = OpVariable %[[TyF16Vec4Ptr]] CrossWorkgroup %[[Const0F16Vec4]]
+; CHECK: %[[ConstF16Vec2:[0-9]+]] = OpConstantComposite %[[TyF16Vec2]] %[[ConstF16]] %[[ConstF16]]
+; CHECK: %[[ScopeAllSvmDevices:[0-9]+]] = OpConstantNull %[[TyInt32]]
+; CHECK: %[[MemSeqCst:[0-9]+]] = OpConstant %[[TyInt32]] 16{{$}}
+; CHECK: %[[ConstF16Vec4:[0-9]+]] = OpConstantComposite %[[TyF16Vec4]] %[[ConstF16]] %[[ConstF16]] %[[ConstF16]] %[[ConstF16]]
@f = common dso_local local_unnamed_addr addrspace(1) global <2 x half> <half 0.000000e+00, half 0.000000e+00>
@g = common dso_local local_unnamed_addr addrspace(1) global <4 x half> <half 0.000000e+00, half 0.000000e+00, half 0.000000e+00, half 0.000000e+00>
@@ -44,4 +44,4 @@ entry:
%addval = atomicrmw fadd ptr addrspace(1) @g, <4 x half> <half 42.000000e+00, half 42.000000e+00, half 42.000000e+00, half 42.000000e+00> seq_cst
%subval = atomicrmw fsub ptr addrspace(1) @g, <4 x half> <half 42.000000e+00, half 42.000000e+00, half 42.000000e+00, half 42.000000e+00> seq_cst
ret void
-}
+}
\ No newline at end of file
diff --git a/llvm/test/CodeGen/SPIRV/extensions/SPV_NV_shader_atomic_fp16_vector/atomicrmw_fminfmax_vec_float16.ll b/llvm/test/CodeGen/SPIRV/extensions/SPV_NV_shader_atomic_fp16_vector/atomicrmw_fminfmax_vec_float16.ll
index 14e98a6fb1f05..7ac772bf5d094 100644
--- a/llvm/test/CodeGen/SPIRV/extensions/SPV_NV_shader_atomic_fp16_vector/atomicrmw_fminfmax_vec_float16.ll
+++ b/llvm/test/CodeGen/SPIRV/extensions/SPV_NV_shader_atomic_fp16_vector/atomicrmw_fminfmax_vec_float16.ll
@@ -8,20 +8,20 @@
; CHECK-DAG: Capability AtomicFloat16VectorNV
; CHECK: Extension "SPV_NV_shader_atomic_fp16_vector"
; CHECK-DAG: %[[TyF16:[0-9]+]] = OpTypeFloat 16
-; CHECK-DAG: %[[TyF16Vec2:[0-9]+]] = OpTypeVector %[[TyF16]] 2
-; CHECK-DAG: %[[TyF16Vec4:[0-9]+]] = OpTypeVector %[[TyF16]] 4
-; CHECK-DAG: %[[TyF16Vec4Ptr:[0-9]+]] = OpTypePointer {{[a-zA-Z]+}} %[[TyF16Vec4]]
-; CHECK-DAG: %[[TyF16Vec2Ptr:[0-9]+]] = OpTypePointer {{[a-zA-Z]+}} %[[TyF16Vec2]]
-; CHECK-DAG: %[[TyInt32:[0-9]+]] = OpTypeInt 32 0
-; CHECK-DAG: %[[ConstF16:[0-9]+]] = OpConstant %[[TyF16]] 20800{{$}}
-; CHECK-DAG: %[[Const0F16Vec2:[0-9]+]] = OpConstantNull %[[TyF16Vec2]]
-; CHECK-DAG: %[[f:[0-9]+]] = OpVariable %[[TyF16Vec2Ptr]] CrossWorkgroup %[[Const0F16Vec2]]
-; CHECK-DAG: %[[Const0F16Vec4:[0-9]+]] = OpConstantNull %[[TyF16Vec4]]
-; CHECK-DAG: %[[g:[0-9]+]] = OpVariable %[[TyF16Vec4Ptr]] CrossWorkgroup %[[Const0F16Vec4]]
-; CHECK-DAG: %[[ConstF16Vec2:[0-9]+]] = OpConstantComposite %[[TyF16Vec2]] %[[ConstF16]] %[[ConstF16]]
-; CHECK-DAG: %[[ScopeAllSvmDevices:[0-9]+]] = OpConstantNull %[[TyInt32]]
-; CHECK-DAG: %[[MemSeqCst:[0-9]+]] = OpConstant %[[TyInt32]] 16{{$}}
-; CHECK-DAG: %[[ConstF16Vec4:[0-9]+]] = OpConstantComposite %[[TyF16Vec4]] %[[ConstF16]] %[[ConstF16]] %[[ConstF16]] %[[ConstF16]]
+; CHECK: %[[TyF16Vec2:[0-9]+]] = OpTypeVector %[[TyF16]] 2
+; CHECK: %[[TyF16Vec4:[0-9]+]] = OpTypeVector %[[TyF16]] 4
+; CHECK: %[[TyF16Vec4Ptr:[0-9]+]] = OpTypePointer {{[a-zA-Z]+}} %[[TyF16Vec4]]
+; CHECK: %[[TyF16Vec2Ptr:[0-9]+]] = OpTypePointer {{[a-zA-Z]+}} %[[TyF16Vec2]]
+; CHECK: %[[TyInt32:[0-9]+]] = OpTypeInt 32 0
+; CHECK: %[[ConstF16:[0-9]+]] = OpConstant %[[TyF16]] 20800{{$}}
+; CHECK: %[[Const0F16Vec2:[0-9]+]] = OpConstantNull %[[TyF16Vec2]]
+; CHECK: %[[f:[0-9]+]] = OpVariable %[[TyF16Vec2Ptr]] CrossWorkgroup %[[Const0F16Vec2]]
+; CHECK: %[[Const0F16Vec4:[0-9]+]] = OpConstantNull %[[TyF16Vec4]]
+; CHECK: %[[g:[0-9]+]] = OpVariable %[[TyF16Vec4Ptr]] CrossWorkgroup %[[Const0F16Vec4]]
+; CHECK: %[[ConstF16Vec2:[0-9]+]] = OpConstantComposite %[[TyF16Vec2]] %[[ConstF16]] %[[ConstF16]]
+; CHECK: %[[ScopeAllSvmDevices:[0-9]+]] = OpConstantNull %[[TyInt32]]
+; CHECK: %[[MemSeqCst:[0-9]+]] = OpConstant %[[TyInt32]] 16{{$}}
+; CHECK: %[[ConstF16Vec4:[0-9]+]] = OpConstantComposite %[[TyF16Vec4]] %[[ConstF16]] %[[ConstF16]] %[[ConstF16]] %[[ConstF16]]
@f = common dso_local local_unnamed_addr addrspace(1) global <2 x half> <half 0.000000e+00, half 0.000000e+00>
@g = common dso_local local_unnamed_addr addrspace(1) global <4 x half> <half 0.000000e+00, half 0.000000e+00, half 0.000000e+00, half 0.000000e+00>
@@ -42,4 +42,4 @@ entry:
%minval = atomicrmw fmin ptr addrspace(1) @g, <4 x half> <half 42.000000e+00, half 42.000000e+00, half 42.000000e+00, half 42.000000e+00> seq_cst
%maxval = atomicrmw fmax ptr addrspace(1) @g, <4 x half> <half 42.000000e+00, half 42.000000e+00, half 42.000000e+00, half 42.000000e+00> seq_cst
ret void
-}
+}
\ No newline at end of file
diff --git a/llvm/test/CodeGen/SPIRV/pointers/fun-with-aggregate-arg-in-const-init.ll b/llvm/test/CodeGen/SPIRV/pointers/fun-with-aggregate-arg-in-const-init.ll
index ffac585669c26..ec3fd41f7de9e 100644
--- a/llvm/test/CodeGen/SPIRV/pointers/fun-with-aggregate-arg-in-const-init.ll
+++ b/llvm/test/CodeGen/SPIRV/pointers/fun-with-aggregate-arg-in-const-init.ll
@@ -6,57 +6,47 @@
; CHECK-DAG: OpExtension "SPV_INTEL_function_pointers"
; CHECK-DAG: OpName %[[#fArray:]] "array"
; CHECK-DAG: OpName %[[#fStruct:]] "struct"
-; CHECK-DAG: OpName %[[#f0:]] "f0"
-; CHECK-DAG: OpName %[[#f1:]] "f1"
-; CHECK-DAG: OpName %[[#f2:]] "f2"
; CHECK-DAG: %[[#Int8Ty:]] = OpTypeInt 8 0
-; CHECK-DAG: %[[#GlobalInt8PtrTy:]] = OpTypePointer CrossWorkgroup %[[#Int8Ty]]
-; CHECK-DAG: %[[#VoidTy:]] = OpTypeVoid
-; CHECK-DAG: %[[#TestFnTy:]] = OpTypeFunction %[[#VoidTy]] %[[#GlobalInt8PtrTy]]
-; CHECK-DAG: %[[#F16Ty:]] = OpTypeFloat 16
-; CHECK-DAG: %[[#t_halfTy:]] = OpTypeStruct %[[#F16Ty]]
-; CHECK-DAG: %[[#FnTy:]] = OpTypeFunction %[[#t_halfTy]] %[[#GlobalInt8PtrTy]] %[[#t_halfTy]]
-; CHECK-DAG: %[[#IntelFnPtrTy:]] = OpTypePointer CodeSectionINTEL %[[#FnTy]]
-; CHECK-DAG: %[[#Int8PtrTy:]] = OpTypePointer Function %[[#Int8Ty]]
-; CHECK-DAG: %[[#Int32Ty:]] = OpTypeInt 32 0
-; CHECK-DAG: %[[#I32Const3:]] = OpConstant %[[#Int32Ty]] 3
-; CHECK-DAG: %[[#FnArrTy:]] = OpTypeArray %[[#Int8PtrTy]] %[[#I32Const3]]
-; CHECK-DAG: %[[#GlobalFnArrPtrTy:]] = OpTypePointer CrossWorkgroup %[[#FnArrTy]]
-; CHECK...
[truncated]
|
sarnex
left a comment
There was a problem hiding this comment.
lgtm assuming this is just a git revert with no other changes
Yes, no other changes. Just a revert. |
|
I kind of feel, that at least some of the recently reported sanitizer issues are attributed to #179154 , though I can't explain, why SPIR-V test has failed. |
I reproduced the issue at least on |
|
I've reduced the test. I'm not sure the PR was the cause, but it triggered it. The minimal reproducer I've got is: ; llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown reduced.ll -o /dev/null --spirv-ext=+SPV_INTEL_function_pointers
define void @foo() {
entry:
store ptr addrspace(4) addrspacecast (ptr @foo to ptr addrspace(4)), ptr null, align 8
ret void
}And it also fails over main with the PR reverted. |
…erences them (llvm#178143 (llvm#179268) This reverts commit 1daef59. From the ASAN buildbot: ```bash FAIL: LLVM :: CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fun-ptr-addrcast.ll (46596 of 94488) ******************** TEST 'LLVM :: CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fun-ptr-addrcast.ll' FAILED ******************** Exit Code: 2 Command Output (stdout): -- # RUN: at line 5 /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fun-ptr-addrcast.ll -o - --spirv-ext=+SPV_INTEL_function_pointers | /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fun-ptr-addrcast.ll # executed command: /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fun-ptr-addrcast.ll -o - --spirv-ext=+SPV_INTEL_function_pointers # note: command had no output on stdout or stderr # error: command failed with exit status: 1 # executed command: /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fun-ptr-addrcast.ll # .---command stderr------------ # | FileCheck error: '<stdin>' is empty. # | FileCheck command line: /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fun-ptr-addrcast.ll # `----------------------------- # error: command failed with exit status: 2 ``` I did not confirm this commit is introducing the issue. But since its likely related I'm reverting it until I confirm everything is ok or fix it.
This reverts commit 1daef59.
From the ASAN buildbot:
I did not confirm this commit is introducing the issue. But since its likely related I'm reverting it until I confirm everything is ok or fix it.