Skip to content

Commit 44f60c8

Browse files
JonPssonJonPsson1
authored andcommitted
VerifyIntegerArgs()
i8 test. LangRef text. tests IP Tests passing, mostly with -no-arg-exts NoExtend IP NoExt attribute instead tests at least passing ZeroExt flag instead of NoExt flag Updated was aab1ee8 IP Verify by default Fix in NoExt handling. SystemZ changes for ver was 02868e6
1 parent 00def06 commit 44f60c8

File tree

24 files changed

+10061
-25
lines changed

24 files changed

+10061
-25
lines changed

clang/include/clang/CodeGen/CGFunctionInfo.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class ABIArgInfo {
116116
bool InReg : 1; // isDirect() || isExtend() || isIndirect()
117117
bool CanBeFlattened: 1; // isDirect()
118118
bool SignExt : 1; // isExtend()
119+
bool ZeroExt : 1; // isExtend()
119120

120121
bool canHavePaddingType() const {
121122
return isDirect() || isExtend() || isIndirect() || isIndirectAliased() ||
@@ -137,7 +138,7 @@ class ABIArgInfo {
137138
PaddingInReg(false), InAllocaSRet(false),
138139
InAllocaIndirect(false), IndirectByVal(false), IndirectRealign(false),
139140
SRetAfterThis(false), InReg(false), CanBeFlattened(false),
140-
SignExt(false) {}
141+
SignExt(false), ZeroExt(false) {}
141142

142143
static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
143144
llvm::Type *Padding = nullptr,
@@ -174,19 +175,26 @@ class ABIArgInfo {
174175
AI.setPaddingType(nullptr);
175176
AI.setDirectOffset(0);
176177
AI.setDirectAlign(0);
177-
AI.setSignExt(false);
178+
AI.setZeroExt(true);
178179
return AI;
179180
}
180181

181182
// ABIArgInfo will record the argument as being extended based on the sign
182-
// of its type.
183+
// of its type. Produces a sign or zero extension.
183184
static ABIArgInfo getExtend(QualType Ty, llvm::Type *T = nullptr) {
184185
assert(Ty->isIntegralOrEnumerationType() && "Unexpected QualType");
185186
if (Ty->hasSignedIntegerRepresentation())
186187
return getSignExtend(Ty, T);
187188
return getZeroExtend(Ty, T);
188189
}
189190

191+
// Struct in register marked explicitly as not needing extension.
192+
static ABIArgInfo getNoExtend(llvm::IntegerType *T) {
193+
auto AI = ABIArgInfo(Extend);
194+
AI.setCoerceToType(T);
195+
return AI;
196+
}
197+
190198
static ABIArgInfo getExtendInReg(QualType Ty, llvm::Type *T = nullptr) {
191199
auto AI = getExtend(Ty, T);
192200
AI.setInReg(true);
@@ -326,14 +334,28 @@ class ABIArgInfo {
326334
}
327335

328336
bool isSignExt() const {
329-
assert(isExtend() && "Invalid kind!");
337+
assert(isExtend() && (SignExt + ZeroExt <= 1) && "Invalid kind / flags!");
330338
return SignExt;
331339
}
332340
void setSignExt(bool SExt) {
333341
assert(isExtend() && "Invalid kind!");
334342
SignExt = SExt;
335343
}
336344

345+
bool isZeroExt() const {
346+
assert(isExtend() && (SignExt + ZeroExt <= 1) && "Invalid kind / flags!");
347+
return ZeroExt;
348+
}
349+
void setZeroExt(bool ZExt) {
350+
assert(isExtend() && "Invalid kind!");
351+
ZeroExt = ZExt;
352+
}
353+
354+
bool isNoExt() const {
355+
assert(isExtend() && (SignExt + ZeroExt <= 1) && "Invalid kind / flags!");
356+
return !SignExt && !ZeroExt;
357+
}
358+
337359
llvm::Type *getPaddingType() const {
338360
return (canHavePaddingType() ? PaddingType : nullptr);
339361
}

clang/lib/CodeGen/CGCall.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,7 +2183,7 @@ static bool DetermineNoUndef(QualType QTy, CodeGenTypes &Types,
21832183
if (AI.getKind() == ABIArgInfo::Indirect ||
21842184
AI.getKind() == ABIArgInfo::IndirectAliased)
21852185
return true;
2186-
if (AI.getKind() == ABIArgInfo::Extend)
2186+
if (AI.getKind() == ABIArgInfo::Extend && !AI.isNoExt())
21872187
return true;
21882188
if (!DL.typeSizeEqualsStoreSize(Ty))
21892189
// TODO: This will result in a modest amount of values not marked noundef
@@ -2566,9 +2566,12 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
25662566
case ABIArgInfo::Extend:
25672567
if (RetAI.isSignExt())
25682568
RetAttrs.addAttribute(llvm::Attribute::SExt);
2569-
else
2569+
else if (RetAI.isZeroExt())
25702570
RetAttrs.addAttribute(llvm::Attribute::ZExt);
2571-
[[fallthrough]];
2571+
else
2572+
RetAttrs.addAttribute(llvm::Attribute::NoExt);
2573+
[[fallthrough]];
2574+
25722575
case ABIArgInfo::Direct:
25732576
if (RetAI.getInReg())
25742577
RetAttrs.addAttribute(llvm::Attribute::InReg);
@@ -2707,9 +2710,12 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
27072710
case ABIArgInfo::Extend:
27082711
if (AI.isSignExt())
27092712
Attrs.addAttribute(llvm::Attribute::SExt);
2710-
else
2713+
else if (AI.isZeroExt())
27112714
Attrs.addAttribute(llvm::Attribute::ZExt);
2715+
else
2716+
Attrs.addAttribute(llvm::Attribute::NoExt);
27122717
[[fallthrough]];
2718+
27132719
case ABIArgInfo::Direct:
27142720
if (ArgNo == 0 && FI.isChainCall())
27152721
Attrs.addAttribute(llvm::Attribute::Nest);

0 commit comments

Comments
 (0)