[llvm-branch-commits] [llvm-branch] r258326 - Merging r258308: [AArch64] Fix two bugs in the .inst directive

2016-01-20 Thread Renato Golin via llvm-branch-commits
Author: rengolin
Date: Wed Jan 20 12:01:05 2016
New Revision: 258326

URL: http://llvm.org/viewvc/llvm-project?rev=258326&view=rev
Log:
Merging r258308: [AArch64] Fix two bugs in the .inst directive

Modified:

llvm/branches/release_38/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
llvm/branches/release_38/test/MC/AArch64/inst-directive.s

Modified: 
llvm/branches/release_38/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp?rev=258326&r1=258325&r2=258326&view=diff
==
--- 
llvm/branches/release_38/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp 
(original)
+++ 
llvm/branches/release_38/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp 
Wed Jan 20 12:01:05 2016
@@ -112,9 +112,21 @@ public:
 MCELFStreamer::EmitInstruction(Inst, STI);
   }
 
+  /// Emit a 32-bit value as an instruction. This is only used for the .inst
+  /// directive, EmitInstruction should be used in other cases.
   void emitInst(uint32_t Inst) {
+char Buffer[4];
+
+// We can't just use EmitIntValue here, as that will emit a data mapping
+// symbol, and swap the endianness on big-endian systems (instructions are
+// always little-endian).
+for (unsigned I = 0; I < 4; ++I) {
+  Buffer[I] = uint8_t(Inst);
+  Inst >>= 8;
+}
+
 EmitA64MappingSymbol();
-MCELFStreamer::EmitIntValue(Inst, 4);
+MCELFStreamer::EmitBytes(StringRef(Buffer, 4));
   }
 
   /// This is one of the functions used to emit data into an ELF section, so 
the

Modified: llvm/branches/release_38/test/MC/AArch64/inst-directive.s
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/test/MC/AArch64/inst-directive.s?rev=258326&r1=258325&r2=258326&view=diff
==
--- llvm/branches/release_38/test/MC/AArch64/inst-directive.s (original)
+++ llvm/branches/release_38/test/MC/AArch64/inst-directive.s Wed Jan 20 
12:01:05 2016
@@ -1,7 +1,14 @@
 // RUN: llvm-mc %s -triple=aarch64-none-linux-gnu -filetype=asm -o - \
 // RUN:   | FileCheck %s --check-prefix=CHECK-ASM
-// RUN: llvm-mc %s -triple=aarch64-none-linux-gnu -filetype=obj -o - \
-// RUN:   | llvm-readobj -s -sd | FileCheck %s  --check-prefix=CHECK-OBJ
+// RUN: llvm-mc %s -triple=aarch64-none-linux-gnu -filetype=obj -o %t
+// RUN: llvm-readobj -s -sd %t | FileCheck %s  --check-prefix=CHECK-OBJ
+// RUN: llvm-objdump -t %t | FileCheck %s  --check-prefix=CHECK-SYMS
+
+// RUN: llvm-mc %s -triple=aarch64_be-none-linux-gnu -filetype=asm -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ASM
+// RUN: llvm-mc %s -triple=aarch64_be-none-linux-gnu -filetype=obj -o %t
+// RUN: llvm-readobj -s -sd %t | FileCheck %s  --check-prefix=CHECK-OBJ
+// RUN: llvm-objdump -t %t | FileCheck %s  --check-prefix=CHECK-SYMS
 
 .section.inst.aarch64_inst
 
@@ -22,3 +29,7 @@ aarch64_inst:
 // CHECK-OBJ:   SectionData (
 // CHECK-OBJ-NEXT: : 2040105E
 // CHECK-OBJ-NEXT: )
+
+// CHECK-SYMS-NOT:  .inst.aarch64_inst  
 $d
+// CHECK-SYMS:  .inst.aarch64_inst  
 $x
+// CHECK-SYMS-NOT:  .inst.aarch64_inst  
 $d


___
llvm-branch-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra-branch] r258345 - Merging r258327:

2016-01-20 Thread Hans Wennborg via llvm-branch-commits
Author: hans
Date: Wed Jan 20 15:02:50 2016
New Revision: 258345

URL: http://llvm.org/viewvc/llvm-project?rev=258345&view=rev
Log:
Merging r258327:

r258327 | dim | 2016-01-20 10:53:44 -0800 (Wed, 20 Jan 2016) | 4 lines

Ensure the lit.site.cfg and Unit/lit.site.cfg make targets do not use
the same temporary file, otherwise there is a race condition when using
parallel make jobs.



Modified:
clang-tools-extra/branches/release_38/   (props changed)
clang-tools-extra/branches/release_38/test/Makefile   (contents, props 
changed)

Propchange: clang-tools-extra/branches/release_38/
--
svn:mergeinfo = /clang-tools-extra/trunk:258327

Modified: clang-tools-extra/branches/release_38/test/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/branches/release_38/test/Makefile?rev=258345&r1=258344&r2=258345&view=diff
==
--- clang-tools-extra/branches/release_38/test/Makefile (original)
+++ clang-tools-extra/branches/release_38/test/Makefile Wed Jan 20 15:02:50 2016
@@ -60,12 +60,12 @@ lit.site.cfg: FORCE
 Unit/lit.site.cfg: FORCE
@echo "Making Unit/lit.site.cfg for Clang extra tools..."
@$(MKDIR) $(dir $@)
-   @$(ECHOPATH) s=@LLVM_LIBS_DIR@=$(LibDir)=g >> lit.tmp
-   @$(ECHOPATH) s=@CLANG_TOOLS_BINARY_DIR@=$(PROJ_OBJ_DIR)/..=g >> lit.tmp
-   @$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> lit.tmp
-   @$(ECHOPATH) s=@CLANG_TOOLS_SOURCE_DIR@=$(PROJ_SRC_DIR)/..=g >> lit.tmp
-   @sed -f lit.tmp $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@
-   @-rm -f lit.tmp
+   @$(ECHOPATH) s=@LLVM_LIBS_DIR@=$(LibDir)=g >> unit.tmp
+   @$(ECHOPATH) s=@CLANG_TOOLS_BINARY_DIR@=$(PROJ_OBJ_DIR)/..=g >> unit.tmp
+   @$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> unit.tmp
+   @$(ECHOPATH) s=@CLANG_TOOLS_SOURCE_DIR@=$(PROJ_SRC_DIR)/..=g >> unit.tmp
+   @sed -f unit.tmp $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@
+   @-rm -f unit.tmp
 
 clean::
@ find . -name Output | xargs rm -fr

Propchange: clang-tools-extra/branches/release_38/test/Makefile
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 20 15:02:50 2016
@@ -1,2 +1,3 @@
 /cfe/branches/type-system-rewrite/test/Makefile:134693-134817
 /cfe/trunk/test/SemaTemplate/test/Makefile:126920
+/clang-tools-extra/trunk/test/Makefile:258327


___
llvm-branch-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm-branch] r258349 - Merging r258273:

2016-01-20 Thread Hans Wennborg via llvm-branch-commits
Author: hans
Date: Wed Jan 20 15:14:05 2016
New Revision: 258349

URL: http://llvm.org/viewvc/llvm-project?rev=258349&view=rev
Log:
Merging r258273:

r258273 | josepht | 2016-01-19 18:15:15 -0800 (Tue, 19 Jan 2016) | 37 lines

[Inliner/WinEH] Honor implicit nounwinds

Summary:
Funclet EH tables require that a given funclet have only one unwind
destination for exceptional exits.  The verifier will therefore reject
e.g. two cleanuprets with different unwind dests for the same cleanup, or
two invokes exiting the same funclet but to different unwind dests.
Because catchswitch has no 'nounwind' variant, and because IR producers
are not *required* to annotate calls which will not unwind as 'nounwind',
it is legal to nest a call or an "unwind to caller" catchswitch within a
funclet pad that has an unwind destination other than caller; it is
undefined behavior for such a call or catchswitch to unwind.

Normally when inlining an invoke, calls in the inlined sequence are
rewritten to invokes that unwind to the callsite invoke's unwind
destination, and "unwind to caller" catchswitches in the inlined sequence
are rewritten to unwind to the callsite invoke's unwind destination.
However, if such a call or "unwind to caller" catchswitch is located in a
callee funclet that has another exceptional exit with an unwind
destination within the callee, applying the normal transformation would
give that callee funclet multiple unwind destinations for its exceptional
exits.  There would be no way for EH table generation to determine which
is the "true" exit, and the verifier would reject the function
accordingly.

Add logic to the inliner to detect these cases and leave such calls and
"unwind to caller" catchswitches as calls and "unwind to caller"
catchswitches in the inlined sequence.

This fixes PR26147.


Reviewers: rnk, andrew.w.kaylor, majnemer

Subscribers: alexcrichton, llvm-commits

Differential Revision: http://reviews.llvm.org/D16319


Added:
llvm/branches/release_38/test/Transforms/Inline/inline-funclets.ll
  - copied unchanged from r258273, 
llvm/trunk/test/Transforms/Inline/inline-funclets.ll
Modified:
llvm/branches/release_38/   (props changed)
llvm/branches/release_38/lib/Transforms/Utils/InlineFunction.cpp

Propchange: llvm/branches/release_38/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 20 15:14:05 2016
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257902,257905,257925,257929-257930,257977,257979,257997,258168,258207,258221
+/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257902,257905,257925,257929-257930,257977,257979,257997,258168,258207,258221,258273

Modified: llvm/branches/release_38/lib/Transforms/Utils/InlineFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/lib/Transforms/Utils/InlineFunction.cpp?rev=258349&r1=258348&r2=258349&view=diff
==
--- llvm/branches/release_38/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/branches/release_38/lib/Transforms/Utils/InlineFunction.cpp Wed Jan 20 
15:14:05 2016
@@ -179,13 +179,244 @@ void LandingPadInliningInfo::forwardResu
   RI->eraseFromParent();
 }
 
+/// Helper for getUnwindDestToken/getUnwindDestTokenHelper.
+static Value *getParentPad(Value *EHPad) {
+  if (auto *FPI = dyn_cast(EHPad))
+return FPI->getParentPad();
+  return cast(EHPad)->getParentPad();
+}
+
+typedef DenseMap UnwindDestMemoTy;
+
+/// Helper for getUnwindDestToken that does the descendant-ward part of
+/// the search.
+static Value *getUnwindDestTokenHelper(Instruction *EHPad,
+   UnwindDestMemoTy &MemoMap) {
+  SmallVector Worklist(1, EHPad);
+
+  while (!Worklist.empty()) {
+Instruction *CurrentPad = Worklist.pop_back_val();
+// We only put pads on the worklist that aren't in the MemoMap.  When
+// we find an unwind dest for a pad we may update its ancestors, but
+// the queue only ever contains uncles/great-uncles/etc. of CurrentPad,
+// so they should never get updated while queued on the worklist.
+assert(!MemoMap.count(CurrentPad));
+Value *UnwindDestToken = nullptr;
+if (auto *CatchSwitch = dyn_cast(CurrentPad)) {
+  if (CatchSwitch->hasUnwindDest()) {
+UnwindDestToken = CatchSwitch->getUnwindDest()->getFirstNonPHI();
+  } else {
+// Catchswitch doesn't have a 'nounwind' variant, and one might be
+// annotated as "unwinds to caller" when really it's nounwind (see
+// e.g. SimplifyCFGOpt::SimplifyUnreachable), so we can't infer the
+// parent's unwind dest from this.  We ca

[llvm-branch-commits] [llvm-branch] r258351 - Merging r257940:

2016-01-20 Thread Hans Wennborg via llvm-branch-commits
Author: hans
Date: Wed Jan 20 15:30:57 2016
New Revision: 258351

URL: http://llvm.org/viewvc/llvm-project?rev=258351&view=rev
Log:
Merging r257940:

r257940 | djg | 2016-01-15 13:56:40 -0800 (Fri, 15 Jan 2016) | 10 lines

[SelectionDAG] CSE nodes with differing SDNodeFlags

In the optimizer (GVN etc.) when eliminating redundant nodes with different
flags, the flags are ignored for the purposes of testing for congruence, and
then intersected for the purposes of producing a result that supports the union
of all the uses. This commit makes SelectionDAG's CSE do the same thing,
allowing it to CSE nodes in more cases. This fixes PR26063.

Differential Revision: http://reviews.llvm.org/D15957


Merging r257942:

r257942 | djg | 2016-01-15 14:07:35 -0800 (Fri, 15 Jan 2016) | 2 lines

Remove a now-empty file left behind by r257940.



Added:
llvm/branches/release_38/test/CodeGen/ARM/cse-flags.ll
  - copied unchanged from r257940, llvm/trunk/test/CodeGen/ARM/cse-flags.ll
Removed:
llvm/branches/release_38/test/CodeGen/X86/2014-05-30-CombineAddNSW.ll
Modified:
llvm/branches/release_38/   (props changed)
llvm/branches/release_38/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/branches/release_38/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Propchange: llvm/branches/release_38/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 20 15:30:57 2016
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257902,257905,257925,257929-257930,257977,257979,257997,258168,258207,258221,258273
+/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257902,257905,257925,257929-257930,257940,257942,257977,257979,257997,258168,258207,258221,258273

Modified: llvm/branches/release_38/include/llvm/CodeGen/SelectionDAGNodes.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/include/llvm/CodeGen/SelectionDAGNodes.h?rev=258351&r1=258350&r2=258351&view=diff
==
--- llvm/branches/release_38/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/branches/release_38/include/llvm/CodeGen/SelectionDAGNodes.h Wed Jan 
20 15:30:57 2016
@@ -369,6 +369,18 @@ public:
 (UnsafeAlgebra << 3) | (NoNaNs << 4) | (NoInfs << 5) |
 (NoSignedZeros << 6) | (AllowReciprocal << 7);
   }
+
+  /// Clear any flags in this flag set that aren't also set in Flags.
+  void intersectWith(const SDNodeFlags *Flags) {
+NoUnsignedWrap &= Flags->NoUnsignedWrap;
+NoSignedWrap &= Flags->NoSignedWrap;
+Exact &= Flags->Exact;
+UnsafeAlgebra &= Flags->UnsafeAlgebra;
+NoNaNs &= Flags->NoNaNs;
+NoInfs &= Flags->NoInfs;
+NoSignedZeros &= Flags->NoSignedZeros;
+AllowReciprocal &= Flags->AllowReciprocal;
+  }
 };
 
 /// Represents one node in the SelectionDAG.
@@ -682,6 +694,9 @@ public:
   /// and directly, but it is not to avoid creating a vtable for this class.
   const SDNodeFlags *getFlags() const;
 
+  /// Clear any flags in this node that aren't also set in Flags.
+  void intersectFlagsWith(const SDNodeFlags *Flags);
+
   /// Return the number of values defined/returned by this operator.
   unsigned getNumValues() const { return NumValues; }
 

Modified: llvm/branches/release_38/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=258351&r1=258350&r2=258351&view=diff
==
--- llvm/branches/release_38/lib/CodeGen/SelectionDAG/SelectionDAG.cpp 
(original)
+++ llvm/branches/release_38/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Jan 
20 15:30:57 2016
@@ -377,22 +377,6 @@ static void AddNodeIDOperands(FoldingSet
   }
 }
 
-/// Add logical or fast math flag values to FoldingSetNodeID value.
-static void AddNodeIDFlags(FoldingSetNodeID &ID, unsigned Opcode,
-   const SDNodeFlags *Flags) {
-  if (!isBinOpWithFlags(Opcode))
-return;
-
-  unsigned RawFlags = 0;
-  if (Flags)
-RawFlags = Flags->getRawFlags();
-  ID.AddInteger(RawFlags);
-}
-
-static void AddNodeIDFlags(FoldingSetNodeID &ID, const SDNode *N) {
-  AddNodeIDFlags(ID, N->getOpcode(), N->getFlags());
-}
-
 static void AddNodeIDNode(FoldingSetNodeID &ID, unsigned short OpC,
   SDVTList VTList, ArrayRef OpList) {
   AddNodeIDOpcode(ID, OpC);
@@ -528,8 +512,6 @@ static void AddNodeIDCustom(FoldingSetNo
   }
   } // end switch (N->getOpcode())
 
-  AddNodeIDFla

[llvm-branch-commits] [llvm-branch] r258353 - Merging r258325:

2016-01-20 Thread Hans Wennborg via llvm-branch-commits
Author: hans
Date: Wed Jan 20 15:49:02 2016
New Revision: 258353

URL: http://llvm.org/viewvc/llvm-project?rev=258353&view=rev
Log:
Merging r258325:

r258325 | spatel | 2016-01-20 09:41:14 -0800 (Wed, 20 Jan 2016) | 21 lines

[LibCallSimplifier] don't get fooled by a fake sqrt()

The test case will crash without this patch because the subsequent call to
hasUnsafeAlgebra() assumes that the call instruction is an FPMathOperator
(ie, returns an FP type).

This part of the function signature check was omitted for the sqrt() case, 
but seems to be in place for all other transforms.

Before:
http://reviews.llvm.org/rL257400
...we would have needlessly continued execution in optimizeSqrt(), but the
bug was harmless because we'd eventually fail some other check and return
without damage.

This should fix:
https://llvm.org/bugs/show_bug.cgi?id=26211

Differential Revision: http://reviews.llvm.org/D16198




Modified:
llvm/branches/release_38/   (props changed)
llvm/branches/release_38/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/branches/release_38/test/Transforms/InstCombine/cos-2.ll

Propchange: llvm/branches/release_38/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 20 15:49:02 2016
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257902,257905,257925,257929-257930,257940,257942,257977,257979,257997,258168,258207,258221,258273
+/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257902,257905,257925,257929-257930,257940,257942,257977,257979,257997,258168,258207,258221,258273,258325

Modified: llvm/branches/release_38/lib/Transforms/Utils/SimplifyLibCalls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/lib/Transforms/Utils/SimplifyLibCalls.cpp?rev=258353&r1=258352&r2=258353&view=diff
==
--- llvm/branches/release_38/lib/Transforms/Utils/SimplifyLibCalls.cpp 
(original)
+++ llvm/branches/release_38/lib/Transforms/Utils/SimplifyLibCalls.cpp Wed Jan 
20 15:49:02 2016
@@ -1394,12 +1394,21 @@ Value *LibCallSimplifier::optimizeLog(Ca
 
 Value *LibCallSimplifier::optimizeSqrt(CallInst *CI, IRBuilder<> &B) {
   Function *Callee = CI->getCalledFunction();
-  
+
   Value *Ret = nullptr;
   if (TLI->has(LibFunc::sqrtf) && (Callee->getName() == "sqrt" ||
Callee->getIntrinsicID() == 
Intrinsic::sqrt))
 Ret = optimizeUnaryDoubleFP(CI, B, true);
 
+  // FIXME: Refactor - this check is repeated all over this file and even in 
the
+  // preceding call to shrink double -> float.
+
+  // Make sure this has 1 argument of FP type, which matches the result type.
+  FunctionType *FT = Callee->getFunctionType();
+  if (FT->getNumParams() != 1 || FT->getReturnType() != FT->getParamType(0) ||
+  !FT->getParamType(0)->isFloatingPointTy())
+return Ret;
+
   if (!CI->hasUnsafeAlgebra())
 return Ret;
 

Modified: llvm/branches/release_38/test/Transforms/InstCombine/cos-2.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/test/Transforms/InstCombine/cos-2.ll?rev=258353&r1=258352&r2=258353&view=diff
==
--- llvm/branches/release_38/test/Transforms/InstCombine/cos-2.ll (original)
+++ llvm/branches/release_38/test/Transforms/InstCombine/cos-2.ll Wed Jan 20 
15:49:02 2016
@@ -1,12 +1,11 @@
-; Test that the cos library call simplifier works correctly.
-;
 ; RUN: opt < %s -instcombine -S | FileCheck %s
 
 target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 
 declare float @cos(double)
+declare signext i8 @sqrt(...)
 
-; Check that cos functions with the wrong prototype aren't simplified.
+; Check that functions with the wrong prototype aren't simplified.
 
 define float @test_no_simplify1(double %d) {
 ; CHECK-LABEL: @test_no_simplify1(
@@ -15,3 +14,14 @@ define float @test_no_simplify1(double %
 ; CHECK: call float @cos(double %neg)
   ret float %cos
 }
+
+
+define i8 @bogus_sqrt() {
+  %fake_sqrt = call signext i8 (...) @sqrt()
+  ret i8 %fake_sqrt
+
+; CHECK-LABEL: bogus_sqrt(
+; CHECK-NEXT:  %fake_sqrt = call signext i8 (...) @sqrt()
+; CHECK-NEXT:  ret i8 %fake_sqrt
+}
+


___
llvm-branch-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits