Skip to content

Commit 58a0567

Browse files
committed
Revert "[InlineFunction] Handle return attributes on call within inlined body"
This reverts commit 28518d9. There is a failure in MsgPackReader.cpp when built with clang. It complains about "signext and zeroext" are incompatible. Investigating offline if it is infact a UB in the MsgPackReader code.
1 parent b7fe795 commit 58a0567

File tree

6 files changed

+18
-266
lines changed

6 files changed

+18
-266
lines changed

clang/test/CodeGen/builtins-systemz-zvector.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3665,31 +3665,31 @@ void test_integer(void) {
36653665
// CHECK-ASM: vsumqg
36663666

36673667
idx = vec_test_mask(vsc, vuc);
3668-
// CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
3668+
// CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
36693669
// CHECK-ASM: vtm
36703670
idx = vec_test_mask(vuc, vuc);
3671-
// CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
3671+
// CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
36723672
// CHECK-ASM: vtm
36733673
idx = vec_test_mask(vss, vus);
3674-
// CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
3674+
// CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
36753675
// CHECK-ASM: vtm
36763676
idx = vec_test_mask(vus, vus);
3677-
// CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
3677+
// CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
36783678
// CHECK-ASM: vtm
36793679
idx = vec_test_mask(vsi, vui);
3680-
// CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
3680+
// CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
36813681
// CHECK-ASM: vtm
36823682
idx = vec_test_mask(vui, vui);
3683-
// CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
3683+
// CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
36843684
// CHECK-ASM: vtm
36853685
idx = vec_test_mask(vsl, vul);
3686-
// CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
3686+
// CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
36873687
// CHECK-ASM: vtm
36883688
idx = vec_test_mask(vul, vul);
3689-
// CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
3689+
// CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
36903690
// CHECK-ASM: vtm
36913691
idx = vec_test_mask(vd, vul);
3692-
// CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
3692+
// CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
36933693
// CHECK-ASM: vtm
36943694
}
36953695

clang/test/CodeGen/builtins-systemz-zvector2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,10 @@ void test_integer(void) {
654654
// CHECK-ASM: vsrlb
655655

656656
idx = vec_test_mask(vf, vui);
657-
// CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
657+
// CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
658658
// CHECK-ASM: vtm
659659
idx = vec_test_mask(vd, vul);
660-
// CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
660+
// CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
661661
// CHECK-ASM: vtm
662662

663663
vuc = vec_msum_u128(vul, vul, vuc, 0);

clang/test/CodeGen/movbe-builtins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
short test_loadbe_i16(const short *P) {
88
// CHECK-LABEL: @test_loadbe_i16
99
// CHECK: [[LOAD:%.*]] = load i16, i16* %{{.*}}, align 1
10-
// CHECK: call signext i16 @llvm.bswap.i16(i16 [[LOAD]])
10+
// CHECK: call i16 @llvm.bswap.i16(i16 [[LOAD]])
1111
return _loadbe_i16(P);
1212
}
1313

clang/test/CodeGen/rot-intrinsics.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// RUN: %clang_cc1 -ffreestanding -triple i686--linux -emit-llvm -mllvm -update-return-attrs=false %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
2-
// RUN: %clang_cc1 -ffreestanding -triple x86_64--linux -emit-llvm -mllvm -update-return-attrs=false %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
3-
// RUN: %clang_cc1 -fms-extensions -fms-compatibility -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -emit-llvm -mllvm -update-return-attrs=false -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
4-
// RUN: %clang_cc1 -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -emit-llvm -mllvm -update-return-attrs=false -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
5-
// RUN: %clang_cc1 -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -emit-llvm -mllvm -update-return-attrs=false -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
6-
// RUN: %clang_cc1 -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -emit-llvm -mllvm -update-return-attrs=false -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
1+
// RUN: %clang_cc1 -ffreestanding -triple i686--linux -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
2+
// RUN: %clang_cc1 -ffreestanding -triple x86_64--linux -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
3+
// RUN: %clang_cc1 -fms-extensions -fms-compatibility -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
4+
// RUN: %clang_cc1 -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
5+
// RUN: %clang_cc1 -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
6+
// RUN: %clang_cc1 -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
77

88
#include <x86intrin.h>
99

llvm/lib/Transforms/Utils/InlineFunction.cpp

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,11 @@ EnableNoAliasConversion("enable-noalias-to-md-conversion", cl::init(true),
8080
cl::Hidden,
8181
cl::desc("Convert noalias attributes to metadata during inlining."));
8282

83-
static cl::opt<bool> UpdateReturnAttributes(
84-
"update-return-attrs", cl::init(true), cl::Hidden,
85-
cl::desc("Update return attributes on calls within inlined body"));
86-
8783
static cl::opt<bool>
8884
PreserveAlignmentAssumptions("preserve-alignment-assumptions-during-inlining",
8985
cl::init(true), cl::Hidden,
9086
cl::desc("Convert align attributes to assumptions during inlining."));
9187

92-
static cl::opt<unsigned> InlinerAttributeWindow(
93-
"inliner-attribute-window", cl::Hidden,
94-
cl::desc("the maximum number of instructions analyzed for may throw during "
95-
"attribute inference in inlined body"),
96-
cl::init(4));
97-
9888
llvm::InlineResult llvm::InlineFunction(CallBase *CB, InlineFunctionInfo &IFI,
9989
AAResults *CalleeAAR,
10090
bool InsertLifetime) {
@@ -1146,81 +1136,6 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
11461136
}
11471137
}
11481138

1149-
static bool MayContainThrowingOrExitingCall(Instruction *Begin,
1150-
Instruction *End) {
1151-
1152-
assert(Begin->getParent() == End->getParent() &&
1153-
"Expected to be in same basic block!");
1154-
unsigned NumInstChecked = 0;
1155-
// Check that all instructions in the range [Begin, End) are guaranteed to
1156-
// transfer execution to successor.
1157-
for (auto &I : make_range(Begin->getIterator(), End->getIterator()))
1158-
if (NumInstChecked++ > InlinerAttributeWindow ||
1159-
!isGuaranteedToTransferExecutionToSuccessor(&I))
1160-
return true;
1161-
return false;
1162-
}
1163-
1164-
static void AddReturnAttributes(CallSite CS, ValueToValueMapTy &VMap) {
1165-
if (!UpdateReturnAttributes)
1166-
return;
1167-
AttrBuilder AB(CS.getAttributes(), AttributeList::ReturnIndex);
1168-
if (AB.empty())
1169-
return;
1170-
1171-
auto *CalledFunction = CS.getCalledFunction();
1172-
auto &Context = CalledFunction->getContext();
1173-
1174-
for (auto &BB : *CalledFunction) {
1175-
auto *RI = dyn_cast<ReturnInst>(BB.getTerminator());
1176-
if (!RI || !isa<CallBase>(RI->getOperand(0)))
1177-
continue;
1178-
// Sanity check that the cloned return instruction exists and is a return
1179-
// instruction itself.
1180-
auto *NewRI = dyn_cast_or_null<ReturnInst>(VMap.lookup(RI));
1181-
if (!NewRI)
1182-
continue;
1183-
auto *RetVal = cast<CallBase>(RI->getOperand(0));
1184-
// Sanity check that the cloned RetVal exists and is a call.
1185-
// Simplification during inlining could have transformed the cloned
1186-
// instruction.
1187-
auto *NewRetVal = dyn_cast_or_null<CallBase>(VMap.lookup(RetVal));
1188-
if (!NewRetVal)
1189-
continue;
1190-
// Backward propagation of attributes to the returned value may be incorrect
1191-
// if it is control flow dependent.
1192-
// Consider:
1193-
// @callee {
1194-
// %rv = call @foo()
1195-
// %rv2 = call @bar()
1196-
// if (%rv2 != null)
1197-
// return %rv2
1198-
// if (%rv == null)
1199-
// exit()
1200-
// return %rv
1201-
// }
1202-
// caller() {
1203-
// %val = call nonnull @callee()
1204-
// }
1205-
// Here we cannot add the nonnull attribute on either foo or bar. So, we
1206-
// limit the check to both NewRetVal and NewRI are in the same basic block
1207-
// and there are no throwing/exiting instructions between these
1208-
// instructions.
1209-
if (NewRI->getParent() != NewRetVal->getParent() ||
1210-
MayContainThrowingOrExitingCall(NewRetVal, NewRI))
1211-
continue;
1212-
// Add to the existing attributes of NewRetVal.
1213-
// NB! When we have the same attribute already existing on NewRetVal, but
1214-
// with a differing value, the AttributeList's merge API honours the already
1215-
// existing attribute value (i.e. attributes such as dereferenceable,
1216-
// dereferenceable_or_null etc). See AttrBuilder::merge for more details.
1217-
AttributeList AL = NewRetVal->getAttributes();
1218-
AttributeList NewAL =
1219-
AL.addAttributes(Context, AttributeList::ReturnIndex, AB);
1220-
NewRetVal->setAttributes(NewAL);
1221-
}
1222-
}
1223-
12241139
/// If the inlined function has non-byval align arguments, then
12251140
/// add @llvm.assume-based alignment assumptions to preserve this information.
12261141
static void AddAlignmentAssumptions(CallSite CS, InlineFunctionInfo &IFI) {
@@ -1886,10 +1801,6 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
18861801
// Add noalias metadata if necessary.
18871802
AddAliasScopeMetadata(CS, VMap, DL, CalleeAAR);
18881803

1889-
// Clone return attributes on the callsite into the calls within the inlined
1890-
// function which feed into its return value.
1891-
AddReturnAttributes(CS, VMap);
1892-
18931804
// Propagate llvm.mem.parallel_loop_access if necessary.
18941805
PropagateParallelLoopAccessMetadata(CS, VMap);
18951806

llvm/test/Transforms/Inline/ret_attr_update.ll

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

0 commit comments

Comments
 (0)