Skip to content

Commit fe5edca

Browse files
PietroGhgomarahmed1111
authored andcommitted
Use DefaultValue to compute md
1 parent 21c278c commit fe5edca

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

llvm/lib/SYCLLowerIR/SpecConstants.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
//===----------------------------------------------------------------------===//
1010

1111
#include "llvm/SYCLLowerIR/SpecConstants.h"
12-
#include "llvm/IR/DerivedTypes.h"
1312
#include "llvm/SYCLLowerIR/Support.h"
14-
#include "llvm/SYCLLowerIR/UtilsSYCLNativeCPU.h"
1513

1614
#include "llvm/ADT/APInt.h"
1715
#include "llvm/ADT/StringMap.h"
@@ -939,7 +937,6 @@ PreservedAnalyses SpecConstantsPass::run(Module &M,
939937
unsigned Size = M.getDataLayout().getTypeStoreSize(SCTy);
940938
uint64_t Align = M.getDataLayout().getABITypeAlign(SCTy).value();
941939

942-
943940
// Ensure correct alignment
944941
if (CurrentOffset % Align != 0) {
945942
// Compute necessary padding to correctly align the constant.
@@ -954,14 +951,9 @@ PreservedAnalyses SpecConstantsPass::run(Module &M,
954951
updatePaddingInLastMDNode(Ctx, SCMetadata, Padding);
955952
}
956953

957-
if (sycl::utils::isSYCLNativeCPU(M) && isa<StructType>(DefaultValue->getType())) {
958-
auto STy = cast<StructType>(DefaultValue->getType());
959-
SCMetadata[SymID] = generateSpecConstantMetadata(
960-
M, SymID, STy, NextID, /* is native spec constant */ false);
961-
} else {
962-
SCMetadata[SymID] = generateSpecConstantMetadata(
963-
M, SymID, SCTy, NextID, /* is native spec constant */ false);
964-
}
954+
auto *DefValTy = DefaultValue->getType();
955+
SCMetadata[SymID] = generateSpecConstantMetadata(
956+
M, SymID, DefValTy, NextID, /* is native spec constant */ false);
965957

966958
++NextID.ID;
967959
NextOffset += Size;

0 commit comments

Comments
 (0)