Skip to content

Commit 975477e

Browse files
committed
[CGBuiltin] Explicitly use inbounds GEP (NFCI)
All of these are inbounds as they access known offsets in fixed globals. NFCI because constant expression construction currently already infers this, this patch just makes it explicit.
1 parent 799316f commit 975477e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14074,7 +14074,7 @@ Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) {
1407414074
// Grab the appropriate field from __cpu_model.
1407514075
llvm::Value *Idxs[] = {ConstantInt::get(Int32Ty, 0),
1407614076
ConstantInt::get(Int32Ty, Index)};
14077-
llvm::Value *CpuValue = Builder.CreateGEP(STy, CpuModel, Idxs);
14077+
llvm::Value *CpuValue = Builder.CreateInBoundsGEP(STy, CpuModel, Idxs);
1407814078
CpuValue = Builder.CreateAlignedLoad(Int32Ty, CpuValue,
1407914079
CharUnits::fromQuantity(4));
1408014080

@@ -14116,7 +14116,7 @@ CodeGenFunction::EmitX86CpuSupports(std::array<uint32_t, 4> FeatureMask) {
1411614116
// global in the struct STy.
1411714117
Value *Idxs[] = {Builder.getInt32(0), Builder.getInt32(3),
1411814118
Builder.getInt32(0)};
14119-
Value *CpuFeatures = Builder.CreateGEP(STy, CpuModel, Idxs);
14119+
Value *CpuFeatures = Builder.CreateInBoundsGEP(STy, CpuModel, Idxs);
1412014120
Value *Features = Builder.CreateAlignedLoad(Int32Ty, CpuFeatures,
1412114121
CharUnits::fromQuantity(4));
1412214122

@@ -14137,7 +14137,7 @@ CodeGenFunction::EmitX86CpuSupports(std::array<uint32_t, 4> FeatureMask) {
1413714137
continue;
1413814138
Value *Idxs[] = {Builder.getInt32(0), Builder.getInt32(i - 1)};
1413914139
Value *Features = Builder.CreateAlignedLoad(
14140-
Int32Ty, Builder.CreateGEP(ATy, CpuFeatures2, Idxs),
14140+
Int32Ty, Builder.CreateInBoundsGEP(ATy, CpuFeatures2, Idxs),
1414114141
CharUnits::fromQuantity(4));
1414214142
// Check the value of the bit corresponding to the feature requested.
1414314143
Value *Mask = Builder.getInt32(M);
@@ -16724,7 +16724,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
1672416724
llvm::Value *Idxs[] = {ConstantInt::get(Int32Ty, 0),
1672516725
ConstantInt::get(Int32Ty, FieldIdx)};
1672616726

16727-
FieldValue = Builder.CreateGEP(STy, SysConf, Idxs);
16727+
FieldValue = Builder.CreateInBoundsGEP(STy, SysConf, Idxs);
1672816728
FieldValue = Builder.CreateAlignedLoad(Int32Ty, FieldValue,
1672916729
CharUnits::fromQuantity(4));
1673016730
} else if (SupportMethod == SYS_CALL) {

0 commit comments

Comments
 (0)