Skip to content

Commit 31c304f

Browse files
committed
[NFC] Cleanup for compiler warnings
Many NFC (hopefully) changes, to resolve warnings for: * Unused variables * Deprecated functions * type->getPointerTo(ASpace) => llvm::PointerType::get(type->getContext(), ASpace) * Intrinsic::getDeclaration => Intrinsic::getOrInsertDeclaration * Unknown escape sequence "\/" * `default:` switch target for exhaustive switch I don't believe any of these are applicable upstream, or in the case of at least one of the unittest fixes the change came direclty from upstream and simply hadn't made it to us somehow.
1 parent 808bf02 commit 31c304f

File tree

14 files changed

+27
-40
lines changed

14 files changed

+27
-40
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9572,8 +9572,8 @@ static void emitTargetCallKernelLaunch(
95729572
CGF.Builder.CreateAlloca(RedVarType, nullptr, "d_team_vals");
95739573
Address DTeamValsAddr(DTeamValsInst, RedVarType,
95749574
Context.getTypeAlignInChars(RedVarQualType));
9575-
llvm::Value *NullPtrDTeamVals =
9576-
llvm::ConstantPointerNull::get(RedVarType->getPointerTo());
9575+
llvm::Value *NullPtrDTeamVals = llvm::ConstantPointerNull::get(
9576+
llvm::PointerType::get(CGF.getLLVMContext(), /*AddressSpace=*/0));
95779577
CGF.Builder.CreateStore(NullPtrDTeamVals, DTeamValsAddr);
95789578
} else {
95799579
// dteam_vals = omp_target_alloc(sizeof(red-type) * num_teams, devid)
@@ -9665,8 +9665,8 @@ static void emitTargetCallKernelLaunch(
96659665
Address DTeamsDoneAddr(
96669666
DTeamsDonePtrInst, CGF.Int32Ty,
96679667
Context.getTypeAlignInChars(Context.UnsignedIntTy));
9668-
llvm::Value *NullPtrDTeamsDone =
9669-
llvm::ConstantPointerNull::get(CGF.Int32Ty->getPointerTo());
9668+
llvm::Value *NullPtrDTeamsDone = llvm::ConstantPointerNull::get(
9669+
llvm::PointerType::get(CGF.getLLVMContext(), /*AddressSpace=*/0));
96709670
CGF.Builder.CreateStore(NullPtrDTeamsDone, DTeamsDoneAddr);
96719671
} else {
96729672
// uint32 teams_done = 0

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ void CodeGenFunction::EmitNoLoopXteamScanPhaseTwoCode(
560560

561561
Address XteamRedSumArg1 = GetAddrOfLocalVar((*Args)[RVI.ArgPos]);
562562
llvm::Value *DTeamVals = Builder.CreateLoad(XteamRedSumArg1);
563+
(void)DTeamVals;
563564

564565
Address XteamRedSumArg3 = GetAddrOfLocalVar((*Args)[RVI.ArgPos + 2]);
565566
llvm::Value *DScanStorage = Builder.CreateLoad(XteamRedSumArg3);
@@ -850,9 +851,6 @@ void CodeGenFunction::EmitXteamScanPhaseTwo(const ForStmt *FStmt,
850851
DSegmentVals = DScanStorage;
851852
}
852853

853-
const Expr *OrigRedVarExpr = RVI.RedVarExpr;
854-
const DeclRefExpr *DRE = cast<DeclRefExpr>(OrigRedVarExpr);
855-
Address OrigRedVarAddr = EmitLValue(DRE).getAddress();
856854
RT.getXteamScanPhaseTwo(*this, Builder.CreateLoad(RVI.RedVarAddr),
857855
SegmentSize, DTeamVals, DScanStorage, DSegmentVals,
858856
ThreadStartIdx, BlockSize, IsInclusiveScan);

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -393,17 +393,17 @@ void CodeGenFunction::InitializeXteamRedCapturedVars(
393393
Builder.CreateAlloca(RedVarType, nullptr, "d_team_vals");
394394
Address DTeamValsAddr(DTeamValsInst, RedVarType,
395395
Context.getTypeAlignInChars(RedVarQualType));
396-
llvm::Value *NullPtrDTeamVals =
397-
llvm::ConstantPointerNull::get(RedVarType->getPointerTo());
396+
llvm::Value *NullPtrDTeamVals = llvm::ConstantPointerNull::get(
397+
llvm::PointerType::get(getLLVMContext(), /*AddressSpace=*/0));
398398
Builder.CreateStore(NullPtrDTeamVals, DTeamValsAddr);
399399

400400
// Placeholder for d_teams_done_ptr initialized to nullptr
401401
llvm::Value *DTeamsDonePtrInst =
402402
Builder.CreateAlloca(Int32Ty, nullptr, "d_teams_done_ptr");
403403
Address DTeamsDoneAddr(DTeamsDonePtrInst, Int32Ty,
404404
Context.getTypeAlignInChars(Context.UnsignedIntTy));
405-
llvm::Value *NullPtrDTeamsDone =
406-
llvm::ConstantPointerNull::get(Int32Ty->getPointerTo());
405+
llvm::Value *NullPtrDTeamsDone = llvm::ConstantPointerNull::get(
406+
llvm::PointerType::get(getLLVMContext(), /*AddressSpace=*/0));
407407
Builder.CreateStore(NullPtrDTeamsDone, DTeamsDoneAddr);
408408

409409
assert(DTeamValsInst && "Device team vals pointer cannot be null");
@@ -419,8 +419,8 @@ void CodeGenFunction::InitializeXteamRedCapturedVars(
419419
Address DScanStorageAddr(
420420
DScanStorageInst, RedVarType,
421421
Context.getTypeAlignInChars(Context.UnsignedIntTy));
422-
llvm::Value *NullPtrDScanStorage =
423-
llvm::ConstantPointerNull::get(RedVarType->getPointerTo());
422+
llvm::Value *NullPtrDScanStorage = llvm::ConstantPointerNull::get(
423+
llvm::PointerType::get(getLLVMContext(), /*AddressSpace=*/0));
424424
Builder.CreateStore(NullPtrDScanStorage, DScanStorageAddr);
425425

426426
assert(DScanStorageInst && "Device scan storage pointer cannot be null");
@@ -432,8 +432,8 @@ void CodeGenFunction::InitializeXteamRedCapturedVars(
432432
Address DSegmentValsAddr(
433433
DSegmentValsInst, RedVarType,
434434
Context.getTypeAlignInChars(Context.UnsignedIntTy));
435-
llvm::Value *NullPtrDSegmentVals =
436-
llvm::ConstantPointerNull::get(RedVarType->getPointerTo());
435+
llvm::Value *NullPtrDSegmentVals = llvm::ConstantPointerNull::get(
436+
llvm::PointerType::get(getLLVMContext(), /*AddressSpace=*/0));
437437
Builder.CreateStore(NullPtrDSegmentVals, DSegmentValsAddr);
438438

439439
assert(DSegmentValsInst && "Segment Vals Array pointer cannot be null");

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,8 @@ class CodeGenFunction : public CodeGenTypeCache {
11441144
if (Temp.getElementType() != TempAddr.emitRawPointer(CGF)->getType())
11451145
Temp = Address(CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
11461146
Temp.emitRawPointer(CGF),
1147-
TempAddr.emitRawPointer(CGF)->getType()->getPointerTo()),
1147+
llvm::PointerType::get(CGF.getLLVMContext(),
1148+
/*AddressSpace=*/0)),
11481149
CGF.Int8Ty, TempAddr.getAlignment());
11491150
CGF.Builder.CreateStore(TempAddr.emitRawPointer(CGF), Temp);
11501151
TempAddr = Temp;

clang/unittests/libclang/LibclangTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ static_assert(true, message);
12201220
const char *Args[] = {"-xc++", "-std=c++26"};
12211221
ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args,
12221222
std::size(Args), nullptr, 0, TUFlags);
1223-
ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0);
1223+
ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0u);
12241224
std::optional<CXCursor> staticAssertCsr;
12251225
Traverse([&](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
12261226
if (cursor.kind == CXCursor_StaticAssert) {
@@ -1229,7 +1229,7 @@ static_assert(true, message);
12291229
return CXChildVisit_Continue;
12301230
});
12311231
ASSERT_TRUE(staticAssertCsr.has_value());
1232-
size_t argCnt = 0;
1232+
int argCnt = 0;
12331233
Traverse(*staticAssertCsr, [&argCnt](CXCursor cursor, CXCursor parent) {
12341234
switch (argCnt) {
12351235
case 0:

llvm/include/llvm/Object/OffloadBinary.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ struct OffloadBundleEntry {
223223
<< ", ID Length = " << IDLength << ", ID = " << ID;
224224
}
225225
void dumpURI(raw_ostream &OS, StringRef filePath) {
226-
OS << ID.data() << "\tfile:\/\/" << filePath << "#offset=" << Offset
226+
OS << ID.data() << "\tfile://" << filePath << "#offset=" << Offset
227227
<< "&size=" << Size << "\n";
228228
}
229229
};
@@ -309,8 +309,6 @@ struct OffloadBundleURI {
309309
case MEMORY_URI:
310310
parseMemoryURI(str);
311311
break;
312-
default:
313-
report_fatal_error("Unrecognized URI type.");
314312
}
315313
}
316314

@@ -329,7 +327,6 @@ struct OffloadBundleURI {
329327
str = str.drop_front(OffsetStr.size());
330328

331329
if (str.consume_front("&size=")) {
332-
Size;
333330
str.getAsInteger(10, Size);
334331
} else
335332
report_fatal_error("Reading 'size' in URI.");

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,7 @@ void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
20182018
if (ProcessedLifetimes.insert(L).second) {
20192019
if (auto *AddCU = dyn_cast<DICompileUnit>(GV->getScope())) {
20202020
AddCULifetimeMap[AddCU].push_back(L);
2021-
} else if (auto *AddNS = dyn_cast<DINamespace>(GV->getScope())) {
2021+
} else if (isa<DINamespace>(GV->getScope())) {
20222022
// FIXME(KZHURAVL): Properly support DINamespace.
20232023
} else if (auto *AddSP = dyn_cast<DISubprogram>(GV->getScope())) {
20242024
SPLifetimeMap[AddSP].push_back(L);

llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,11 +991,9 @@ std::optional<NewOpResult> DwarfExpression::traverse(DIOp::Arg Arg,
991991
if (IsFragment)
992992
emitOp(dwarf::DW_OP_lit0);
993993

994-
unsigned RegSize = 0;
995994
for (auto &Reg : Regs) {
996995
if (Reg.SubRegSize % 8)
997996
return std::nullopt;
998-
RegSize += Reg.SubRegSize;
999997
if (Reg.DwarfRegNo >= 0)
1000998
addReg(Reg.DwarfRegNo, Reg.Comment);
1001999
emitOp(dwarf::DW_OP_piece);

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
14431443
const DbgDefInst &DDI = *cast<DbgDefInst>(II);
14441444
const Value *Referrer = DDI.getReferrer();
14451445
assert(Referrer);
1446-
if (const auto *UV = dyn_cast<UndefValue>(Referrer)) {
1446+
if (isa<UndefValue>(Referrer)) {
14471447
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
14481448
TII.get(TargetOpcode::DBG_DEF))
14491449
.addMetadata(DDI.getLifetime())

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,8 @@ FunctionCallee OpenMPIRBuilder::unsignedGetOrCreateAtomicCASRuntimeFunction(
689689

690690
assert(Fn && "Failed to create custom OpenMP atomic CAS runtime function");
691691
// Cast the function to the expected type if necessary
692-
Constant *C = ConstantExpr::getBitCast(Fn, FnTy->getPointerTo());
692+
Constant *C = ConstantExpr::getBitCast(
693+
Fn, llvm::PointerType::get(Fn->getContext(), /*AddressSpace=*/0));
693694
return {FnTy, C};
694695
}
695696

0 commit comments

Comments
 (0)