Skip to content

Commit a6604f3

Browse files
committed
address comments
1 parent a487d6b commit a6604f3

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.h

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,33 +111,22 @@ class LLVM_LIBRARY_VISIBILITY NVPTXAsmPrinter : public AsmPrinter {
111111

112112
// Copy Num bytes from Ptr.
113113
// if Bytes > Num, zero fill up to Bytes.
114-
unsigned addBytes(unsigned char *Ptr, int Num, int Bytes) {
115-
assert((curpos + Num) <= size);
116-
assert((curpos + Bytes) <= size);
117-
for (int i = 0; i < Num; ++i) {
118-
buffer[curpos] = Ptr[i];
119-
curpos++;
120-
}
121-
for (int i = Num; i < Bytes; ++i) {
122-
buffer[curpos] = 0;
123-
curpos++;
124-
}
125-
return curpos;
114+
void addBytes(const unsigned char *Ptr, unsigned Num, unsigned Bytes) {
115+
for (unsigned I : llvm::seq(Num))
116+
addByte(Ptr[I]);
117+
if (Bytes > Num)
118+
addZeros(Bytes - Num);
126119
}
127120

128121
void addByte(uint8_t Byte) {
129-
assert((curpos + 1) <= size);
122+
assert(curpos < size);
130123
buffer[curpos] = Byte;
131124
curpos++;
132125
}
133126

134-
unsigned addZeros(int Num) {
135-
assert((curpos + Num) <= size);
136-
for (int i = 0; i < Num; ++i) {
137-
buffer[curpos] = 0;
138-
curpos++;
139-
}
140-
return curpos;
127+
void addZeros(unsigned Num) {
128+
for (unsigned _ : llvm::seq(Num))
129+
addByte(0);
141130
}
142131

143132
void addSymbol(const Value *GVar, const Value *GVarBeforeStripping) {

0 commit comments

Comments
 (0)