Skip to content

Commit

Permalink
Merge pull request #305 from hvdijk/use-const
Browse files Browse the repository at this point in the history
[NFC] Add more const.
  • Loading branch information
hvdijk authored Jan 19, 2024
2 parents b2f1da8 + fc153fa commit 12e10e5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ PreservedAnalyses compiler::ImageArgumentSubstitutionPass::run(
// Our wrapper hasn't been created with any parameter attributes, as the
// parameter types have changed. We must copy across all attributes from
// the non-sampler arguments to maintain program semantics.
AttributeList KernelAttrs = KernelF->getAttributes();
const AttributeList KernelAttrs = KernelF->getAttributes();
SmallVector<AttributeSet, 4> WrapperParamAttrs(KernelF->arg_size());

for (auto [OldArg, NewArg] :
zip(KernelF->args(), WrapperKernel->args())) {
// Copy parameter names across
unsigned ArgIdx = Args.size();
const unsigned ArgIdx = Args.size();
NewArg.setName(OldArg.getName());
if (OldArg.getType() == NewArg.getType()) {
Args.push_back(&NewArg);
Expand Down
5 changes: 3 additions & 2 deletions modules/compiler/source/base/source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,11 @@ static bool loadKernelAPIHeader(clang::CompilerInstance &compiler,
// stored inside the PCH file.
llvm::BitstreamCursor &Cursor = moduleFile->InputFilesCursor;
const clang::SavedStreamPosition SavedPosition(Cursor);
uint64_t Base = 0;
#if LLVM_VERSION_GREATER_EQUAL(18, 0)
// LLVM 18 introduces a new offset that should be included
Base = moduleFile->InputFilesOffsetBase;
const uint64_t Base = moduleFile->InputFilesOffsetBase;
#else
const uint64_t Base = 0;
#endif
if (Cursor.JumpToBit(Base + moduleFile->InputFileOffsets[0])) {
return false;
Expand Down
8 changes: 4 additions & 4 deletions modules/compiler/spirv-ll/source/builder_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3772,11 +3772,11 @@ llvm::Error Builder::create<OpImageQuerySizeLod>(
module.getInternalStructType(opFunctionParameter->IdResultType());
SPIRV_LL_ASSERT(imgTy, "Unknown/untracked image type");

llvm::StringRef imageTypeName = imgTy->getStructName();
const llvm::StringRef imageTypeName = imgTy->getStructName();

bool isArray = imageTypeName.contains("array");
bool is2D = imageTypeName.contains("2d");
bool is3D = imageTypeName.contains("3d");
const bool isArray = imageTypeName.contains("array");
const bool is2D = imageTypeName.contains("2d");
const bool is3D = imageTypeName.contains("3d");
#endif

llvm::Value *result = llvm::UndefValue::get(returnType);
Expand Down
2 changes: 1 addition & 1 deletion modules/compiler/utils/source/lld_linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Expected<std::unique_ptr<MemoryBuffer>> lldLinkToBinary(
const bool linkResult = !s.retCode && s.canRunAgain;
::lld::CommonLinkerContext::destroy();
#else
bool linkResult =
const bool linkResult =
lld::elf::link(lld_args, outs(), stderrOS,
/*exitEarly*/ false, /*disableOutput*/ false);
lld::CommonLinkerContext::destroy();
Expand Down

0 comments on commit 12e10e5

Please sign in to comment.