[llvm-branch-commits] [llvm] d2071b8 - Revert "Re-land [MC] Fix quadratic behavior in addPendingLabel"

2020-04-29 Thread Tom Stellard via llvm-branch-commits

Author: Tom Stellard
Date: 2020-04-29T11:08:42-07:00
New Revision: d2071b8fcdc5e8794d467cec9ebab735d09218bf

URL: 
https://github.com/llvm/llvm-project/commit/d2071b8fcdc5e8794d467cec9ebab735d09218bf
DIFF: 
https://github.com/llvm/llvm-project/commit/d2071b8fcdc5e8794d467cec9ebab735d09218bf.diff

LOG: Revert "Re-land [MC] Fix quadratic behavior in addPendingLabel"

This reverts commit aa97472d211df67e91e8c1dd3188a0fb2ff942c8.

This commit broke ABI compatibility:
https://github.com/llvm/llvm-project/runs/624609989

Added: 


Modified: 
llvm/include/llvm/MC/MCObjectStreamer.h
llvm/lib/MC/MCObjectStreamer.cpp

Removed: 




diff  --git a/llvm/include/llvm/MC/MCObjectStreamer.h 
b/llvm/include/llvm/MC/MCObjectStreamer.h
index 701cdf30b479..9e3f87565e26 100644
--- a/llvm/include/llvm/MC/MCObjectStreamer.h
+++ b/llvm/include/llvm/MC/MCObjectStreamer.h
@@ -9,7 +9,6 @@
 #ifndef LLVM_MC_MCOBJECTSTREAMER_H
 #define LLVM_MC_MCOBJECTSTREAMER_H
 
-#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/MC/MCAssembler.h"
 #include "llvm/MC/MCSection.h"
@@ -39,7 +38,7 @@ class MCObjectStreamer : public MCStreamer {
   bool EmitEHFrame;
   bool EmitDebugFrame;
   SmallVector PendingLabels;
-  SmallSetVector PendingLabelSections;
+  SmallVector PendingLabelSections;
   unsigned CurSubsectionIdx;
   struct PendingMCFixup {
 const MCSymbol *Sym;

diff  --git a/llvm/lib/MC/MCObjectStreamer.cpp 
b/llvm/lib/MC/MCObjectStreamer.cpp
index e05a0ec11f56..3d1358df475f 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -59,8 +59,12 @@ void MCObjectStreamer::addPendingLabel(MCSymbol* S) {
 CurSection->addPendingLabel(S, CurSubsectionIdx);
 
 // Add this Section to the list of PendingLabelSections.
-PendingLabelSections.insert(CurSection);
-  } else
+auto SecIt = std::find(PendingLabelSections.begin(),
+   PendingLabelSections.end(), CurSection);
+if (SecIt == PendingLabelSections.end())
+  PendingLabelSections.push_back(CurSection);
+  }
+  else
 // There is no Section / Subsection for this label yet.
 PendingLabels.push_back(S);
 }



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


[llvm-branch-commits] [clang] 9cf9cf2 - [Clang] Fix Hurd toolchain test on a two-stage build with ThinLTO

2020-04-29 Thread Tom Stellard via llvm-branch-commits

Author: Alexandre Ganea
Date: 2020-04-29T15:23:44-07:00
New Revision: 9cf9cf2a398ce70d9187afa59db6500e7a1f2cd0

URL: 
https://github.com/llvm/llvm-project/commit/9cf9cf2a398ce70d9187afa59db6500e7a1f2cd0
DIFF: 
https://github.com/llvm/llvm-project/commit/9cf9cf2a398ce70d9187afa59db6500e7a1f2cd0.diff

LOG: [Clang] Fix Hurd toolchain test on a two-stage build with ThinLTO

A two-stage ThinLTO build previously failed the clang/test/Driver/hurd.c test 
because of a static_cast in "tools::gnutools::Linker::ConstructJob()" which 
wrongly converted an instance of "clang::driver::toolchains::Hurd" into that of 
"clang::driver::toolchains::Linux". ThinLTO would later devirtualize the 
"ToolChain.getDynamicLinker(Args)" call and use "Linux::getDynamicLinker()" 
instead, causing the test to generate a wrong "-dynamic-linker" linker flag 
(/lib/ld-linux.so.2 instead of /lib/ld.so)

Fixes PR45061.

Differential Revision: https://reviews.llvm.org/D75373

(cherry picked from commit 7e77cf473ac9d8f8b65db017d660892f1c8f4b75)

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Gnu.h
clang/lib/Driver/ToolChains/Hurd.cpp
clang/lib/Driver/ToolChains/Hurd.h
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Linux.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index da197e476621..e8ef881e89ac 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -309,7 +309,7 @@ static const char *getLDMOption(const llvm::Triple &T, 
const ArgList &Args) {
   }
 }
 
-static bool getPIE(const ArgList &Args, const toolchains::Linux &ToolChain) {
+static bool getPIE(const ArgList &Args, const ToolChain &TC) {
   if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static) ||
   Args.hasArg(options::OPT_r) || Args.hasArg(options::OPT_static_pie))
 return false;
@@ -317,17 +317,16 @@ static bool getPIE(const ArgList &Args, const 
toolchains::Linux &ToolChain) {
   Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie,
options::OPT_nopie);
   if (!A)
-return ToolChain.isPIEDefault();
+return TC.isPIEDefault();
   return A->getOption().matches(options::OPT_pie);
 }
 
-static bool getStaticPIE(const ArgList &Args,
- const toolchains::Linux &ToolChain) {
+static bool getStaticPIE(const ArgList &Args, const ToolChain &TC) {
   bool HasStaticPIE = Args.hasArg(options::OPT_static_pie);
   // -no-pie is an alias for -nopie. So, handling -nopie takes care of
   // -no-pie as well.
   if (HasStaticPIE && Args.hasArg(options::OPT_nopie)) {
-const Driver &D = ToolChain.getDriver();
+const Driver &D = TC.getDriver();
 const llvm::opt::OptTable &Opts = D.getOpts();
 const char *StaticPIEName = Opts.getOptionName(options::OPT_static_pie);
 const char *NoPIEName = Opts.getOptionName(options::OPT_nopie);
@@ -346,8 +345,12 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
-  const toolchains::Linux &ToolChain =
-  static_cast(getToolChain());
+  // FIXME: The Linker class constructor takes a ToolChain and not a
+  // Generic_ELF, so the static_cast might return a reference to a invalid
+  // instance (see PR45061). Ideally, the Linker constructor needs to take a
+  // Generic_ELF instead.
+  const toolchains::Generic_ELF &ToolChain =
+  static_cast(getToolChain());
   const Driver &D = ToolChain.getDriver();
 
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
@@ -418,8 +421,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   if (isAndroid)
   CmdArgs.push_back("--warn-shared-textrel");
 
-  for (const auto &Opt : ToolChain.ExtraOpts)
-CmdArgs.push_back(Opt.c_str());
+  ToolChain.addExtraOpts(CmdArgs);
 
   CmdArgs.push_back("--eh-frame-hdr");
 

diff  --git a/clang/lib/Driver/ToolChains/Gnu.h 
b/clang/lib/Driver/ToolChains/Gnu.h
index 083f74c05477..fa50b56bf954 100644
--- a/clang/lib/Driver/ToolChains/Gnu.h
+++ b/clang/lib/Driver/ToolChains/Gnu.h
@@ -356,6 +356,12 @@ class LLVM_LIBRARY_VISIBILITY Generic_ELF : public 
Generic_GCC {
   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
  llvm::opt::ArgStringList &CC1Args,
  Action::OffloadKind DeviceOffloadKind) const 
override;
+
+  virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const {
+return {};
+  }
+
+  virtual void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const {}
 };
 
 } // end namespace toolchains

diff  --git a/clang/lib/Driver/

[llvm-branch-commits] [llvm] e4312b9 - [Coroutines] Fix PR45130

2020-04-29 Thread Tom Stellard via llvm-branch-commits

Author: Jun Ma
Date: 2020-04-29T17:13:34-07:00
New Revision: e4312b950dd7b019e14b991a17d6ac260b8e8082

URL: 
https://github.com/llvm/llvm-project/commit/e4312b950dd7b019e14b991a17d6ac260b8e8082
DIFF: 
https://github.com/llvm/llvm-project/commit/e4312b950dd7b019e14b991a17d6ac260b8e8082.diff

LOG: [Coroutines] Fix PR45130

For now, when final suspend can be simplified by simplifySuspendPoint,
handleFinalSuspend is executed as well to remove last case in switch
instruction. This patch fixes it.

Differential Revision: https://reviews.llvm.org/D76345

(cherry picked from commit 032251e34d17c1cbf21e7571514bb775ed5cdf30)

Added: 


Modified: 
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/test/Transforms/Coroutines/no-suspend.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp 
b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 66cb3e74e53e..1e067a45d016 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -1155,7 +1155,10 @@ static void simplifySuspendPoints(coro::Shape &Shape) {
   if (N == 0)
 return;
   while (true) {
-if (simplifySuspendPoint(cast(S[I]), Shape.CoroBegin)) {
+auto SI = cast(S[I]);
+// Leave final.suspend to handleFinalSuspend since it is undefined behavior
+// to resume a coroutine suspended at the final suspend point.
+if (!SI->isFinal() && simplifySuspendPoint(SI, Shape.CoroBegin)) {
   if (--N == I)
 break;
   std::swap(S[I], S[N]);

diff  --git a/llvm/test/Transforms/Coroutines/no-suspend.ll 
b/llvm/test/Transforms/Coroutines/no-suspend.ll
index fca096fa48bb..beb2431b7f19 100644
--- a/llvm/test/Transforms/Coroutines/no-suspend.ll
+++ b/llvm/test/Transforms/Coroutines/no-suspend.ll
@@ -361,6 +361,58 @@ suspend:
   ret void
 }
 
+; SimplifySuspendPoint should not simplify final suspend point
+;
+; CHECK-LABEL: define void @cannot_simplify_final_suspend(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT: llvm.coro.id
+;
+define void @cannot_simplify_final_suspend() "coroutine.presplit"="1" 
personality i32 0 {
+entry:
+  %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
+  %need.dyn.alloc = call i1 @llvm.coro.alloc(token %id)
+  br i1 %need.dyn.alloc, label %dyn.alloc, label %coro.begin
+dyn.alloc:
+  %size = call i32 @llvm.coro.size.i32()
+  %alloc = call i8* @malloc(i32 %size)
+  br label %coro.begin
+coro.begin:
+  %phi = phi i8* [ null, %entry ], [ %alloc, %dyn.alloc ]
+  %hdl = call noalias i8* @llvm.coro.begin(token %id, i8* %phi)
+  br label %body
+body:
+  %save = call token @llvm.coro.save(i8* %hdl)
+  %subfn = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 1)
+  %bcast = bitcast i8* %subfn to void (i8*)*
+  invoke fastcc void %bcast(i8* %hdl) to label %real_susp unwind label %lpad
+
+real_susp:
+  %0 = call i8 @llvm.coro.suspend(token %save, i1 1)
+  switch i8 %0, label %suspend [i8 0, label %resume
+i8 1, label %pre.cleanup]
+resume:
+  call void @print(i32 0)
+  br label %cleanup
+
+pre.cleanup:
+  call void @print(i32 1)
+  br label %cleanup
+
+cleanup:
+  %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
+  call void @free(i8* %mem)
+  br label %suspend
+suspend:
+  call i1 @llvm.coro.end(i8* %hdl, i1 false)
+  ret void
+lpad:
+  %lpval = landingpad { i8*, i32 }
+ cleanup
+
+  call void @print(i32 2)
+  resume { i8*, i32 } %lpval
+}
+
 declare i8* @malloc(i32)
 declare void @free(i8*)
 declare void @print(i32)



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


[llvm-branch-commits] [libclc] 199494f - libclc: Pass system libraries to the linker after llvm libraries

2020-04-29 Thread Tom Stellard via llvm-branch-commits

Author: Tom Stellard
Date: 2020-04-29T18:01:01-07:00
New Revision: 199494f512e96aa86592e849aff2bceb832629c0

URL: 
https://github.com/llvm/llvm-project/commit/199494f512e96aa86592e849aff2bceb832629c0
DIFF: 
https://github.com/llvm/llvm-project/commit/199494f512e96aa86592e849aff2bceb832629c0.diff

LOG: libclc: Pass system libraries to the linker after llvm libraries

Summary:
The llvm libraries depend on the symbols in the system libaries, so
the system libraries need to be added after.

Reviewers: jvesely

Reviewed By: jvesely

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78535

(cherry picked from commit 174c41defc63db4ac7594e00a5044672ff624a31)

Added: 


Modified: 
libclc/CMakeLists.txt

Removed: 




diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 440eab076509..ca65cf930562 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -113,8 +113,8 @@ link_directories( ${LLVM_LIBDIR} )
 add_executable( prepare_builtins utils/prepare-builtins.cpp )
 target_compile_options( prepare_builtins PRIVATE ${LLVM_CXX_FLAGS} )
 target_compile_definitions( prepare_builtins PRIVATE ${LLVM_VERSION_DEFINE} )
-target_link_libraries( prepare_builtins PRIVATE ${LLVM_SYSTEM_LIBS} )
 target_link_libraries( prepare_builtins PRIVATE ${LLVM_LIBS} )
+target_link_libraries( prepare_builtins PRIVATE ${LLVM_SYSTEM_LIBS} )
 
 # Setup arch devices
 set( r600--_devices cedar cypress barts cayman )



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