[PATCH] D44381: [mips] Prevent PIC to be set to level 2

2018-04-16 Thread Aleksandar Beserminji via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330118: [mips] Prevent PIC to be set to level 2 (authored by 
abeserminji, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44381?vs=142406=142609#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44381

Files:
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/test/Driver/pic.c


Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1007,12 +1007,17 @@
   if ((ROPI || RWPI) && (PIC || PIE))
 ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic);
 
-  // When targettng MIPS64 with N64, the default is PIC, unless -mno-abicalls 
is
-  // used.
-  if ((Triple.getArch() == llvm::Triple::mips64 ||
-   Triple.getArch() == llvm::Triple::mips64el) &&
-  Args.hasArg(options::OPT_mno_abicalls))
-return std::make_tuple(llvm::Reloc::Static, 0U, false);
+  if (Triple.getArch() == llvm::Triple::mips ||
+   Triple.getArch() == llvm::Triple::mipsel ||
+   Triple.getArch() == llvm::Triple::mips64 ||
+   Triple.getArch() == llvm::Triple::mips64el) {
+// When targettng MIPS with -mno-abicalls, it's always static.
+if(Args.hasArg(options::OPT_mno_abicalls))
+  return std::make_tuple(llvm::Reloc::Static, 0U, false);
+// Unlike other architectures, MIPS, even with -fPIC/-mxgot/multigot,
+// does not use PIC level 2 for historical reasons.
+IsPICLevelTwo = false;
+  }
 
   if (PIC)
 return std::make_tuple(llvm::Reloc::PIC_, IsPICLevelTwo ? 2U : 1U, PIE);
Index: cfe/trunk/test/Driver/pic.c
===
--- cfe/trunk/test/Driver/pic.c
+++ cfe/trunk/test/Driver/pic.c
@@ -292,9 +292,9 @@
 // RUN: %clang -c %s -target mipsel-linux-android14 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
 // RUN: %clang -c %s -target mipsel-linux-android16 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 // RUN: %clang -c %s -target mipsel-linux-android24 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 //
 // 64-bit Android targets are always PIE.
 // RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \


Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1007,12 +1007,17 @@
   if ((ROPI || RWPI) && (PIC || PIE))
 ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic);
 
-  // When targettng MIPS64 with N64, the default is PIC, unless -mno-abicalls is
-  // used.
-  if ((Triple.getArch() == llvm::Triple::mips64 ||
-   Triple.getArch() == llvm::Triple::mips64el) &&
-  Args.hasArg(options::OPT_mno_abicalls))
-return std::make_tuple(llvm::Reloc::Static, 0U, false);
+  if (Triple.getArch() == llvm::Triple::mips ||
+   Triple.getArch() == llvm::Triple::mipsel ||
+   Triple.getArch() == llvm::Triple::mips64 ||
+   Triple.getArch() == llvm::Triple::mips64el) {
+// When targettng MIPS with -mno-abicalls, it's always static.
+if(Args.hasArg(options::OPT_mno_abicalls))
+  return std::make_tuple(llvm::Reloc::Static, 0U, false);
+// Unlike other architectures, MIPS, even with -fPIC/-mxgot/multigot,
+// does not use PIC level 2 for historical reasons.
+IsPICLevelTwo = false;
+  }
 
   if (PIC)
 return std::make_tuple(llvm::Reloc::PIC_, IsPICLevelTwo ? 2U : 1U, PIE);
Index: cfe/trunk/test/Driver/pic.c
===
--- cfe/trunk/test/Driver/pic.c
+++ cfe/trunk/test/Driver/pic.c
@@ -292,9 +292,9 @@
 // RUN: %clang -c %s -target mipsel-linux-android14 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
 // RUN: %clang -c %s -target mipsel-linux-android16 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 // RUN: %clang -c %s -target mipsel-linux-android24 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 //
 // 64-bit Android targets are always PIE.
 // RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44381: [mips] Prevent PIC to be set to level 2

2018-04-16 Thread Aleksandar Beserminji via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330118: [mips] Prevent PIC to be set to level 2 (authored by 
abeserminji, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D44381

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/pic.c


Index: test/Driver/pic.c
===
--- test/Driver/pic.c
+++ test/Driver/pic.c
@@ -292,9 +292,9 @@
 // RUN: %clang -c %s -target mipsel-linux-android14 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
 // RUN: %clang -c %s -target mipsel-linux-android16 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 // RUN: %clang -c %s -target mipsel-linux-android24 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 //
 // 64-bit Android targets are always PIE.
 // RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -1007,12 +1007,17 @@
   if ((ROPI || RWPI) && (PIC || PIE))
 ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic);
 
-  // When targettng MIPS64 with N64, the default is PIC, unless -mno-abicalls 
is
-  // used.
-  if ((Triple.getArch() == llvm::Triple::mips64 ||
-   Triple.getArch() == llvm::Triple::mips64el) &&
-  Args.hasArg(options::OPT_mno_abicalls))
-return std::make_tuple(llvm::Reloc::Static, 0U, false);
+  if (Triple.getArch() == llvm::Triple::mips ||
+   Triple.getArch() == llvm::Triple::mipsel ||
+   Triple.getArch() == llvm::Triple::mips64 ||
+   Triple.getArch() == llvm::Triple::mips64el) {
+// When targettng MIPS with -mno-abicalls, it's always static.
+if(Args.hasArg(options::OPT_mno_abicalls))
+  return std::make_tuple(llvm::Reloc::Static, 0U, false);
+// Unlike other architectures, MIPS, even with -fPIC/-mxgot/multigot,
+// does not use PIC level 2 for historical reasons.
+IsPICLevelTwo = false;
+  }
 
   if (PIC)
 return std::make_tuple(llvm::Reloc::PIC_, IsPICLevelTwo ? 2U : 1U, PIE);


Index: test/Driver/pic.c
===
--- test/Driver/pic.c
+++ test/Driver/pic.c
@@ -292,9 +292,9 @@
 // RUN: %clang -c %s -target mipsel-linux-android14 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
 // RUN: %clang -c %s -target mipsel-linux-android16 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 // RUN: %clang -c %s -target mipsel-linux-android24 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 //
 // 64-bit Android targets are always PIE.
 // RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -1007,12 +1007,17 @@
   if ((ROPI || RWPI) && (PIC || PIE))
 ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic);
 
-  // When targettng MIPS64 with N64, the default is PIC, unless -mno-abicalls is
-  // used.
-  if ((Triple.getArch() == llvm::Triple::mips64 ||
-   Triple.getArch() == llvm::Triple::mips64el) &&
-  Args.hasArg(options::OPT_mno_abicalls))
-return std::make_tuple(llvm::Reloc::Static, 0U, false);
+  if (Triple.getArch() == llvm::Triple::mips ||
+   Triple.getArch() == llvm::Triple::mipsel ||
+   Triple.getArch() == llvm::Triple::mips64 ||
+   Triple.getArch() == llvm::Triple::mips64el) {
+// When targettng MIPS with -mno-abicalls, it's always static.
+if(Args.hasArg(options::OPT_mno_abicalls))
+  return std::make_tuple(llvm::Reloc::Static, 0U, false);
+// Unlike other architectures, MIPS, even with -fPIC/-mxgot/multigot,
+// does not use PIC level 2 for historical reasons.
+IsPICLevelTwo = false;
+  }
 
   if (PIC)
 return std::make_tuple(llvm::Reloc::PIC_, IsPICLevelTwo ? 2U : 1U, PIE);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44381: [mips] Prevent PIC to be set to level 2

2018-04-13 Thread Simon Dardis via Phabricator via cfe-commits
sdardis accepted this revision.
sdardis added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D44381



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44381: [mips] Prevent PIC to be set to level 2

2018-04-13 Thread Aleksandar Beserminji via Phabricator via cfe-commits
abeserminji updated this revision to Diff 142406.
abeserminji marked an inline comment as done.
abeserminji edited the summary of this revision.
abeserminji added a comment.

Comments resolved.


Repository:
  rC Clang

https://reviews.llvm.org/D44381

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/pic.c


Index: test/Driver/pic.c
===
--- test/Driver/pic.c
+++ test/Driver/pic.c
@@ -292,9 +292,9 @@
 // RUN: %clang -c %s -target mipsel-linux-android14 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
 // RUN: %clang -c %s -target mipsel-linux-android16 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 // RUN: %clang -c %s -target mipsel-linux-android24 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 //
 // 64-bit Android targets are always PIE.
 // RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -1007,12 +1007,17 @@
   if ((ROPI || RWPI) && (PIC || PIE))
 ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic);
 
-  // When targettng MIPS64 with N64, the default is PIC, unless -mno-abicalls 
is
-  // used.
-  if ((Triple.getArch() == llvm::Triple::mips64 ||
-   Triple.getArch() == llvm::Triple::mips64el) &&
-  Args.hasArg(options::OPT_mno_abicalls))
-return std::make_tuple(llvm::Reloc::Static, 0U, false);
+  if (Triple.getArch() == llvm::Triple::mips ||
+   Triple.getArch() == llvm::Triple::mipsel ||
+   Triple.getArch() == llvm::Triple::mips64 ||
+   Triple.getArch() == llvm::Triple::mips64el) {
+// When targettng MIPS with -mno-abicalls, it's always static.
+if(Args.hasArg(options::OPT_mno_abicalls))
+  return std::make_tuple(llvm::Reloc::Static, 0U, false);
+// Unlike other architectures, MIPS, even with -fPIC/-mxgot/multigot,
+// does not use PIC level 2 for historical reasons.
+IsPICLevelTwo = false;
+  }
 
   if (PIC)
 return std::make_tuple(llvm::Reloc::PIC_, IsPICLevelTwo ? 2U : 1U, PIE);


Index: test/Driver/pic.c
===
--- test/Driver/pic.c
+++ test/Driver/pic.c
@@ -292,9 +292,9 @@
 // RUN: %clang -c %s -target mipsel-linux-android14 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
 // RUN: %clang -c %s -target mipsel-linux-android16 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 // RUN: %clang -c %s -target mipsel-linux-android24 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 //
 // 64-bit Android targets are always PIE.
 // RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -1007,12 +1007,17 @@
   if ((ROPI || RWPI) && (PIC || PIE))
 ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic);
 
-  // When targettng MIPS64 with N64, the default is PIC, unless -mno-abicalls is
-  // used.
-  if ((Triple.getArch() == llvm::Triple::mips64 ||
-   Triple.getArch() == llvm::Triple::mips64el) &&
-  Args.hasArg(options::OPT_mno_abicalls))
-return std::make_tuple(llvm::Reloc::Static, 0U, false);
+  if (Triple.getArch() == llvm::Triple::mips ||
+   Triple.getArch() == llvm::Triple::mipsel ||
+   Triple.getArch() == llvm::Triple::mips64 ||
+   Triple.getArch() == llvm::Triple::mips64el) {
+// When targettng MIPS with -mno-abicalls, it's always static.
+if(Args.hasArg(options::OPT_mno_abicalls))
+  return std::make_tuple(llvm::Reloc::Static, 0U, false);
+// Unlike other architectures, MIPS, even with -fPIC/-mxgot/multigot,
+// does not use PIC level 2 for historical reasons.
+IsPICLevelTwo = false;
+  }
 
   if (PIC)
 return std::make_tuple(llvm::Reloc::PIC_, IsPICLevelTwo ? 2U : 1U, PIE);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44381: [mips] Prevent PIC to be set to level 2

2018-04-06 Thread Simon Dardis via Phabricator via cfe-commits
sdardis requested changes to this revision.
sdardis added a comment.
This revision now requires changes to proceed.

You should also update the description of the patch.


Repository:
  rC Clang

https://reviews.llvm.org/D44381



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44381: [mips] Prevent PIC to be set to level 2

2018-03-29 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added inline comments.



Comment at: lib/Driver/ToolChains/CommonArgs.cpp:983
+  return std::make_tuple(llvm::Reloc::Static, 0U, false);
+// It's never PIC level 2 for mips.
+IsPICLevelTwo = false;

Can you reformulate this comment to say that MIPS does not use PIC level 2? 
Also, please add a note stating that even with -mxgot / -fPIC / multigot , MIPS 
does not use PIC level 2 unlike other architecutres for historical reasons.


Repository:
  rC Clang

https://reviews.llvm.org/D44381



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits