Skip to content

Commit c169650

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:b27eb0ae8280675fc8fb249d39f1ccafa3ee2187 into amd-gfx:ea66a9b7b6c7
Local branch amd-gfx ea66a9b Merged main:bc9823cf60bf91cc8b45248c4205cd2c67b2a3d5 into amd-gfx:922c3da159e1 Remote branch main b27eb0a [lldb] Avoid modifying the source tree in TestCompletion.py
2 parents ea66a9b + b27eb0a commit c169650

File tree

7 files changed

+201
-311
lines changed

7 files changed

+201
-311
lines changed

lldb/test/API/functionalities/completion/TestCompletion.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,17 @@ def test_process_unload(self):
108108
)
109109
err = lldb.SBError()
110110
local_spec = lldb.SBFileSpec(self.getBuildArtifact("libshared.so"))
111-
remote_spec = (
112-
lldb.SBFileSpec(
113-
lldbutil.append_to_process_working_directory(self, "libshared.so"),
114-
False,
111+
if lldb.remote_platform:
112+
self.process().LoadImage(
113+
local_spec,
114+
lldb.SBFileSpec(
115+
lldbutil.append_to_process_working_directory(self, "libshared.so"),
116+
False,
117+
),
118+
err,
115119
)
116-
if lldb.remote_platform
117-
else lldb.SBFileSpec()
118-
)
119-
self.process().LoadImage(local_spec, remote_spec, err)
120+
else:
121+
self.process().LoadImage(local_spec, err)
120122
self.assertSuccess(err)
121123

122124
self.complete_from_to("process unload ", "process unload 0")

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 498998
19+
#define LLVM_MAIN_REVISION 499003
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,28 @@ bool TargetLibraryInfoImpl::isCallingConvCCompatible(Function *F) {
160160
F->getFunctionType());
161161
}
162162

163+
static void initializeBase(TargetLibraryInfoImpl &TLI, const Triple &T) {
164+
bool ShouldExtI32Param, ShouldExtI32Return;
165+
bool ShouldSignExtI32Param, ShouldSignExtI32Return;
166+
TargetLibraryInfo::initExtensionsForTriple(
167+
ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param,
168+
ShouldSignExtI32Return, T);
169+
TLI.setShouldExtI32Param(ShouldExtI32Param);
170+
TLI.setShouldExtI32Return(ShouldExtI32Return);
171+
TLI.setShouldSignExtI32Param(ShouldSignExtI32Param);
172+
TLI.setShouldSignExtI32Return(ShouldSignExtI32Return);
173+
174+
// Let's assume by default that the size of int is 32 bits, unless the target
175+
// is a 16-bit architecture because then it most likely is 16 bits. If that
176+
// isn't true for a target those defaults should be overridden below.
177+
TLI.setIntSize(T.isArch16Bit() ? 16 : 32);
178+
}
179+
163180
/// Initialize the set of available library functions based on the specified
164181
/// target triple. This should be carefully written so that a missing target
165182
/// triple gets a sane set of defaults.
166-
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
167-
ArrayRef<StringLiteral> StandardNames) {
183+
static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
184+
ArrayRef<StringLiteral> StandardNames) {
168185
// Set IO unlocked variants as unavailable
169186
// Set them as available per system below
170187
TLI.setUnavailable(LibFunc_getc_unlocked);
@@ -178,20 +195,6 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
178195
TLI.setUnavailable(LibFunc_fputs_unlocked);
179196
TLI.setUnavailable(LibFunc_fgets_unlocked);
180197

181-
bool ShouldExtI32Param, ShouldExtI32Return;
182-
bool ShouldSignExtI32Param, ShouldSignExtI32Return;
183-
TargetLibraryInfo::initExtensionsForTriple(ShouldExtI32Param,
184-
ShouldExtI32Return, ShouldSignExtI32Param, ShouldSignExtI32Return, T);
185-
TLI.setShouldExtI32Param(ShouldExtI32Param);
186-
TLI.setShouldExtI32Return(ShouldExtI32Return);
187-
TLI.setShouldSignExtI32Param(ShouldSignExtI32Param);
188-
TLI.setShouldSignExtI32Return(ShouldSignExtI32Return);
189-
190-
// Let's assume by default that the size of int is 32 bits, unless the target
191-
// is a 16-bit architecture because then it most likely is 16 bits. If that
192-
// isn't true for a target those defaults should be overridden below.
193-
TLI.setIntSize(T.isArch16Bit() ? 16 : 32);
194-
195198
// There is really no runtime library on AMDGPU, apart from
196199
// __kmpc_alloc/free_shared.
197200
if (T.isAMDGPU()) {
@@ -882,11 +885,19 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
882885
TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary, T);
883886
}
884887

885-
TargetLibraryInfoImpl::TargetLibraryInfoImpl() {
886-
// Default to everything being available.
887-
memset(AvailableArray, -1, sizeof(AvailableArray));
888+
/// Initialize the set of available library functions based on the specified
889+
/// target triple. This should be carefully written so that a missing target
890+
/// triple gets a sane set of defaults.
891+
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
892+
ArrayRef<StringLiteral> StandardNames) {
893+
initializeBase(TLI, T);
894+
initializeLibCalls(TLI, T, StandardNames);
895+
}
888896

889-
initialize(*this, Triple(), StandardNames);
897+
TargetLibraryInfoImpl::TargetLibraryInfoImpl() {
898+
// Default to nothing being available.
899+
memset(AvailableArray, 0, sizeof(AvailableArray));
900+
initializeBase(*this, Triple());
890901
}
891902

892903
TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) {

llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static bool isAggrToReplace(const Value *V) {
174174

175175
static void setInsertPointSkippingPhis(IRBuilder<> &B, Instruction *I) {
176176
if (isa<PHINode>(I))
177-
B.SetInsertPoint(I->getParent(), I->getParent()->getFirstInsertionPt());
177+
B.SetInsertPoint(I->getParent()->getFirstNonPHIOrDbgOrAlloca());
178178
else
179179
B.SetInsertPoint(I);
180180
}
@@ -491,7 +491,7 @@ void SPIRVEmitIntrinsics::deduceOperandElementType(Instruction *I) {
491491
if (Instruction *User = dyn_cast<Instruction>(Op->use_begin()->get()))
492492
setInsertPointSkippingPhis(B, User->getNextNode());
493493
else
494-
B.SetInsertPoint(I);
494+
setInsertPointSkippingPhis(B, I);
495495
Value *OpTyVal = Constant::getNullValue(KnownElemTy);
496496
Type *OpTy = Op->getType();
497497
if (!Ty) {
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
; The goal of the test is to check that internal intrinsic functions for PHI's
2+
; operand are inserted at the correct positions, and don't break rules of
3+
; instruction domination and PHI nodes grouping at top of basic block.
4+
5+
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
6+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
7+
8+
; CHECK-DAG: OpName %[[#Foo:]] "foo"
9+
; CHECK-DAG: OpName %[[#Bar:]] "bar"
10+
; CHECK: %[[#Foo]] = OpFunction
11+
; CHECK: OpPhi
12+
; CHECK-NEXT: OpPhi
13+
; CHECK-NEXT: OpPhi
14+
; CHECK-NEXT: OpPhi
15+
; CHECK: %[[#Bar]] = OpFunction
16+
; CHECK: OpPhi
17+
; CHECK-NEXT: OpPhi
18+
; CHECK-NEXT: OpPhi
19+
; CHECK-NEXT: OpPhi
20+
21+
%struct = type { i64, i64 }
22+
23+
define spir_kernel void @foo(i64 %arg_val, ptr addrspace(4) byval(%struct) %arg_ptr) {
24+
entry:
25+
%fl = icmp eq i64 %arg_val, 0
26+
br i1 %fl, label %ok, label %err
27+
28+
err:
29+
br label %ok
30+
31+
ok:
32+
%r1 = phi i64 [ undef, %err ], [ %arg_val, %entry ]
33+
%r2 = phi i64 [ undef, %err ], [ %arg_val, %entry ]
34+
%r3 = phi ptr addrspace(4) [ undef, %err ], [ %arg_ptr, %entry ]
35+
%r4 = phi ptr addrspace(4) [ undef, %err ], [ %arg_ptr, %entry ]
36+
br label %exit
37+
38+
exit:
39+
ret void
40+
}
41+
42+
define spir_kernel void @bar(i64 %arg_val, i64 %arg_val_def, ptr addrspace(4) byval(%struct) %arg_ptr, ptr addrspace(4) %arg_ptr_def) {
43+
entry:
44+
%fl = icmp eq i64 %arg_val, 0
45+
br i1 %fl, label %ok, label %err
46+
47+
err:
48+
br label %ok
49+
50+
ok:
51+
%r1 = phi i64 [ %arg_val_def, %err ], [ %arg_val, %entry ]
52+
%r2 = phi i64 [ %arg_val_def, %err ], [ %arg_val, %entry ]
53+
%r3 = phi ptr addrspace(4) [ %arg_ptr_def, %err ], [ %arg_ptr, %entry ]
54+
%r4 = phi ptr addrspace(4) [ %arg_ptr_def, %err ], [ %arg_ptr, %entry ]
55+
br label %exit
56+
57+
exit:
58+
ret void
59+
}

mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -956,27 +956,12 @@ struct SignOpConversion : public OpConversionPattern<complex::SignOp> {
956956
}
957957
};
958958

959-
struct TanOpConversion : public OpConversionPattern<complex::TanOp> {
960-
using OpConversionPattern<complex::TanOp>::OpConversionPattern;
959+
template <typename Op>
960+
struct TanTanhOpConversion : public OpConversionPattern<Op> {
961+
using OpConversionPattern<Op>::OpConversionPattern;
961962

962963
LogicalResult
963-
matchAndRewrite(complex::TanOp op, OpAdaptor adaptor,
964-
ConversionPatternRewriter &rewriter) const override {
965-
auto loc = op.getLoc();
966-
arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
967-
968-
Value cos = rewriter.create<complex::CosOp>(loc, adaptor.getComplex(), fmf);
969-
Value sin = rewriter.create<complex::SinOp>(loc, adaptor.getComplex(), fmf);
970-
rewriter.replaceOpWithNewOp<complex::DivOp>(op, sin, cos, fmf);
971-
return success();
972-
}
973-
};
974-
975-
struct TanhOpConversion : public OpConversionPattern<complex::TanhOp> {
976-
using OpConversionPattern<complex::TanhOp>::OpConversionPattern;
977-
978-
LogicalResult
979-
matchAndRewrite(complex::TanhOp op, OpAdaptor adaptor,
964+
matchAndRewrite(Op op, typename Op::Adaptor adaptor,
980965
ConversionPatternRewriter &rewriter) const override {
981966
ImplicitLocOpBuilder b(op.getLoc(), rewriter);
982967
auto loc = op.getLoc();
@@ -989,14 +974,20 @@ struct TanhOpConversion : public OpConversionPattern<complex::TanhOp> {
989974
b.create<complex::ReOp>(loc, elementType, adaptor.getComplex());
990975
Value imag =
991976
b.create<complex::ImOp>(loc, elementType, adaptor.getComplex());
977+
Value negOne = b.create<arith::ConstantOp>(
978+
elementType, b.getFloatAttr(elementType, -1.0));
979+
980+
if constexpr (std::is_same_v<Op, complex::TanOp>) {
981+
// tan(x+yi) = -i*tanh(-y + xi)
982+
std::swap(real, imag);
983+
real = b.create<arith::MulFOp>(real, negOne, fmf);
984+
}
992985

993986
auto cst = [&](APFloat v) {
994987
return b.create<arith::ConstantOp>(elementType,
995988
b.getFloatAttr(elementType, v));
996989
};
997990
Value inf = cst(APFloat::getInf(floatSemantics));
998-
Value negOne = b.create<arith::ConstantOp>(
999-
elementType, b.getFloatAttr(elementType, -1.0));
1000991
Value four = b.create<arith::ConstantOp>(elementType,
1001992
b.getFloatAttr(elementType, 4.0));
1002993
Value twoReal = b.create<arith::AddFOp>(real, real, fmf);
@@ -1054,6 +1045,12 @@ struct TanhOpConversion : public OpConversionPattern<complex::TanhOp> {
10541045
b.create<arith::SelectOp>(resultImagIsZero, zero, resultImag);
10551046
}
10561047

1048+
if constexpr (std::is_same_v<Op, complex::TanOp>) {
1049+
// tan(x+yi) = -i*tanh(-y + xi)
1050+
std::swap(resultReal, resultImag);
1051+
resultImag = b.create<arith::MulFOp>(resultImag, negOne, fmf);
1052+
}
1053+
10571054
rewriter.replaceOpWithNewOp<complex::CreateOp>(op, type, resultReal,
10581055
resultImag);
10591056
return success();
@@ -1327,8 +1324,8 @@ void mlir::populateComplexToStandardConversionPatterns(
13271324
SignOpConversion,
13281325
SinOpConversion,
13291326
SqrtOpConversion,
1330-
TanOpConversion,
1331-
TanhOpConversion,
1327+
TanTanhOpConversion<complex::TanOp>,
1328+
TanTanhOpConversion<complex::TanhOp>,
13321329
PowOpConversion,
13331330
RsqrtOpConversion
13341331
>(patterns.getContext());

0 commit comments

Comments
 (0)