llvm.org GIT mirror llvm / a474ab4
Merging r332682 and r332694: ------------------------------------------------------------------------ r332682 | kfischer | 2018-05-17 18:03:01 -0700 (Thu, 17 May 2018) | 21 lines [X86DomainReassignment] Don't compare stack-allocated values by address Summary: The Closure allocated in the main loop is allocated on the stack. However, later in the code its address is taken (and used for comparisons). This obviously doesn't work. In fact, the Closure will get the same stack address during every loop iteration, rendering the check that intended to identify Closure conflicts entirely ineffective. Fix this bug by giving every Closure a unique ID and using that for comparison. Alternatively, we could heap allocate the closure object. Fixes PR37396 Fixes JuliaLang/julia#27032 Reviewers: craig.topper, guyblank Reviewed By: craig.topper Subscribers: vchuravy, llvm-commits Differential Revision: https://reviews.llvm.org/D46800 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r332694 | kfischer | 2018-05-17 21:36:38 -0700 (Thu, 17 May 2018) | 15 lines [X86DomainReassignment] Hopefully fix buildbot failure The Darwin build bot failed with: ``` llc -mcpu=skylake-avx512 -mtriple=x86_64-unknown-linux-gnu domain-reassignment-test.ll -o - | llvm-mc -- Exit Code: 134 Command Output (stderr): -- Assertion failed: (MAI->hasSingleParameterDotFile()), function EmitFileDirective, file lib/MC/MCAsmStreamer.cpp, line 1087. ``` Looks like this is because the `llvm-mc` command was missing a triple directive and defaulting to MachO. Add the triple option. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@333470 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 1 year, 4 months ago
2 changed file(s) with 72 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
2525 #include "llvm/CodeGen/MachineRegisterInfo.h"
2626 #include "llvm/CodeGen/TargetRegisterInfo.h"
2727 #include "llvm/Support/Debug.h"
28 #include "llvm/Support/Printable.h"
2829 #include
2930
3031 using namespace llvm;
290291 /// Domains which this closure can legally be reassigned to.
291292 std::bitset LegalDstDomains;
292293
294 /// An ID to uniquely identify this closure, even when it gets
295 /// moved around
296 unsigned ID;
297
293298 public:
294 Closure(std::initializer_list LegalDstDomainList) {
299 Closure(unsigned ID, std::initializer_list LegalDstDomainList) : ID(ID) {
295300 for (RegDomain D : LegalDstDomainList)
296301 LegalDstDomains.set(D);
297302 }
325330
326331 ArrayRef instructions() const {
327332 return Instrs;
333 }
334
335 LLVM_DUMP_METHOD void dump(const MachineRegisterInfo *MRI) const {
336 dbgs() << "Registers: ";
337 bool First = true;
338 for (unsigned Reg : Edges) {
339 if (!First)
340 dbgs() << ", ";
341 First = false;
342 dbgs() << printReg(Reg, MRI->getTargetRegisterInfo());
343 }
344 dbgs() << "\n" << "Instructions:";
345 for (MachineInstr *MI : Instrs) {
346 dbgs() << "\n ";
347 MI->print(dbgs());
348 }
349 dbgs() << "\n";
350 }
351
352 unsigned getID() const {
353 return ID;
328354 }
329355
330356 };
338364 DenseSet EnclosedEdges;
339365
340366 /// All instructions that are included in some closure.
341 DenseMapClosure *> EnclosedInstrs;
367 DenseMapunsigned> EnclosedInstrs;
342368
343369 public:
344370 static char ID;
415441 void X86DomainReassignment::encloseInstr(Closure &C, MachineInstr *MI) {
416442 auto I = EnclosedInstrs.find(MI);
417443 if (I != EnclosedInstrs.end()) {
418 if (I->second != &C)
444 if (I->second != C.getID())
419445 // Instruction already belongs to another closure, avoid conflicts between
420446 // closure and mark this closure as illegal.
421447 C.setAllIllegal();
422448 return;
423449 }
424450
425 EnclosedInstrs[MI] = &C;
451 EnclosedInstrs[MI] = C.getID();
426452 C.addInstruction(MI);
427453
428454 // Mark closure as illegal for reassignment to domains, if there is no
703729 std::vector Closures;
704730
705731 // Go over all virtual registers and calculate a closure.
732 unsigned ClosureID = 0;
706733 for (unsigned Idx = 0; Idx < MRI->getNumVirtRegs(); ++Idx) {
707734 unsigned Reg = TargetRegisterInfo::index2VirtReg(Idx);
708735
715742 continue;
716743
717744 // Calculate closure starting with Reg.
718 Closure C({MaskDomain});
745 Closure C(ClosureID++, {MaskDomain});
719746 buildClosure(C, Reg);
720747
721748 // Collect all closures that can potentially be converted.
723750 Closures.push_back(std::move(C));
724751 }
725752
726 for (Closure &C : Closures)
753 for (Closure &C : Closures) {
754 DEBUG(C.dump(MRI));
727755 if (isReassignmentProfitable(C, MaskDomain)) {
728756 reassign(C, MaskDomain);
729757 ++NumClosuresConverted;
730758 Changed = true;
731759 }
760 }
732761
733762 DeleteContainerSeconds(Converters);
734763
0 ; RUN: llc -mcpu=skylake-avx512 -mtriple=x86_64-unknown-linux-gnu %s -o - | FileCheck %s
1 ; RUN: llc -mcpu=skylake-avx512 -mtriple=x86_64-unknown-linux-gnu %s -o - | llvm-mc -triple=x86_64-unknown-linux-gnu -mcpu=skylake-avx512
2
3 ; Check that the X86 domain reassignment pass doesn't introduce an illegal
4 ; test instruction. See PR37396
5 define void @japi1_foo2_34617() {
6 pass2:
7 br label %if5
8
9 L174:
10 %tmp = icmp sgt <2 x i64> undef, zeroinitializer
11 %tmp1 = icmp sle <2 x i64> undef, undef
12 %tmp2 = and <2 x i1> %tmp, %tmp1
13 %tmp3 = extractelement <2 x i1> %tmp2, i32 0
14 %tmp4 = extractelement <2 x i1> %tmp2, i32 1
15 %tmp106 = and i1 %tmp4, %tmp3
16 %tmp107 = zext i1 %tmp106 to i8
17 %tmp108 = and i8 %tmp122, %tmp107
18 %tmp109 = icmp eq i8 %tmp108, 0
19 ; CHECK-NOT: testb {{%k[0-7]}}
20 br i1 %tmp109, label %L188, label %L190
21
22 if5:
23 %b.055 = phi i8 [ 1, %pass2 ], [ %tmp122, %if5 ]
24 %tmp118 = icmp sgt i64 undef, 0
25 %tmp119 = icmp sle i64 undef, undef
26 %tmp120 = and i1 %tmp118, %tmp119
27 %tmp121 = zext i1 %tmp120 to i8
28 %tmp122 = and i8 %b.055, %tmp121
29 br i1 undef, label %L174, label %if5
30
31 L188:
32 unreachable
33
34 L190:
35 ret void
36 }