Skip to content

Commit

Permalink
Merged master:d50d4c3d440 into amd-gfx:b0efeab4481
Browse files Browse the repository at this point in the history
Local branch amd-gfx b0efeab Merged master:db0d636e52c into amd-gfx:cda84d7337b
Remote branch master d50d4c3 [Hexagon] Correct the order of operands when lowering funnel shift-left
  • Loading branch information
Sw authored and Sw committed Jul 29, 2020
2 parents b0efeab + d50d4c3 commit bc9ad25
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 13 deletions.
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaCoroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ static ReadySuspendResumeResult buildCoawaitCalls(Sema &S, VarDecl *CoroPromise,
if (!AwaitSuspend->getType()->isDependentType()) {
// [expr.await]p3 [...]
// - await-suspend is the expression e.await_suspend(h), which shall be
// a prvalue of type void or bool.
// a prvalue of type void, bool, or std::coroutine_handle<Z> for some
// type Z.
QualType RetType = AwaitSuspend->getCallReturnType(S.Context);

// Experimental support for coroutine_handle returning await_suspend.
Expand Down
4 changes: 3 additions & 1 deletion clang/test/Analysis/fuchsia_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ void handleDieBeforeErrorSymbol01() {
void handleDieBeforeErrorSymbol02() {
zx_handle_t sa, sb;
zx_status_t status = zx_channel_create(0, &sa, &sb);
// expected-note@-1 {{Handle allocated through 2nd parameter}}
// FIXME: There appears to be non-determinism in choosing
// which handle to report.
// expected-note-re@-3 {{Handle allocated through {{(2nd|3rd)}} parameter}}
if (status == 0) { // expected-note {{Assuming 'status' is equal to 0}}
// expected-note@-1 {{Taking true branch}}
return; // expected-warning {{Potential leak of handle}}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/User.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void User::replaceUsesOfWith(Value *From, Value *To) {
// The side effects of this setOperand call include linking to
// "To", adding "this" to the uses list of To, and
// most importantly, removing "this" from the use list of "From".
setOperand(i, To); // Fix it now...
setOperand(i, To);
}
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/Hexagon/HexagonPatterns.td
Original file line number Diff line number Diff line change
Expand Up @@ -1082,9 +1082,9 @@ def FShl32r: OutPatFrag<(ops node:$Rs, node:$Rt, node:$Ru),
(HiReg (S2_asl_r_p (Combinew $Rs, $Rt), $Ru))>;

def FShl64i: OutPatFrag<(ops node:$Rs, node:$Rt, node:$S),
(S2_lsr_i_p_or (S2_asl_i_p $Rt, $S), $Rs, (Subi<64> $S))>;
(S2_lsr_i_p_or (S2_asl_i_p $Rs, $S), $Rt, (Subi<64> $S))>;
def FShl64r: OutPatFrag<(ops node:$Rs, node:$Rt, node:$Ru),
(S2_lsr_r_p_or (S2_asl_r_p $Rt, $Ru), $Rs, (A2_subri 64, $Ru))>;
(S2_lsr_r_p_or (S2_asl_r_p $Rs, $Ru), $Rt, (A2_subri 64, $Ru))>;

// Combined SDNodeXForm: (Divu8 (Subi<64> $S))
def Divu64_8: SDNodeXForm<imm, [{
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/CodeGen/Hexagon/funnel-shift.ll
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ b0:
}

; CHECK-LABEL: f2:
; CHECK: r[[R20:[0-9]+]]:[[R21:[0-9]+]] = asl(r3:2,#17)
; CHECK: r[[R20]]:[[R21]] |= lsr(r1:0,#47)
; CHECK: r[[R20:[0-9]+]]:[[R21:[0-9]+]] = asl(r1:0,#17)
; CHECK: r[[R20]]:[[R21]] |= lsr(r3:2,#47)
define i64 @f2(i64 %a0, i64 %a1) #1 {
b0:
%v0 = tail call i64 @llvm.fshl.i64(i64 %a0, i64 %a1, i64 17)
ret i64 %v0
}

; CHECK-LABEL: f3:
; CHECK: r[[R30:[0-9]+]]:[[R31:[0-9]+]] = asl(r3:2,r4)
; CHECK: r[[R30:[0-9]+]]:[[R31:[0-9]+]] = asl(r1:0,r4)
; CHECK: r[[R32:[0-9]+]] = sub(#64,r4)
; CHECK: r[[R30]]:[[R31]] |= lsr(r1:0,r[[R32]])
; CHECK: r[[R30]]:[[R31]] |= lsr(r3:2,r[[R32]])
define i64 @f3(i64 %a0, i64 %a1, i64 %a2) #1 {
b0:
%v0 = tail call i64 @llvm.fshl.i64(i64 %a0, i64 %a1, i64 %a2)
Expand Down
31 changes: 31 additions & 0 deletions llvm/test/CodeGen/Hexagon/funnel-shift2.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
; RUN: llc -mtriple=hexagon < %s | FileCheck %s

; This patch corrects the order of operands in the pattern that lowers funnel
; shift-left.

; CHECK: r[[R17:[0-9]+]]:[[R16:[0-9]+]] = combine
; CHECK: call parity
; CHECK: r[[R1:[0-9]+]]:[[R0:[0-9]+]] = asl(r[[R1]]:[[R0]],#63)
; CHECK: r[[R1]]:[[R0]] |= lsr(r[[R17]]:[[R16]],#1)

target triple = "hexagon-unknown-unknown-elf"

define dso_local i64 @fshl(i64 %x, i64 %y) {
entry:
%x.addr = alloca i64, align 8
%y.addr = alloca i64, align 8
store i64 %x, i64* %x.addr, align 8
store i64 %y, i64* %y.addr, align 8
%0 = load i64, i64* %x.addr, align 8
%shr = lshr i64 %0, 1
%1 = load i64, i64* %x.addr, align 8
%2 = load i64, i64* %y.addr, align 8
%call = call i64 @parity(i64 %1, i64 %2)
%shl = shl i64 %call, 63
%or = or i64 %shr, %shl
store i64 %or, i64* %x.addr, align 8
%3 = load i64, i64* %x.addr, align 8
ret i64 %3
}

declare dso_local i64 @parity(i64, i64)
8 changes: 4 additions & 4 deletions llvm/test/tools/llvm-readobj/ELF/hex-dump.test
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ FileHeader:
Type: ET_DYN
Machine: EM_386

## Test that llvm-readelf emits a correct amount of spaces between the hex data
## Test that llvm-readelf emits the correct number of spaces between the hex data
## and its ascii representation.

## a) When the hex data doesn't fill the column whose index isn't 4.
## a) When the hex data doesn't fill a column other than the last one.
# RUN: yaml2obj --docnum=2 -DSIZE=18 %s -o %t2.out1
# RUN: llvm-readelf --hex-dump=.sec %t2.out1 | \
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SPACES1
Expand All @@ -61,7 +61,7 @@ FileHeader:
# SPACES1-NEXT:0x00000000 00000000 00000000 00000000 00000000 ................
# SPACES1-NEXT:0x00000010 0000 ..

## b) When the hex data doesn't fill the column whose index is 4.
## b) When the hex data doesn't fill the last column.
# RUN: yaml2obj --docnum=2 -DSIZE=30 %s -o %t2.out2
# RUN: llvm-readelf --hex-dump=.sec %t2.out2 | \
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SPACES2
Expand All @@ -70,7 +70,7 @@ FileHeader:
# SPACES2-NEXT:0x00000000 00000000 00000000 00000000 00000000 ................
# SPACES2-NEXT:0x00000010 00000000 00000000 00000000 0000 ..............

## c) When the hex data fills the column.
## c) When the hex data fills a column.
# RUN: yaml2obj --docnum=2 -DSIZE=28 %s -o %t2.out3
# RUN: llvm-readelf --hex-dump=.sec %t2.out3 | \
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SPACES3
Expand Down
32 changes: 32 additions & 0 deletions llvm/unittests/IR/UserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,38 @@ TEST(UserTest, ValueOpIteration) {
EXPECT_EQ(IP->value_op_end(), (CI - 2) + 8);
}

TEST(UserTest, replaceUseOfWith) {
LLVMContext C;

const char *ModuleString = "define void @f(i32 %x) {\n"
"entry:\n"
" %v0 = add i32 1, 1\n"
" %v1 = add i32 %x, 2\n"
" ret void\n"
"}\n";
SMDiagnostic Err;
std::unique_ptr<Module> M = parseAssemblyString(ModuleString, Err, C);
Function *F = M->getFunction("f");
EXPECT_TRUE(F);
EXPECT_TRUE(F->arg_begin() != F->arg_end());
BasicBlock& entryBB = F->front();
Instruction& I0 = *(entryBB.begin());
Instruction& I1 = *(++(entryBB.begin()));

Argument &X = *F->arg_begin();
EXPECT_EQ("x", X.getName());
EXPECT_NE(X.user_begin() ,X.user_end());
EXPECT_EQ(I0.user_begin() ,I0.user_end());


auto XUser = find(X.users(), &(I1));
EXPECT_NE(XUser, X.user_end());

XUser->replaceUsesOfWith(&X, &I0);
EXPECT_EQ(X.user_begin() ,X.user_end());
EXPECT_NE(I0.user_begin() ,I0.user_end());
}

TEST(UserTest, PersonalityUser) {
LLVMContext Context;
Module M("", Context);
Expand Down

0 comments on commit bc9ad25

Please sign in to comment.