Skip to content

Commit 4b7020d

Browse files
committed
Try TargetOption
1 parent 0674559 commit 4b7020d

27 files changed

+73
-180
lines changed

clang/include/clang/CodeGen/CGFunctionInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ class ABIArgInfo {
192192
static ABIArgInfo getNoExtend(llvm::IntegerType *T) {
193193
auto AI = ABIArgInfo(Extend);
194194
AI.setCoerceToType(T);
195+
AI.setPaddingType(nullptr);
196+
AI.setDirectOffset(0);
197+
AI.setDirectAlign(0);
195198
return AI;
196199
}
197200

clang/lib/CodeGen/CGCall.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,8 +2570,7 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
25702570
RetAttrs.addAttribute(llvm::Attribute::ZExt);
25712571
else
25722572
RetAttrs.addAttribute(llvm::Attribute::NoExt);
2573-
[[fallthrough]];
2574-
2573+
[[fallthrough]];
25752574
case ABIArgInfo::Direct:
25762575
if (RetAI.getInReg())
25772576
RetAttrs.addAttribute(llvm::Attribute::InReg);
@@ -2715,7 +2714,6 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
27152714
else
27162715
Attrs.addAttribute(llvm::Attribute::NoExt);
27172716
[[fallthrough]];
2718-
27192717
case ABIArgInfo::Direct:
27202718
if (ArgNo == 0 && FI.isChainCall())
27212719
Attrs.addAttribute(llvm::Attribute::Nest);

clang/lib/CodeGen/Targets/SystemZ.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -447,17 +447,13 @@ ABIArgInfo SystemZABIInfo::classifyArgumentType(QualType Ty) const {
447447
// The structure is passed as an unextended integer, a float, or a double.
448448
if (isFPArgumentType(SingleElementTy)) {
449449
assert(Size == 32 || Size == 64);
450-
llvm::Type *PassTy;
451-
if (Size == 32)
452-
PassTy = llvm::Type::getFloatTy(getVMContext());
453-
else
454-
PassTy = llvm::Type::getDoubleTy(getVMContext());
455-
return ABIArgInfo::getDirect(PassTy);
450+
return ABIArgInfo::getDirect(
451+
Size == 32 ? llvm::Type::getFloatTy(getVMContext())
452+
: llvm::Type::getDoubleTy(getVMContext()));
456453
} else {
457454
llvm::IntegerType *PassTy = llvm::IntegerType::get(getVMContext(), Size);
458-
if (Size <= 32)
459-
return ABIArgInfo::getNoExtend(PassTy);
460-
return ABIArgInfo::getDirect(PassTy);
455+
return Size <= 32 ? ABIArgInfo::getNoExtend(PassTy)
456+
: ABIArgInfo::getDirect(PassTy);
461457
}
462458
}
463459

llvm/include/llvm/Bitcode/LLVMBitCodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ enum AttributeKindCodes {
759759
ATTR_KIND_INITIALIZES = 94,
760760
ATTR_KIND_HYBRID_PATCHABLE = 95,
761761
ATTR_KIND_SANITIZE_REALTIME = 96,
762-
ATTR_KIND_NO_EXT = 96, X
762+
ATTR_KIND_NO_EXT = 97,
763763
};
764764

765765
enum ComdatSelectionKindCodes {

llvm/include/llvm/Target/TargetOptions.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ namespace llvm {
155155
XRayFunctionIndex(true), DebugStrictDwarf(false), Hotpatch(false),
156156
PPCGenScalarMASSEntries(false), JMCInstrument(false),
157157
EnableCFIFixup(false), MisExpect(false), XCOFFReadOnlyPointers(false),
158+
VerifyArgABICompliance(true),
158159
FPDenormalMode(DenormalMode::IEEE, DenormalMode::IEEE) {}
159160

160161
/// DisableFramePointerElim - This returns true if frame pointer elimination
@@ -381,6 +382,12 @@ namespace llvm {
381382
/// into the RO data section.
382383
unsigned XCOFFReadOnlyPointers : 1;
383384

385+
/// When set to true, call/return argument extensions of narrow integers
386+
/// are verified in the target backend if it cares about them. This is
387+
/// not done with internal tools like llc that run many tests that ignore
388+
/// (lack) these extensions.
389+
unsigned VerifyArgABICompliance : 1;
390+
384391
/// Name of the stack usage file (i.e., .su file) if user passes
385392
/// -fstack-usage. If empty, it can be implied that -fstack-usage is not
386393
/// passed on the command line.

llvm/lib/AsmParser/LLLexer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,6 @@ lltok::Kind LLLexer::LexIdentifier() {
648648
KEYWORD(c);
649649

650650
KEYWORD(attributes);
651-
KEYWORD(noext);
652651
KEYWORD(sync);
653652
KEYWORD(async);
654653

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ using namespace llvm;
3434

3535
#define DEBUG_TYPE "systemz-lower"
3636

37-
static cl::opt<bool> DisableIntArgExtCheck(
38-
"no-argext-abi-check", cl::init(false),
39-
cl::desc("Do not verify that narrow int args are properly extended per the "
40-
"SystemZ ABI."));
41-
4237
namespace {
4338
// Represents information about a comparison.
4439
struct Comparison {
@@ -1481,27 +1476,6 @@ bool SystemZTargetLowering::mayBeEmittedAsTailCall(const CallInst *CI) const {
14811476
return CI->isTailCall();
14821477
}
14831478

1484-
// Verify that a narrow integer argument is extended to 64 bits or marked
1485-
// 'noext' (struct in reg).
1486-
static void VerifyIntegerArg(MVT VT, ISD::ArgFlagsTy Flags) {
1487-
if (VT.isInteger()) {
1488-
assert((VT == MVT::i32 || VT.getSizeInBits() >= 64) &&
1489-
"Unexpected integer argument VT.");
1490-
assert((VT != MVT::i32 ||
1491-
(Flags.isSExt() || Flags.isZExt() || Flags.isNoExt())) &&
1492-
"Narrow integer argument must have a valid extension type.");
1493-
}
1494-
}
1495-
1496-
// Verify that narrow integer arguments are extended as required by the ABI.
1497-
static void CheckNarrowIntegerArgs(SmallVectorImpl<ISD::OutputArg> &Outs) {
1498-
if (!DisableIntArgExtCheck) {
1499-
for (unsigned i = 0; i < Outs.size(); ++i)
1500-
VerifyIntegerArg(Outs[i].VT, Outs[i].Flags);
1501-
return;
1502-
}
1503-
}
1504-
15051479
// Value is a value that has been passed to us in the location described by VA
15061480
// (and so has type VA.getLocVT()). Convert Value to VA.getValVT(), chaining
15071481
// any loads onto Chain.
@@ -1948,8 +1922,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
19481922
if (auto *G = dyn_cast<GlobalAddressSDNode>(Callee))
19491923
if (const Function *Fn = dyn_cast<Function>(G->getGlobal()))
19501924
HasLocalLinkage = Fn->hasLocalLinkage();
1951-
if (!HasLocalLinkage && Subtarget.isTargetELF())
1952-
CheckNarrowIntegerArgs(Outs);
1925+
verifyNarrowIntegerArgs(Outs, HasLocalLinkage);
19531926

19541927
// Analyze the operands of the call, assigning locations to each operand.
19551928
SmallVector<CCValAssign, 16> ArgLocs;
@@ -2211,10 +2184,9 @@ SystemZTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
22112184
const SDLoc &DL, SelectionDAG &DAG) const {
22122185
MachineFunction &MF = DAG.getMachineFunction();
22132186

2214-
22152187
// Integer args <=32 bits should have an extension attribute.
2216-
if (!MF.getFunction().hasLocalLinkage() && Subtarget.isTargetELF())
2217-
CheckNarrowIntegerArgs(const_cast<SmallVectorImpl<ISD::OutputArg> &>(Outs));
2188+
verifyNarrowIntegerArgs(Outs, MF.getFunction().hasLocalLinkage());
2189+
22182190
// Assign locations to each returned value.
22192191
SmallVector<CCValAssign, 16> RetLocs;
22202192
CCState RetCCInfo(CallConv, IsVarArg, MF, RetLocs, *DAG.getContext());
@@ -9838,3 +9810,24 @@ SDValue SystemZTargetLowering::lowerVECREDUCE_ADD(SDValue Op,
98389810
ISD::EXTRACT_VECTOR_ELT, DL, VT, DAG.getBitcast(OpVT, Op),
98399811
DAG.getConstant(OpVT.getVectorNumElements() - 1, DL, MVT::i32));
98409812
}
9813+
9814+
// Verify that narrow integer arguments are extended as required by the ABI.
9815+
void SystemZTargetLowering::
9816+
verifyNarrowIntegerArgs(const SmallVectorImpl<ISD::OutputArg> &Outs,
9817+
bool HasLocalLinkage) const {
9818+
if (!getTargetMachine().Options.VerifyArgABICompliance || HasLocalLinkage ||
9819+
!Subtarget.isTargetELF())
9820+
return;
9821+
9822+
for (unsigned i = 0; i < Outs.size(); ++i) {
9823+
MVT VT = Outs[i].VT;
9824+
ISD::ArgFlagsTy Flags = Outs[i].Flags;
9825+
if (VT.isInteger()) {
9826+
assert((VT == MVT::i32 || VT.getSizeInBits() >= 64) &&
9827+
"Unexpected integer argument VT.");
9828+
assert((VT != MVT::i32 ||
9829+
(Flags.isSExt() || Flags.isZExt() || Flags.isNoExt())) &&
9830+
"Narrow integer argument must have a valid extension type.");
9831+
}
9832+
}
9833+
}

llvm/lib/Target/SystemZ/SystemZISelLowering.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,9 @@ class SystemZTargetLowering : public TargetLowering {
804804
MachineMemOperand::Flags
805805
getTargetMMOFlags(const Instruction &I) const override;
806806
const TargetRegisterClass *getRepRegClassFor(MVT VT) const override;
807+
808+
void verifyNarrowIntegerArgs(const SmallVectorImpl<ISD::OutputArg> &Outs,
809+
bool HasLocalLinkage) const;
807810
};
808811

809812
struct SystemZVectorConstantInfo {

llvm/test/Analysis/CostModel/SystemZ/divrem-const.ll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ define i64 @fun0(i64 %a) {
1818
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = sdiv i64 %a, 20
1919
}
2020

21-
define internal i32 @fun1(i32 %a) {
21+
define i32 @fun1(i32 %a) {
2222
%r = sdiv i32 %a, 20
2323
ret i32 %r
2424
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = sdiv i32 %a, 20
2525
}
2626

27-
define internal i16 @fun2(i16 %a) {
27+
define i16 @fun2(i16 %a) {
2828
%r = sdiv i16 %a, 20
2929
ret i16 %r
3030
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = sdiv i16 %a, 20
3131
}
3232

33-
define internal i8 @fun3(i8 %a) {
33+
define i8 @fun3(i8 %a) {
3434
%r = sdiv i8 %a, 20
3535
ret i8 %r
3636
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = sdiv i8 %a, 20
@@ -88,19 +88,19 @@ define i64 @fun11(i64 %a) {
8888
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i64 %a, 20
8989
}
9090

91-
define internal i32 @fun12(i32 %a) {
91+
define i32 @fun12(i32 %a) {
9292
%r = udiv i32 %a, 20
9393
ret i32 %r
9494
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i32 %a, 20
9595
}
9696

97-
define internal i16 @fun13(i16 %a) {
97+
define i16 @fun13(i16 %a) {
9898
%r = udiv i16 %a, 20
9999
ret i16 %r
100100
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i16 %a, 20
101101
}
102102

103-
define internal i8 @fun14(i8 %a) {
103+
define i8 @fun14(i8 %a) {
104104
%r = udiv i8 %a, 20
105105
ret i8 %r
106106
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i8
@@ -158,19 +158,19 @@ define i64 @fun22(i64 %a) {
158158
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i64
159159
}
160160

161-
define internal i32 @fun23(i32 %a) {
161+
define i32 @fun23(i32 %a) {
162162
%r = srem i32 %a, 20
163163
ret i32 %r
164164
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i32
165165
}
166166

167-
define internal i16 @fun24(i16 %a) {
167+
define i16 @fun24(i16 %a) {
168168
%r = srem i16 %a, 20
169169
ret i16 %r
170170
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i16
171171
}
172172

173-
define internal i8 @fun25(i8 %a) {
173+
define i8 @fun25(i8 %a) {
174174
%r = srem i8 %a, 20
175175
ret i8 %r
176176
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i8
@@ -228,19 +228,19 @@ define i64 @fun33(i64 %a) {
228228
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i64
229229
}
230230

231-
define internal i32 @fun34(i32 %a) {
231+
define i32 @fun34(i32 %a) {
232232
%r = urem i32 %a, 20
233233
ret i32 %r
234234
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i32
235235
}
236236

237-
define internal i16 @fun35(i16 %a) {
237+
define i16 @fun35(i16 %a) {
238238
%r = urem i16 %a, 20
239239
ret i16 %r
240240
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i16
241241
}
242242

243-
define internal i8 @fun36(i8 %a) {
243+
define i8 @fun36(i8 %a) {
244244
%r = urem i8 %a, 20
245245
ret i8 %r
246246
; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i8

llvm/test/Analysis/CostModel/SystemZ/divrem-pow2.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; RUN: | FileCheck %s -check-prefix=COST
33

44
; Check that all divide/remainder instructions are implemented by cheaper instructions.
5-
; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -o - -no-argext-abi-check | FileCheck %s
5+
; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -o - | FileCheck %s
66
; CHECK-NOT: dsg
77
; CHECK-NOT: dl
88

llvm/test/CodeGen/Generic/2002-04-16-StackFrameSizeAlignment.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ declare i32 @SIM(ptr, ptr, i32, i32, i32, ptr, i32, i32, i32)
88
define void @foo() {
99
bb0:
1010
%V = alloca [256 x i32], i32 256 ; <ptr> [#uses=1]
11-
call signext i32 @SIM( ptr null, ptr null, i32 signext 0, i32 signext 0, i32 signext 0,
12-
ptr %V, i32 signext 0, i32 signext 0, i32 signext 2 ) ; <i32>:0 [#uses=0]
11+
call i32 @SIM( ptr null, ptr null, i32 0, i32 0, i32 0, ptr %V, i32 0, i32 0, i32 2 ) ; <i32>:0 [#uses=0]
1312
ret void
1413
}
1514

llvm/test/CodeGen/Generic/extractelement-shuffle.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
; following program. The bug is DAGCombine assumes that the bit convert
55
; preserves the number of elements so the optimization code tries to read
66
; through the 3rd mask element, which doesn't exist.
7-
define signext i32 @update(<2 x i64> %val1, <2 x i64> %val2) nounwind readnone {
7+
define i32 @update(<2 x i64> %val1, <2 x i64> %val2) nounwind readnone {
88
entry:
99
%shuf = shufflevector <2 x i64> %val1, <2 x i64> %val2, <2 x i32> <i32 0, i32 3>
1010
%bit = bitcast <2 x i64> %shuf to <4 x i32>

llvm/test/CodeGen/SystemZ/args-01.ll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; Test the handling of GPR, FPR and stack arguments with the noext attribute.
2-
; This type of argument is used for passing structures, etc.
1+
; Test the handling of GPR, FPR and stack arguments when no extension
2+
; type is given. This type of argument is used for passing structures, etc.
33
;
44
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-INT
55
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-FLOAT
@@ -8,9 +8,8 @@
88
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-FP128-2
99
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-STACK
1010

11-
declare void @bar(i8 noext, i16 noext, i32 noext, i64, float, double, fp128, i64,
12-
float, double, i8 noext, i16 noext, i32 noext, i64, float,
13-
double, fp128)
11+
declare void @bar(i8, i16, i32, i64, float, double, fp128, i64,
12+
float, double, i8, i16, i32, i64, float, double, fp128)
1413

1514
; There are two indirect fp128 slots, one at offset 224 (the first available
1615
; byte after the outgoing arguments) and one immediately after it at 240.

llvm/test/CodeGen/SystemZ/args-13.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ define i128 @f14(i128 %r3) {
4141
%y = add i128 %r3, %r3
4242
ret i128 %y
4343
}
44+

llvm/test/CodeGen/SystemZ/args-14-i16.ll

Lines changed: 0 additions & 11 deletions
This file was deleted.

llvm/test/CodeGen/SystemZ/args-14-i32.ll

Lines changed: 0 additions & 10 deletions
This file was deleted.

llvm/test/CodeGen/SystemZ/args-14-i8.ll

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)