Skip to content

Commit 6c1932f

Browse files
authored
[LLVM] Pass APInt by const reference. NFC. (#86278)
This patch adjusts argument passing for `APInt` to improve the compile-time. Compile-time improvement: https://llvm-compile-time-tracker.com/compare.php?from=d1f182c895728d89c5c3d198b133e212a5d9d4a3&to=32d6611af69bf4e76373f9bc7d9649650f760e48&stat=instructions:u
1 parent 635ea25 commit 6c1932f

File tree

6 files changed

+7
-6
lines changed

6 files changed

+7
-6
lines changed

llvm/include/llvm/Analysis/MemoryBuiltins.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ struct SizeOffsetAPInt : public SizeOffsetType<APInt, SizeOffsetAPInt> {
217217
SizeOffsetAPInt() = default;
218218
SizeOffsetAPInt(APInt Size, APInt Offset) : SizeOffsetType(Size, Offset) {}
219219

220-
static bool known(APInt V) { return V.getBitWidth() > 1; }
220+
static bool known(const APInt &V) { return V.getBitWidth() > 1; }
221221
};
222222

223223
/// Evaluate the size and offset of an object pointed to by a Value*

llvm/include/llvm/CodeGen/SelectionDAG.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ class SelectionDAG {
883883

884884
/// Returns a vector of type ResVT whose elements contain the linear sequence
885885
/// <0, Step, Step * 2, Step * 3, ...>
886-
SDValue getStepVector(const SDLoc &DL, EVT ResVT, APInt StepVal);
886+
SDValue getStepVector(const SDLoc &DL, EVT ResVT, const APInt &StepVal);
887887

888888
/// Returns a vector of type ResVT whose elements contain the linear sequence
889889
/// <0, 1, 2, 3, ...>

llvm/include/llvm/MC/MCStreamer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ class MCStreamer {
740740
/// Special case of EmitValue that avoids the client having
741741
/// to pass in a MCExpr for constant integers.
742742
virtual void emitIntValue(uint64_t Value, unsigned Size);
743-
virtual void emitIntValue(APInt Value);
743+
virtual void emitIntValue(const APInt &Value);
744744

745745
/// Special case of EmitValue that avoids the client having to pass
746746
/// in a MCExpr for constant integers & prints in Hex format for certain

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7855,7 +7855,7 @@ LegalizerHelper::LegalizeResult LegalizerHelper::lowerBswap(MachineInstr &MI) {
78557855

78567856
//{ (Src & Mask) >> N } | { (Src << N) & Mask }
78577857
static MachineInstrBuilder SwapN(unsigned N, DstOp Dst, MachineIRBuilder &B,
7858-
MachineInstrBuilder Src, APInt Mask) {
7858+
MachineInstrBuilder Src, const APInt &Mask) {
78597859
const LLT Ty = Dst.getLLTTy(*B.getMRI());
78607860
MachineInstrBuilder C_N = B.buildConstant(Ty, N);
78617861
MachineInstrBuilder MaskLoNTo0 = B.buildConstant(Ty, Mask);

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,8 @@ SDValue SelectionDAG::getStepVector(const SDLoc &DL, EVT ResVT) {
20312031
return getStepVector(DL, ResVT, One);
20322032
}
20332033

2034-
SDValue SelectionDAG::getStepVector(const SDLoc &DL, EVT ResVT, APInt StepVal) {
2034+
SDValue SelectionDAG::getStepVector(const SDLoc &DL, EVT ResVT,
2035+
const APInt &StepVal) {
20352036
assert(ResVT.getScalarSizeInBits() == StepVal.getBitWidth());
20362037
if (ResVT.isScalableVector())
20372038
return getNode(

llvm/lib/MC/MCStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void MCStreamer::emitIntValue(uint64_t Value, unsigned Size) {
141141
unsigned Index = IsLittleEndian ? 0 : 8 - Size;
142142
emitBytes(StringRef(reinterpret_cast<char *>(&Swapped) + Index, Size));
143143
}
144-
void MCStreamer::emitIntValue(APInt Value) {
144+
void MCStreamer::emitIntValue(const APInt &Value) {
145145
if (Value.getNumWords() == 1) {
146146
emitIntValue(Value.getLimitedValue(), Value.getBitWidth() / 8);
147147
return;

0 commit comments

Comments
 (0)