[clang] d2fd110 - Reapply "[clang] Support fixed point types in C++ (#67750)" (#69963)

2023-11-14 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2023-11-14T20:18:06Z
New Revision: d2fd1106f6879c410b6a807133090866e6c3a243

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

LOG: Reapply "[clang] Support fixed point types in C++ (#67750)" (#69963)

This reverts commit d593f6cb387fe86aad47d3b763abcf0048e5b568.

Added: 
clang/test/CodeGenCXX/fixed-point-mangle.cpp

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/AST/ItaniumMangle.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseTentative.cpp
clang/test/Frontend/fixed_point_errors.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d1b67a448b2a59b..e63ee583f6b30c5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2117,7 +2117,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
+  BothFlags<[], [ClangOption], " fixed point types">>;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag _ # ISO/IEC TS 18661 binary floating point
-  // type _FloatN (N bits);
+  // ::= DF  _ # ISO/IEC TS 18661 binary floating 
point type _FloatN (N bits);
   // ::= Di # char32_t
   // ::= Ds # char16_t
   // ::= Dn # std::nullptr_t (i.e., decltype(nullptr))
+  // ::= [DS] DA  # N1169 fixed-point [_Sat] T _Accum
+  // ::= [DS] DR  # N1169 fixed-point [_Sat] T _Fract
   // ::= u # vendor extended type
+  //
+  //  
+  // ::= s # short
+  // ::= t # unsigned short
+  // ::= i # plain
+  // ::= j # unsigned
+  // ::= l # long
+  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3201,30 +3210,77 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
+Out << "DAs";
+break;
   case BuiltinType::Accum:
+Out << "DAi";
+break;
   case BuiltinType::LongAccum:
+Out << "DAl";
+break;
   case BuiltinType::UShortAccum:
+Out << "DAt";
+break;
   case BuiltinType::UAccum:
+Out << "DAj";
+break;
   case BuiltinType::ULongAccum:
+Out << "DAm";
+break;
   case BuiltinType::ShortFract:
+Out << "DRs";
+break;
   case BuiltinType::Fract:
+Out << "DRi";
+break;
   case BuiltinType::LongFract:
+Out << "DRl";
+break;
   case BuiltinType::UShortFract:
+Out << "DRt";
+break;
   case BuiltinType::UFract:
+Out << "DRj";
+break;
   case BuiltinType::ULongFract:
+Out << "DRm";
+break;
   case BuiltinType::SatShortAccum:
+Out << "DSDAs";
+break;
   case BuiltinType::SatAccum:
+Out << "DSDAi";
+break;
   case BuiltinType::SatLongAccum:
+Out << "DSDAl";
+break;
   case BuiltinType::SatUShortAccum:
+Out << "DSDAt";
+break;
   case BuiltinType::SatUAccum:
+Out << "DSDAj";
+break;
   case BuiltinType::SatULongAccum:
+Out << "DSDAm";
+break;
   case BuiltinType::SatShortFract:
+Out << "DSDRs";
+break;
   case BuiltinType::SatFract:
+Out << "DSDRi";
+break;
   case BuiltinType::SatLongFract:
+Out << "DSDRl";
+break;
   case BuiltinType::SatUShortFract:
+Out << "DSDRt";
+break;
   case BuiltinType::SatUFract:
+Out << "DSDRj";
+break;
   case BuiltinType::SatULongFract:
-llvm_unreachable("Fixed point types are disabled for c++");
+Out << "DSDRm";
+break;
   case BuiltinType::Half:
 Out << "Dh";
 break;

diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 9e05394e8d07dd6..897810557976151 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1577,6 +1577,9 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
   case tok::kw_typename:
   case tok::kw_typeof:
   case tok::kw___vector:
+  case tok::kw__Accum:
+  case tok::kw__Fract:
+  case tok::kw__Sat:
 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
 #include "clang/Basic/OpenCLImageTypes.def"
   {

diff  --git a/clang/lib/Parse/ParseExprCXX.cpp 
b/clang/lib/Parse/ParseExprCXX.cpp
index 99b4931004546c1..79db094e098f8e6 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -2354,6 +2354,15 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec ) {
   case tok::kw_bool:
 

[clang] ef38833 - Revert "Reapply "InstCombine: Introduce SimplifyDemandedUseFPClass""

2023-10-12 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2023-10-12T20:23:39Z
New Revision: ef388334ee5a3584255b9ef5b3fefdb244fa3fd7

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

LOG: Revert "Reapply "InstCombine: Introduce SimplifyDemandedUseFPClass""

This reverts commit 5a36904c515b.

Reverted because this breaks some floating point operations. See the
comment on https://github.com/llvm/llvm-project/commit/5a36904c515b.

Added: 


Modified: 
clang/test/Headers/__clang_hip_math.hip
llvm/include/llvm/Analysis/ValueTracking.h
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll

Removed: 




diff  --git a/clang/test/Headers/__clang_hip_math.hip 
b/clang/test/Headers/__clang_hip_math.hip
index 15eccc3b2baba08..fc18e14d8229635 100644
--- a/clang/test/Headers/__clang_hip_math.hip
+++ b/clang/test/Headers/__clang_hip_math.hip
@@ -231,8 +231,8 @@ extern "C" __device__ uint64_t test___make_mantissa(const 
char *p) {
 
 // CHECK-LABEL: @test_abs(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call noundef i32 @llvm.abs.i32(i32 
[[X:%.*]], i1 true)
-// CHECK-NEXT:ret i32 [[TMP0]]
+// CHECK-NEXT:[[ABS_I:%.*]] = tail call noundef i32 @llvm.abs.i32(i32 
[[X:%.*]], i1 true)
+// CHECK-NEXT:ret i32 [[ABS_I]]
 //
 extern "C" __device__ int test_abs(int x) {
   return abs(x);
@@ -240,8 +240,8 @@ extern "C" __device__ int test_abs(int x) {
 
 // CHECK-LABEL: @test_labs(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call noundef i64 @llvm.abs.i64(i64 
[[X:%.*]], i1 true)
-// CHECK-NEXT:ret i64 [[TMP0]]
+// CHECK-NEXT:[[ABS_I:%.*]] = tail call noundef i64 @llvm.abs.i64(i64 
[[X:%.*]], i1 true)
+// CHECK-NEXT:ret i64 [[ABS_I]]
 //
 extern "C" __device__ long test_labs(long x) {
   return labs(x);
@@ -249,8 +249,8 @@ extern "C" __device__ long test_labs(long x) {
 
 // CHECK-LABEL: @test_llabs(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call noundef i64 @llvm.abs.i64(i64 
[[X:%.*]], i1 true)
-// CHECK-NEXT:ret i64 [[TMP0]]
+// CHECK-NEXT:[[ABS_I:%.*]] = tail call noundef i64 @llvm.abs.i64(i64 
[[X:%.*]], i1 true)
+// CHECK-NEXT:ret i64 [[ABS_I]]
 //
 extern "C" __device__ long long test_llabs(long x) {
   return llabs(x);
@@ -2557,65 +2557,33 @@ extern "C" __device__ double test_nan(const char *tag) {
   return nan(tag);
 }
 
-// DEFAULT-LABEL: @test_nanf_emptystr(
-// DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:ret float 0x7FF8
-//
-// FINITEONLY-LABEL: @test_nanf_emptystr(
-// FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:ret float poison
-//
-// APPROX-LABEL: @test_nanf_emptystr(
-// APPROX-NEXT:  entry:
-// APPROX-NEXT:ret float 0x7FF8
+// CHECK-LABEL: @test_nanf_emptystr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret float 0x7FF8
 //
 extern "C" __device__ float test_nanf_emptystr() {
   return nanf("");
 }
 
-// DEFAULT-LABEL: @test_nan_emptystr(
-// DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:ret double 0x7FF8
-//
-// FINITEONLY-LABEL: @test_nan_emptystr(
-// FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:ret double poison
-//
-// APPROX-LABEL: @test_nan_emptystr(
-// APPROX-NEXT:  entry:
-// APPROX-NEXT:ret double 0x7FF8
+// CHECK-LABEL: @test_nan_emptystr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret double 0x7FF8
 //
 extern "C" __device__ double test_nan_emptystr() {
   return nan("");
 }
 
-// DEFAULT-LABEL: @test_nanf_fill(
-// DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:ret float 0x7FF8
-//
-// FINITEONLY-LABEL: @test_nanf_fill(
-// FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:ret float poison
-//
-// APPROX-LABEL: @test_nanf_fill(
-// APPROX-NEXT:  entry:
-// APPROX-NEXT:ret float 0x7FF8
+// CHECK-LABEL: @test_nanf_fill(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret float 0x7FF8
 //
 extern "C" __device__ float test_nanf_fill() {
   return nanf("0x456");
 }
 
-// DEFAULT-LABEL: @test_nan_fill(
-// DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:ret double 0x7FF8
-//
-// FINITEONLY-LABEL: @test_nan_fill(
-// FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:ret double poison
-//
-// APPROX-LABEL: @test_nan_fill(
-// APPROX-NEXT:  entry:
-// APPROX-NEXT:ret double 0x7FF8
+// CHECK-LABEL: @test_nan_fill(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret double 0x7FF8
 //
 extern "C" __device__ double test_nan_fill() {
   return nan("0x123");

diff  --git a/llvm/include/llvm/Analysis/ValueTracking.h 
b/llvm/include/llvm/Analysis/ValueTracking.h
index 

[clang] f45f1c3 - Reland "[clang] Add experimental option to omit the RTTI component from the vtable when -fno-rtti is used"

2023-09-14 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2023-09-14T18:28:37Z
New Revision: f45f1c3585e6b50dd134b3b23ac14d1ca322dc6f

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

LOG: Reland "[clang] Add experimental option to omit the RTTI component from 
the vtable when -fno-rtti is used"

This reverts commit 070493ddbd9473499d6f00ca62bc6aa92808ed79 (and
relands the original change). This removes a test run that makes an
assumption of RTTI being on by default for a given target.

Added: 
clang/test/CodeGenCXX/OmitRTTIComponentABI/simple-vtable-definition.cpp
clang/test/CodeGenCXX/OmitRTTIComponentABI/vbase-offset.cpp
clang/test/CodeGenCXX/OmitRTTIComponentABI/vtable-layout.cpp
clang/test/Driver/omit-rtti-component-flag.cpp
clang/test/Driver/omit-rtti-component-without-no-rtti.cpp

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/AST/VTableBuilder.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 86567267cfb437a..9349ff85ca8a1d3 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -674,6 +674,9 @@ def err_cc1_round_trip_mismatch : Error<
 def err_cc1_unbounded_vscale_min : Error<
   "minimum vscale must be an unsigned integer greater than 0">;
 
+def err_drv_using_omit_rtti_component_without_no_rtti : Error<
+  "-fexperimental-omit-vtable-rtti call only be used with -fno-rtti">;
+
 def err_drv_ssp_missing_offset_argument : Error<
   "'%0' is used without '-mstack-protector-guard-offset', and there is no 
default">;
 

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 102209ce899d70c..e18b5b80a34e718 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -450,6 +450,9 @@ LANGOPT(SpeculativeLoadHardening, 1, 0, "Speculative load 
hardening enabled")
 LANGOPT(RelativeCXXABIVTables, 1, 0,
 "Use an ABI-incompatible v-table layout that uses relative references")
 
+LANGOPT(OmitVTableRTTI, 1, 0,
+"Use an ABI-incompatible v-table layout that omits the RTTI component")
+
 LANGOPT(VScaleMin, 32, 0, "Minimum vscale value")
 LANGOPT(VScaleMax, 32, 0, "Maximum vscale value")
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2d42d05859bc1d3..553c7928c4f949e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2671,6 +2671,12 @@ def fno_experimental_relative_cxx_abi_vtables :
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Do not use the experimental C++ class ABI for classes with virtual 
tables">;
 
+defm experimental_omit_vtable_rtti : 
BoolFOption<"experimental-omit-vtable-rtti",
+  LangOpts<"OmitVTableRTTI">, DefaultFalse,
+  PosFlag,
+  NegFlag,
+  BothFlags<[], [CC1Option], " the RTTI component from virtual tables">>;
+
 def fcxx_abi_EQ : Joined<["-"], "fc++-abi=">,
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"C++ ABI to use. This will override the target C++ 
ABI.">;

diff  --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index a587f9bdc758529..cce0a507e8077d8 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -665,7 +665,11 @@ CharUnits 
VCallAndVBaseOffsetBuilder::getCurrentOffsetOffset() const {
   // vtable address point. (We subtract 3 to account for the information just
   // above the address point, the RTTI info, the offset to top, and the
   // vcall offset itself).
-  int64_t OffsetIndex = -(int64_t)(3 + Components.size());
+  size_t NumComponentsAboveAddrPoint = 3;
+  if (Context.getLangOpts().OmitVTableRTTI)
+NumComponentsAboveAddrPoint--;
+  int64_t OffsetIndex =
+  -(int64_t)(NumComponentsAboveAddrPoint + Components.size());
 
   // Under the relative ABI, the offset widths are 32-bit ints instead of
   // pointer widths.
@@ -1669,7 +1673,8 @@ void 
ItaniumVTableBuilder::LayoutPrimaryAndSecondaryVTables(
   Components.push_back(VTableComponent::MakeOffsetToTop(OffsetToTop));
 
   // Next, add the RTTI.
-  Components.push_back(VTableComponent::MakeRTTI(MostDerivedClass));
+  if (!Context.getLangOpts().OmitVTableRTTI)
+Components.push_back(VTableComponent::MakeRTTI(MostDerivedClass));
 
   uint64_t AddressPoint = Components.size();
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 531677e92f73252..40e60585a8b8d6e 100644

[clang] e16474b - Revert "Revert "[clang] Add experimental option to omit the RTTI component from the vtable when -fno-rtti is used""

2023-09-13 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2023-09-14T00:00:50Z
New Revision: e16474ba2cba8fa69b413a83852d06c93155f8c9

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

LOG: Revert "Revert "[clang] Add experimental option to omit the RTTI component 
from the vtable when -fno-rtti is used""

This attempts to reland 6385c1df919f237d4149fabf542a158f61010bf8 but
with a fix for the test failure.

Added: 
clang/test/CodeGenCXX/OmitRTTIComponentABI/simple-vtable-definition.cpp
clang/test/CodeGenCXX/OmitRTTIComponentABI/vbase-offset.cpp
clang/test/CodeGenCXX/OmitRTTIComponentABI/vtable-layout.cpp
clang/test/Driver/omit-rtti-component-flag.cpp
clang/test/Driver/omit-rtti-component-without-no-rtti.cpp

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/AST/VTableBuilder.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 86567267cfb437a..9349ff85ca8a1d3 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -674,6 +674,9 @@ def err_cc1_round_trip_mismatch : Error<
 def err_cc1_unbounded_vscale_min : Error<
   "minimum vscale must be an unsigned integer greater than 0">;
 
+def err_drv_using_omit_rtti_component_without_no_rtti : Error<
+  "-fexperimental-omit-vtable-rtti call only be used with -fno-rtti">;
+
 def err_drv_ssp_missing_offset_argument : Error<
   "'%0' is used without '-mstack-protector-guard-offset', and there is no 
default">;
 

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 102209ce899d70c..e18b5b80a34e718 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -450,6 +450,9 @@ LANGOPT(SpeculativeLoadHardening, 1, 0, "Speculative load 
hardening enabled")
 LANGOPT(RelativeCXXABIVTables, 1, 0,
 "Use an ABI-incompatible v-table layout that uses relative references")
 
+LANGOPT(OmitVTableRTTI, 1, 0,
+"Use an ABI-incompatible v-table layout that omits the RTTI component")
+
 LANGOPT(VScaleMin, 32, 0, "Minimum vscale value")
 LANGOPT(VScaleMax, 32, 0, "Maximum vscale value")
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2d42d05859bc1d3..553c7928c4f949e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2671,6 +2671,12 @@ def fno_experimental_relative_cxx_abi_vtables :
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Do not use the experimental C++ class ABI for classes with virtual 
tables">;
 
+defm experimental_omit_vtable_rtti : 
BoolFOption<"experimental-omit-vtable-rtti",
+  LangOpts<"OmitVTableRTTI">, DefaultFalse,
+  PosFlag,
+  NegFlag,
+  BothFlags<[], [CC1Option], " the RTTI component from virtual tables">>;
+
 def fcxx_abi_EQ : Joined<["-"], "fc++-abi=">,
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"C++ ABI to use. This will override the target C++ 
ABI.">;

diff  --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index a587f9bdc758529..cce0a507e8077d8 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -665,7 +665,11 @@ CharUnits 
VCallAndVBaseOffsetBuilder::getCurrentOffsetOffset() const {
   // vtable address point. (We subtract 3 to account for the information just
   // above the address point, the RTTI info, the offset to top, and the
   // vcall offset itself).
-  int64_t OffsetIndex = -(int64_t)(3 + Components.size());
+  size_t NumComponentsAboveAddrPoint = 3;
+  if (Context.getLangOpts().OmitVTableRTTI)
+NumComponentsAboveAddrPoint--;
+  int64_t OffsetIndex =
+  -(int64_t)(NumComponentsAboveAddrPoint + Components.size());
 
   // Under the relative ABI, the offset widths are 32-bit ints instead of
   // pointer widths.
@@ -1669,7 +1673,8 @@ void 
ItaniumVTableBuilder::LayoutPrimaryAndSecondaryVTables(
   Components.push_back(VTableComponent::MakeOffsetToTop(OffsetToTop));
 
   // Next, add the RTTI.
-  Components.push_back(VTableComponent::MakeRTTI(MostDerivedClass));
+  if (!Context.getLangOpts().OmitVTableRTTI)
+Components.push_back(VTableComponent::MakeRTTI(MostDerivedClass));
 
   uint64_t AddressPoint = Components.size();
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 531677e92f73252..40e60585a8b8d6e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ 

[clang] 87e11ec - Revert "[clang] Add experimental option to omit the RTTI component from the vtable when -fno-rtti is used"

2023-09-13 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2023-09-13T23:55:05Z
New Revision: 87e11ecbaec95d8411d1b332d6d88d458b408739

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

LOG: Revert "[clang] Add experimental option to omit the RTTI component from 
the vtable when -fno-rtti is used"

This reverts commit 6385c1df919f237d4149fabf542a158f61010bf8.

Reverting since this broke a windows builder:
https://lab.llvm.org/buildbot/#/builders/216/builds/27252.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/AST/VTableBuilder.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 
clang/test/CodeGenCXX/OmitRTTIComponentABI/simple-vtable-definition.cpp
clang/test/CodeGenCXX/OmitRTTIComponentABI/vbase-offset.cpp
clang/test/CodeGenCXX/OmitRTTIComponentABI/vtable-layout.cpp
clang/test/Driver/omit-rtti-component-flag.cpp
clang/test/Driver/omit-rtti-component-without-no-rtti.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 9349ff85ca8a1d3..86567267cfb437a 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -674,9 +674,6 @@ def err_cc1_round_trip_mismatch : Error<
 def err_cc1_unbounded_vscale_min : Error<
   "minimum vscale must be an unsigned integer greater than 0">;
 
-def err_drv_using_omit_rtti_component_without_no_rtti : Error<
-  "-fexperimental-omit-vtable-rtti call only be used with -fno-rtti">;
-
 def err_drv_ssp_missing_offset_argument : Error<
   "'%0' is used without '-mstack-protector-guard-offset', and there is no 
default">;
 

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index e18b5b80a34e718..102209ce899d70c 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -450,9 +450,6 @@ LANGOPT(SpeculativeLoadHardening, 1, 0, "Speculative load 
hardening enabled")
 LANGOPT(RelativeCXXABIVTables, 1, 0,
 "Use an ABI-incompatible v-table layout that uses relative references")
 
-LANGOPT(OmitVTableRTTI, 1, 0,
-"Use an ABI-incompatible v-table layout that omits the RTTI component")
-
 LANGOPT(VScaleMin, 32, 0, "Minimum vscale value")
 LANGOPT(VScaleMax, 32, 0, "Maximum vscale value")
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 553c7928c4f949e..2d42d05859bc1d3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2671,12 +2671,6 @@ def fno_experimental_relative_cxx_abi_vtables :
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Do not use the experimental C++ class ABI for classes with virtual 
tables">;
 
-defm experimental_omit_vtable_rtti : 
BoolFOption<"experimental-omit-vtable-rtti",
-  LangOpts<"OmitVTableRTTI">, DefaultFalse,
-  PosFlag,
-  NegFlag,
-  BothFlags<[], [CC1Option], " the RTTI component from virtual tables">>;
-
 def fcxx_abi_EQ : Joined<["-"], "fc++-abi=">,
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"C++ ABI to use. This will override the target C++ 
ABI.">;

diff  --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index cce0a507e8077d8..a587f9bdc758529 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -665,11 +665,7 @@ CharUnits 
VCallAndVBaseOffsetBuilder::getCurrentOffsetOffset() const {
   // vtable address point. (We subtract 3 to account for the information just
   // above the address point, the RTTI info, the offset to top, and the
   // vcall offset itself).
-  size_t NumComponentsAboveAddrPoint = 3;
-  if (Context.getLangOpts().OmitVTableRTTI)
-NumComponentsAboveAddrPoint--;
-  int64_t OffsetIndex =
-  -(int64_t)(NumComponentsAboveAddrPoint + Components.size());
+  int64_t OffsetIndex = -(int64_t)(3 + Components.size());
 
   // Under the relative ABI, the offset widths are 32-bit ints instead of
   // pointer widths.
@@ -1673,8 +1669,7 @@ void 
ItaniumVTableBuilder::LayoutPrimaryAndSecondaryVTables(
   Components.push_back(VTableComponent::MakeOffsetToTop(OffsetToTop));
 
   // Next, add the RTTI.
-  if (!Context.getLangOpts().OmitVTableRTTI)
-Components.push_back(VTableComponent::MakeRTTI(MostDerivedClass));
+  Components.push_back(VTableComponent::MakeRTTI(MostDerivedClass));
 
   uint64_t AddressPoint = Components.size();
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 40e60585a8b8d6e..531677e92f73252 100644
--- 

[clang] 6385c1d - [clang] Add experimental option to omit the RTTI component from the vtable when -fno-rtti is used

2023-09-13 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2023-09-13T23:15:50Z
New Revision: 6385c1df919f237d4149fabf542a158f61010bf8

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

LOG: [clang] Add experimental option to omit the RTTI component from the vtable 
when -fno-rtti is used

For programs that don't use RTTI, the rtti component is just replaced with a
zero. This way, vtables that don't use RTTI can still cooperate with vtables
that use RTTI since offset calculations on the ABI level would still work.
However, if throughout your whole program you don't use RTTI at all (such as
the embedded case), then this is just an unused pointer-sized component that's
wasting space. This adds an experimental option for removing the RTTI component
from the vtable.

Some notes:
- This is only allowed when RTTI is disabled, so we don't have to worry about
  things like `typeid` or `dynamic_cast`.
- This is a "use at your own risk" since, similar to relative vtables, 
everything
  must be compiled with this since it's an ABI breakage. That is, a program 
compiled
  with this is not guaranteed to work with a program compiled without this, even
  if RTTI is disabled for both programs.

Note that this is a completely different ABI flavor orthogonal to the
relative-vtables ABI. That is, they can be enabled/disabled independently.

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

Added: 
clang/test/CodeGenCXX/OmitRTTIComponentABI/simple-vtable-definition.cpp
clang/test/CodeGenCXX/OmitRTTIComponentABI/vbase-offset.cpp
clang/test/CodeGenCXX/OmitRTTIComponentABI/vtable-layout.cpp
clang/test/Driver/omit-rtti-component-flag.cpp
clang/test/Driver/omit-rtti-component-without-no-rtti.cpp

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/AST/VTableBuilder.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 86567267cfb437a..9349ff85ca8a1d3 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -674,6 +674,9 @@ def err_cc1_round_trip_mismatch : Error<
 def err_cc1_unbounded_vscale_min : Error<
   "minimum vscale must be an unsigned integer greater than 0">;
 
+def err_drv_using_omit_rtti_component_without_no_rtti : Error<
+  "-fexperimental-omit-vtable-rtti call only be used with -fno-rtti">;
+
 def err_drv_ssp_missing_offset_argument : Error<
   "'%0' is used without '-mstack-protector-guard-offset', and there is no 
default">;
 

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 102209ce899d70c..e18b5b80a34e718 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -450,6 +450,9 @@ LANGOPT(SpeculativeLoadHardening, 1, 0, "Speculative load 
hardening enabled")
 LANGOPT(RelativeCXXABIVTables, 1, 0,
 "Use an ABI-incompatible v-table layout that uses relative references")
 
+LANGOPT(OmitVTableRTTI, 1, 0,
+"Use an ABI-incompatible v-table layout that omits the RTTI component")
+
 LANGOPT(VScaleMin, 32, 0, "Minimum vscale value")
 LANGOPT(VScaleMax, 32, 0, "Maximum vscale value")
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2d42d05859bc1d3..553c7928c4f949e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2671,6 +2671,12 @@ def fno_experimental_relative_cxx_abi_vtables :
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Do not use the experimental C++ class ABI for classes with virtual 
tables">;
 
+defm experimental_omit_vtable_rtti : 
BoolFOption<"experimental-omit-vtable-rtti",
+  LangOpts<"OmitVTableRTTI">, DefaultFalse,
+  PosFlag,
+  NegFlag,
+  BothFlags<[], [CC1Option], " the RTTI component from virtual tables">>;
+
 def fcxx_abi_EQ : Joined<["-"], "fc++-abi=">,
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"C++ ABI to use. This will override the target C++ 
ABI.">;

diff  --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index a587f9bdc758529..cce0a507e8077d8 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -665,7 +665,11 @@ CharUnits 
VCallAndVBaseOffsetBuilder::getCurrentOffsetOffset() const {
   // vtable address point. (We subtract 3 to account for the information just
   // above the address point, the RTTI info, the offset to top, and the
   // vcall offset itself).
-  int64_t OffsetIndex = 

[clang] 9f00eb9 - Revert "Revert "[clang-format] Fix overlapping replacements before PPDirectives""

2023-06-07 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2023-06-08T00:15:30Z
New Revision: 9f00eb99759b62c4a81ce84d686b212e46ec7452

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

LOG: Revert "Revert "[clang-format] Fix overlapping replacements before 
PPDirectives""

This reverts commit 94e75469597f197f9c4b45baa6c8a576c78dbd02.

Apparently I broke some builders with the original revert: 
http://45.33.8.238/linux/109159/step_7.txt

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 33be74dfe1b9f..f229742b19d97 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1418,19 +1418,12 @@ unsigned UnwrappedLineFormatter::format(
   return Penalty;
 }
 
-void UnwrappedLineFormatter::formatFirstToken(
-const AnnotatedLine , const AnnotatedLine *PreviousLine,
-const AnnotatedLine *PrevPrevLine,
-const SmallVectorImpl , unsigned Indent,
-unsigned NewlineIndent) {
-  FormatToken  = *Line.First;
-  if (RootToken.is(tok::eof)) {
-unsigned Newlines = std::min(RootToken.NewlinesBefore, 1u);
-unsigned TokenIndent = Newlines ? NewlineIndent : 0;
-Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
-   TokenIndent);
-return;
-  }
+static auto newlinesBeforeLine(const AnnotatedLine ,
+   const AnnotatedLine *PreviousLine,
+   const AnnotatedLine *PrevPrevLine,
+   const SmallVectorImpl ,
+   const FormatStyle ) {
+  const auto  = *Line.First;
   unsigned Newlines =
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
@@ -1510,6 +1503,29 @@ void UnwrappedLineFormatter::formatFirstToken(
 }
   }
 
+  return Newlines;
+}
+
+void UnwrappedLineFormatter::formatFirstToken(
+const AnnotatedLine , const AnnotatedLine *PreviousLine,
+const AnnotatedLine *PrevPrevLine,
+const SmallVectorImpl , unsigned Indent,
+unsigned NewlineIndent) {
+  FormatToken  = *Line.First;
+  if (RootToken.is(tok::eof)) {
+unsigned Newlines =
+std::min(RootToken.NewlinesBefore,
+ Style.KeepEmptyLinesAtEOF ? Style.MaxEmptyLinesToKeep + 1 : 
1);
+unsigned TokenIndent = Newlines ? NewlineIndent : 0;
+Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
+   TokenIndent);
+return;
+  }
+
+  const auto Newlines =
+  RootToken.Finalized
+  ? RootToken.NewlinesBefore
+  : newlinesBeforeLine(Line, PreviousLine, PrevPrevLine, Lines, Style);
   if (Newlines)
 Indent = NewlineIndent;
 

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 9a0194be7044f..adc1eda41a91a 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -12856,6 +12856,22 @@ TEST_F(FormatTest, FormatsAfterAccessModifiers) {
"  void f() {}\n"
"};\n",
Style);
+  verifyFormat("struct foo {\n"
+   "#ifdef FOO\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "#endif\n"
+   "};",
+   "struct foo {\n"
+   "#ifdef FOO\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "\n"
+   "#endif\n"
+   "};",
+   Style);
 
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
   verifyFormat("struct foo {\n"



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


[clang] 94e7546 - Revert "[clang-format] Fix overlapping replacements before PPDirectives"

2023-06-07 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2023-06-07T23:44:32Z
New Revision: 94e75469597f197f9c4b45baa6c8a576c78dbd02

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

LOG: Revert "[clang-format] Fix overlapping replacements before PPDirectives"

This reverts commit 4b9764959dc4b8783e18747c1742ab164e4bc4ee.

Reverting since this causes clang-formtat to incorrectly fall into an
error path yet return a zero exit code despite not formatting the file
at all.

See https://github.com/llvm/llvm-project/issues/63170

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index f229742b19d97..33be74dfe1b9f 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1418,12 +1418,19 @@ unsigned UnwrappedLineFormatter::format(
   return Penalty;
 }
 
-static auto newlinesBeforeLine(const AnnotatedLine ,
-   const AnnotatedLine *PreviousLine,
-   const AnnotatedLine *PrevPrevLine,
-   const SmallVectorImpl ,
-   const FormatStyle ) {
-  const auto  = *Line.First;
+void UnwrappedLineFormatter::formatFirstToken(
+const AnnotatedLine , const AnnotatedLine *PreviousLine,
+const AnnotatedLine *PrevPrevLine,
+const SmallVectorImpl , unsigned Indent,
+unsigned NewlineIndent) {
+  FormatToken  = *Line.First;
+  if (RootToken.is(tok::eof)) {
+unsigned Newlines = std::min(RootToken.NewlinesBefore, 1u);
+unsigned TokenIndent = Newlines ? NewlineIndent : 0;
+Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
+   TokenIndent);
+return;
+  }
   unsigned Newlines =
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
@@ -1503,29 +1510,6 @@ static auto newlinesBeforeLine(const AnnotatedLine ,
 }
   }
 
-  return Newlines;
-}
-
-void UnwrappedLineFormatter::formatFirstToken(
-const AnnotatedLine , const AnnotatedLine *PreviousLine,
-const AnnotatedLine *PrevPrevLine,
-const SmallVectorImpl , unsigned Indent,
-unsigned NewlineIndent) {
-  FormatToken  = *Line.First;
-  if (RootToken.is(tok::eof)) {
-unsigned Newlines =
-std::min(RootToken.NewlinesBefore,
- Style.KeepEmptyLinesAtEOF ? Style.MaxEmptyLinesToKeep + 1 : 
1);
-unsigned TokenIndent = Newlines ? NewlineIndent : 0;
-Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
-   TokenIndent);
-return;
-  }
-
-  const auto Newlines =
-  RootToken.Finalized
-  ? RootToken.NewlinesBefore
-  : newlinesBeforeLine(Line, PreviousLine, PrevPrevLine, Lines, Style);
   if (Newlines)
 Indent = NewlineIndent;
 

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index adc1eda41a91a..9a0194be7044f 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -12856,22 +12856,6 @@ TEST_F(FormatTest, FormatsAfterAccessModifiers) {
"  void f() {}\n"
"};\n",
Style);
-  verifyFormat("struct foo {\n"
-   "#ifdef FOO\n"
-   "#else\n"
-   "private:\n"
-   "\n"
-   "#endif\n"
-   "};",
-   "struct foo {\n"
-   "#ifdef FOO\n"
-   "#else\n"
-   "private:\n"
-   "\n"
-   "\n"
-   "#endif\n"
-   "};",
-   Style);
 
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
   verifyFormat("struct foo {\n"



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


[clang] 5056394 - [clang-format-diff] Correctly parse start-of-file diffs

2023-02-27 Thread Leonard Chan via cfe-commits

Author: Tamir Duberstein
Date: 2023-02-27T20:02:51Z
New Revision: 50563944ab962b58a1e00763ce16d8c712965c6d

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

LOG: [clang-format-diff] Correctly parse start-of-file diffs

Handle the case where the diff is a pure removal of lines. Before this
change start_line would end up as 0 which is rejected by clang-format.

Submitting on behalf of @tamird.

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

Added: 


Modified: 
clang/tools/clang-format/clang-format-diff.py

Removed: 




diff  --git a/clang/tools/clang-format/clang-format-
diff .py b/clang/tools/clang-format/clang-format-
diff .py
index 1f6ff0fe295f..1dcc8689d5fe 100755
--- a/clang/tools/clang-format/clang-format-
diff .py
+++ b/clang/tools/clang-format/clang-format-
diff .py
@@ -84,12 +84,19 @@ def main():
   if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE):
 continue
 
-match = re.search(r'^@@.*\+(\d+)(,(\d+))?', line)
+match = re.search(r'^@@.*\+(\d+)(?:,(\d+))?', line)
 if match:
   start_line = int(match.group(1))
   line_count = 1
-  if match.group(3):
-line_count = int(match.group(3))
+  if match.group(2):
+line_count = int(match.group(2))
+# The input is something like
+#
+# @@ -1, +0,0 @@
+#
+# which means no lines were added.
+if line_count == 0:
+  continue
   # Also format lines range if line_count is 0 in case of deleting
   # surrounding statements.
   end_line = start_line



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


[clang] 003b603 - [clang] Ensure correct metadata for relative vtables

2022-12-07 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2022-12-08T00:42:48Z
New Revision: 003b6033e1b254dd96ddb341f375b73ee5bed2af

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

LOG: [clang] Ensure correct metadata for relative vtables

Prior to this, metadata pertaining to the size or address point offsets
into a relative vtable were twice the value they should be (treating
component widths as pointer width rather than 4 bytes). This prevented
some vtables from being devirtualized with D134320. This ensures the
correct metadata is written so whole program devirtualization can catch
these remaining devirt targets.

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

Added: 


Modified: 
clang/lib/CodeGen/CGVTables.cpp
clang/lib/CodeGen/CGVTables.h
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGenCXX/type-metadata.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index a9eb1a075f62b..85acebeeaec9b 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -678,15 +678,23 @@ void 
CodeGenVTables::addRelativeComponent(ConstantArrayBuilder ,
   /*position=*/vtableAddressPoint);
 }
 
-bool CodeGenVTables::useRelativeLayout() const {
+static bool UseRelativeLayout(const CodeGenModule ) {
   return CGM.getTarget().getCXXABI().isItaniumFamily() &&
  CGM.getItaniumVTableContext().isRelativeLayout();
 }
 
+bool CodeGenVTables::useRelativeLayout() const {
+  return UseRelativeLayout(CGM);
+}
+
+llvm::Type *CodeGenModule::getVTableComponentType() const {
+  if (UseRelativeLayout(*this))
+return Int32Ty;
+  return Int8PtrTy;
+}
+
 llvm::Type *CodeGenVTables::getVTableComponentType() const {
-  if (useRelativeLayout())
-return CGM.Int32Ty;
-  return CGM.Int8PtrTy;
+  return CGM.getVTableComponentType();
 }
 
 static void AddPointerLayoutOffset(const CodeGenModule ,
@@ -1281,8 +1289,7 @@ void CodeGenModule::EmitVTableTypeMetadata(const 
CXXRecordDecl *RD,
   if (!getCodeGenOpts().LTOUnit)
 return;
 
-  CharUnits PointerWidth = Context.toCharUnitsFromBits(
-  Context.getTargetInfo().getPointerWidth(LangAS::Default));
+  CharUnits ComponentWidth = GetTargetTypeStoreSize(getVTableComponentType());
 
   typedef std::pair AddressPoint;
   std::vector AddressPoints;
@@ -1320,7 +1327,7 @@ void CodeGenModule::EmitVTableTypeMetadata(const 
CXXRecordDecl *RD,
   ArrayRef Comps = VTLayout.vtable_components();
   for (auto AP : AddressPoints) {
 // Create type metadata for the address point.
-AddVTableTypeMetadata(VTable, PointerWidth * AP.second, AP.first);
+AddVTableTypeMetadata(VTable, ComponentWidth * AP.second, AP.first);
 
 // The class associated with each address point could also potentially be
 // used for indirect calls via a member function pointer, so we need to
@@ -1333,7 +1340,7 @@ void CodeGenModule::EmitVTableTypeMetadata(const 
CXXRecordDecl *RD,
   Context.getMemberPointerType(
   Comps[I].getFunctionDecl()->getType(),
   Context.getRecordType(AP.first).getTypePtr()));
-  VTable->addTypeMetadata((PointerWidth * I).getQuantity(), MD);
+  VTable->addTypeMetadata((ComponentWidth * I).getQuantity(), MD);
 }
   }
 

diff  --git a/clang/lib/CodeGen/CGVTables.h b/clang/lib/CodeGen/CGVTables.h
index eb6b00b7847bc..e7b59d94f2576 100644
--- a/clang/lib/CodeGen/CGVTables.h
+++ b/clang/lib/CodeGen/CGVTables.h
@@ -102,6 +102,10 @@ class CodeGenVTables {
 return *cast(VTContext);
   }
 
+  const ItaniumVTableContext () const {
+return *cast(VTContext);
+  }
+
   MicrosoftVTableContext () {
 return *cast(VTContext);
   }

diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 5289f0cc13559..4595dd55401d7 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -760,6 +760,10 @@ class CodeGenModule : public CodeGenTypeCache {
 return VTables.getItaniumVTableContext();
   }
 
+  const ItaniumVTableContext () const {
+return VTables.getItaniumVTableContext();
+  }
+
   MicrosoftVTableContext () {
 return VTables.getMicrosoftVTableContext();
   }
@@ -1444,6 +1448,8 @@ class CodeGenModule : public CodeGenTypeCache {
   llvm::GlobalVariable *VTable,
   const VTableLayout );
 
+  llvm::Type *getVTableComponentType() const;
+
   /// Generate a cross-DSO type identifier for MD.
   llvm::ConstantInt *CreateCrossDsoCfiTypeId(llvm::Metadata *MD);
 

diff  --git a/clang/test/CodeGenCXX/type-metadata.cpp 
b/clang/test/CodeGenCXX/type-metadata.cpp
index 0a90968062d92..3f8b54af801f8 100644
--- a/clang/test/CodeGenCXX/type-metadata.cpp
+++ 

[libunwind] 96d6399 - Revert "[CMake] Use LLVM_TARGET_TRIPLE in runtimes"

2022-12-05 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2022-12-05T22:20:51Z
New Revision: 96d63993dd3698bbf2d6a83c035cd05faed7317b

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

LOG: Revert "[CMake] Use LLVM_TARGET_TRIPLE in runtimes"

This reverts commit bec8a372fc0db95852748691c0f4933044026b25.

This causes many of these errors to appear when rebuilding runtimes part
of fuchsia's toolchain:

ld.lld: error:
/usr/local/google/home/paulkirth/llvm-upstream/build/lib/x86_64-unknown-linux-gnu/libunwind.a(libunwind.cpp.o)
is incompatible with elf64-x86-64

This can be reproduced by making a complete toolchain, saving any source
file with no changes, then rerunning ninja distribution.

Added: 


Modified: 
compiler-rt/cmake/config-ix.cmake
libc/lib/CMakeLists.txt
libcxx/CMakeLists.txt
libcxx/docs/BuildingLibcxx.rst
libcxx/lib/abi/CMakeLists.txt
libcxx/test/CMakeLists.txt
libcxxabi/CMakeLists.txt
libcxxabi/test/CMakeLists.txt
libunwind/CMakeLists.txt
libunwind/test/CMakeLists.txt
llvm/cmake/modules/LLVMExternalProjectUtils.cmake
llvm/runtimes/CMakeLists.txt
runtimes/CMakeLists.txt

Removed: 




diff  --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index 9eb48b8f2ba5..fd7daa50bdd9 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -689,8 +689,8 @@ else()
   set(CAN_SYMBOLIZE 1)
 endif()
 
-find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_TARGET_TRIPLE}-ld.bfd ld.bfd DOC 
"GNU ld")
-find_program(GOLD_EXECUTABLE NAMES ${LLVM_TARGET_TRIPLE}-ld.gold ld.gold DOC 
"GNU gold")
+find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd 
ld.bfd DOC "GNU ld")
+find_program(GOLD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.gold 
ld.gold DOC "GNU gold")
 
 if(COMPILER_RT_SUPPORTED_ARCH)
   list(REMOVE_DUPLICATES COMPILER_RT_SUPPORTED_ARCH)

diff  --git a/libc/lib/CMakeLists.txt b/libc/lib/CMakeLists.txt
index 1080fdf00931..b7eb0a133a17 100644
--- a/libc/lib/CMakeLists.txt
+++ b/libc/lib/CMakeLists.txt
@@ -10,7 +10,7 @@ set_target_properties(
 )
 
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
-  set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_TARGET_TRIPLE})
+  set(LIBC_INSTALL_LIBRARY_DIR 
lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
 else()
   set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX})
 endif()

diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 437c4b2f87a0..454caedcdf3f 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -413,12 +413,12 @@ set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output 
name for the shared lib
 set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static 
libc++ runtime library.")
 
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-  set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_TARGET_TRIPLE})
+  set(LIBCXX_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
   set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LLVM_BINARY_DIR}/include/${LLVM_TARGET_TRIPLE}/c++/v1")
-  set(LIBCXX_INSTALL_LIBRARY_DIR 
lib${LLVM_LIBDIR_SUFFIX}/${LLVM_TARGET_TRIPLE} CACHE PATH
+  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
+  set(LIBCXX_INSTALL_LIBRARY_DIR 
lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
   "Path where built libc++ libraries should be installed.")
-  set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR 
"${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_TARGET_TRIPLE}/c++/v1" CACHE PATH
+  set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR 
"${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH
   "Path where target-specific libc++ headers should be installed.")
   if(LIBCXX_LIBDIR_SUBDIR)
 string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})

diff  --git a/libcxx/docs/BuildingLibcxx.rst b/libcxx/docs/BuildingLibcxx.rst
index 5d51088f71ad..59c695efe44e 100644
--- a/libcxx/docs/BuildingLibcxx.rst
+++ b/libcxx/docs/BuildingLibcxx.rst
@@ -281,7 +281,7 @@ libc++ specific options
 .. option:: LIBCXX_INSTALL_INCLUDE_TARGET_DIR:PATH
 
   **Default**: ``include/c++/v1`` or
-  ``include/${LLVM_TARGET_TRIPLE}/c++/v1``
+  ``include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1``
 
   Path where target-specific libc++ headers should be installed. If a relative
   path, relative to ``CMAKE_INSTALL_PREFIX``.

diff  --git a/libcxx/lib/abi/CMakeLists.txt b/libcxx/lib/abi/CMakeLists.txt
index a40794c54c3e..7c08bd06c50b 100644
--- a/libcxx/lib/abi/CMakeLists.txt
+++ b/libcxx/lib/abi/CMakeLists.txt
@@ -43,7 +43,7 @@ endfunction()
 if (CMAKE_CXX_COMPILER_TARGET)
   set(triple "${CMAKE_CXX_COMPILER_TARGET}")
 else()
-  set(triple 

[clang] cdb30f7 - [clang] Do not instrument the rtti_proxies under hwasan

2022-08-26 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2022-08-26T18:22:17Z
New Revision: cdb30f7a26354b000310ebe30a6874f7737675ed

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

LOG: [clang] Do not instrument the rtti_proxies under hwasan

We run into a duplicate symbol error when instrumenting the rtti_proxies
generated as part of the relative vtables ABI with hwasan:

```
ld.lld: error: duplicate symbol: typeinfo for icu_71::UObject
(.rtti_proxy)
>>> defined at brkiter.cpp
>>>
arm64-hwasan-shared/obj/third_party/icu/source/common/libicuuc.brkiter.cpp.o:(typeinfo
for icu_71::UObject (.rtti_proxy))
>>> defined at locavailable.cpp
>>>
arm64-hwasan-shared/obj/third_party/icu/source/common/libicuuc.locavailable.cpp.o:(.data.rel.ro..L_ZTIN6icu_717UObjectE.rtti_proxy.hwasan+0xE00)
```

The issue here is that the hwasan alias carries over the visibility and
linkage of the original proxy, so we have duplicate external symbols
that participate in linking. Similar to D132425 we can just disable
hwasan for the proxies for now.

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

Added: 


Modified: 
clang/lib/CodeGen/CGVTables.cpp
clang/lib/CodeGen/CGVTables.h
clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index c8b29aec917c..3f8835d80a9a 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -664,6 +664,12 @@ void 
CodeGenVTables::addRelativeComponent(ConstantArrayBuilder ,
 proxy->setVisibility(llvm::GlobalValue::HiddenVisibility);
 proxy->setComdat(module.getOrInsertComdat(rttiProxyName));
   }
+  // Do not instrument the rtti proxies with hwasan to avoid a duplicate
+  // symbol error. Aliases generated by hwasan will retain the same namebut
+  // the addresses they are set to may have 
diff erent tags from 
diff erent
+  // compilation units. We don't run into this without hwasan because the
+  // proxies are in comdat groups, but those aren't propagated to the 
alias.
+  RemoveHwasanMetadata(proxy);
 }
 target = proxy;
   }
@@ -938,13 +944,13 @@ llvm::GlobalVariable 
*CodeGenVTables::GenerateConstructionVTable(
 // relocations. A future alternative for this would be finding which usages of
 // the vtable can continue to use the untagged hwasan value without any loss of
 // value in hwasan.
-void CodeGenVTables::RemoveHwasanMetadata(llvm::GlobalValue *VTable) {
+void CodeGenVTables::RemoveHwasanMetadata(llvm::GlobalValue *GV) const {
   if (CGM.getLangOpts().Sanitize.has(SanitizerKind::HWAddress)) {
 llvm::GlobalValue::SanitizerMetadata Meta;
-if (VTable->hasSanitizerMetadata())
-  Meta = VTable->getSanitizerMetadata();
+if (GV->hasSanitizerMetadata())
+  Meta = GV->getSanitizerMetadata();
 Meta.NoHWAddress = true;
-VTable->setSanitizerMetadata(Meta);
+GV->setSanitizerMetadata(Meta);
   }
 }
 

diff  --git a/clang/lib/CodeGen/CGVTables.h b/clang/lib/CodeGen/CGVTables.h
index c044ecc9bc8c..eb6b00b7847b 100644
--- a/clang/lib/CodeGen/CGVTables.h
+++ b/clang/lib/CodeGen/CGVTables.h
@@ -155,8 +155,8 @@ class CodeGenVTables {
   void GenerateRelativeVTableAlias(llvm::GlobalVariable *VTable,
llvm::StringRef AliasNameRef);
 
-  /// Specify a vtable should not be instrumented with hwasan.
-  void RemoveHwasanMetadata(llvm::GlobalValue *VTable);
+  /// Specify a global should not be instrumented with hwasan.
+  void RemoveHwasanMetadata(llvm::GlobalValue *GV) const;
 };
 
 } // end namespace CodeGen

diff  --git 
a/clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp 
b/clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp
index b414b8d8ea8a..d0777b0f1245 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp
@@ -6,6 +6,7 @@
 /// hwasan-instrumented.
 // CHECK-DAG: @_ZTV1A.local = private unnamed_addr constant { [3 x i32] } { [3 
x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1A.rtti_proxy to 
i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr 
@_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 
ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 ptrtoint (ptr 
getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) 
to i64)) to i32)] }, no_sanitize_hwaddress, align 4
 // CHECK-DAG: @_ZTV1A = unnamed_addr alias { [3 x i32] }, ptr @_ZTV1A.local
+// CHECK-DAG: @_ZTI1A.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1A, 
no_sanitize_hwaddress, comdat
 
 class A {
 public:
@@ -21,6 +22,7 @@ void A_foo(A *a) {
 /// 

[clang] 93e5cf6 - [clang] Do not instrument relative vtables under hwasan

2022-08-26 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2022-08-26T18:21:40Z
New Revision: 93e5cf6b9c08d99cf7cefc0adda346bd7ba56049

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

LOG: [clang] Do not instrument relative vtables under hwasan

Full context in
https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=107017.

Instrumenting hwasan with globals results in a linker error under the
relative vtables abi:

```
ld.lld: error:
libunwind.cpp:(.rodata..L_ZTVN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_15Registers_arm64EEE.hwasan+0x8):
relocation R_AARCH64_PLT32 out of range: 6845471433603167792 is not in
[-2147483648, 2147483647]; references
libunwind::AbstractUnwindCursor::~AbstractUnwindCursor()
>>> defined in
libunwind/src/CMakeFiles/unwind_shared.dir/libunwind.cpp.obj
```

This is because the tag is included in the vtable address when
calculating the offset between the vtable and virtual function. A
temporary solution until we can resolve this is to just disable hwasan
instrumentation on relative vtables specifically, which can be done in
the frontend.

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

Added: 
clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp

Modified: 
clang/lib/CodeGen/CGVTables.cpp
clang/lib/CodeGen/CGVTables.h
clang/lib/CodeGen/ItaniumCXXABI.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index cdd40d2a6a2e..c8b29aec917c 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -921,12 +921,33 @@ llvm::GlobalVariable 
*CodeGenVTables::GenerateConstructionVTable(
 
   CGM.EmitVTableTypeMetadata(RD, VTable, *VTLayout.get());
 
-  if (UsingRelativeLayout && !VTable->isDSOLocal())
-GenerateRelativeVTableAlias(VTable, OutName);
+  if (UsingRelativeLayout) {
+RemoveHwasanMetadata(VTable);
+if (!VTable->isDSOLocal())
+  GenerateRelativeVTableAlias(VTable, OutName);
+  }
 
   return VTable;
 }
 
+// Ensure this vtable is not instrumented by hwasan. That is, a global alias is
+// not generated for it. This is mainly used by the relative-vtables ABI where
+// vtables instead contain 32-bit offsets between the vtable and function
+// pointers. Hwasan is disabled for these vtables for now because the tag in a
+// vtable pointer may fail the overflow check when resolving 32-bit PLT
+// relocations. A future alternative for this would be finding which usages of
+// the vtable can continue to use the untagged hwasan value without any loss of
+// value in hwasan.
+void CodeGenVTables::RemoveHwasanMetadata(llvm::GlobalValue *VTable) {
+  if (CGM.getLangOpts().Sanitize.has(SanitizerKind::HWAddress)) {
+llvm::GlobalValue::SanitizerMetadata Meta;
+if (VTable->hasSanitizerMetadata())
+  Meta = VTable->getSanitizerMetadata();
+Meta.NoHWAddress = true;
+VTable->setSanitizerMetadata(Meta);
+  }
+}
+
 // If the VTable is not dso_local, then we will not be able to indicate that
 // the VTable does not need a relocation and move into rodata. A frequent
 // time this can occur is for classes that should be made public from a DSO

diff  --git a/clang/lib/CodeGen/CGVTables.h b/clang/lib/CodeGen/CGVTables.h
index bdfc075ee305..c044ecc9bc8c 100644
--- a/clang/lib/CodeGen/CGVTables.h
+++ b/clang/lib/CodeGen/CGVTables.h
@@ -154,6 +154,9 @@ class CodeGenVTables {
   /// when a vtable may not be dso_local.
   void GenerateRelativeVTableAlias(llvm::GlobalVariable *VTable,
llvm::StringRef AliasNameRef);
+
+  /// Specify a vtable should not be instrumented with hwasan.
+  void RemoveHwasanMetadata(llvm::GlobalValue *VTable);
 };
 
 } // end namespace CodeGen

diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 2809cbe99c10..cb97af7ab11a 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1769,8 +1769,11 @@ void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables 
,
 }
   }
 
-  if (VTContext.isRelativeLayout() && !VTable->isDSOLocal())
-CGVT.GenerateRelativeVTableAlias(VTable, VTable->getName());
+  if (VTContext.isRelativeLayout()) {
+CGVT.RemoveHwasanMetadata(VTable);
+if (!VTable->isDSOLocal())
+  CGVT.GenerateRelativeVTableAlias(VTable, VTable->getName());
+  }
 }
 
 bool ItaniumCXXABI::isVirtualOffsetNeededForVTableField(

diff  --git 
a/clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp 
b/clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp
new file mode 100644
index ..b414b8d8ea8a
--- /dev/null
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -S -o - -emit-llvm 

[clang] 33171df - Revert "[clang][Darwin] Always set the default C++ Standard Library to libc++"

2022-08-04 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2022-08-04T22:56:32Z
New Revision: 33171df9cc7f6560dea7b0b162ab51ff97417468

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

LOG: Revert "[clang][Darwin] Always set the default C++ Standard Library to 
libc++"

This reverts commit c5ccb78ade8136134e0ca9dde64de97f913f0f8c.

We're seeing darwin-stdlib.cpp fail on our linux, mac, and windows
builders:
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8806821020552676065/overview

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-iphone-defaults.m
clang/test/Driver/darwin-stdlib.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 7e3fc625d8c85..bada811daadfe 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -896,7 +896,12 @@ types::ID MachO::LookupTypeForExtension(StringRef Ext) 
const {
 bool MachO::HasNativeLLVMSupport() const { return true; }
 
 ToolChain::CXXStdlibType Darwin::GetDefaultCXXStdlibType() const {
-  // Always use libc++ by default
+  // Use libstdc++ on old targets (OSX < 10.9 and iOS < 7)
+  if ((isTargetMacOSBased() && isMacosxVersionLT(10, 9)) ||
+  (isTargetIOSBased() && isIPhoneOSVersionLT(7, 0)))
+return ToolChain::CST_Libstdcxx;
+
+  // On all other targets, use libc++
   return ToolChain::CST_Libcxx;
 }
 

diff  --git a/clang/test/Driver/darwin-iphone-defaults.m 
b/clang/test/Driver/darwin-iphone-defaults.m
index 79d3bc848faf5..ec9507fd091a3 100644
--- a/clang/test/Driver/darwin-iphone-defaults.m
+++ b/clang/test/Driver/darwin-iphone-defaults.m
@@ -1,4 +1,4 @@
-// RUN: %clang -target i386-apple-darwin -miphoneos-version-min=5.0 -arch 
armv7 -stdlib=platform -flto -S -o - %s | FileCheck %s
+// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -arch 
armv7 -stdlib=platform -flto -S -o - %s | FileCheck %s
 
 // CHECK: @f0() [[F0:#[0-9]+]]
 // CHECK: @__f0_block_invoke

diff  --git a/clang/test/Driver/darwin-stdlib.cpp 
b/clang/test/Driver/darwin-stdlib.cpp
index d15eb1932e3ca..0538a42ecd5cc 100644
--- a/clang/test/Driver/darwin-stdlib.cpp
+++ b/clang/test/Driver/darwin-stdlib.cpp
@@ -2,10 +2,13 @@
 // than the platform default. (see https://llvm.org/bugs/show_bug.cgi?id=30548)
 // XFAIL: default-cxx-stdlib-set
 
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir 
%S/Inputs/darwin_toolchain_tree/bin/ -arch arm64 -miphoneos-version-min=7.0 %s 
-### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir 
%S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.9 %s -### 2>&1 | 
FileCheck %s
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir 
%S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 %s 
-### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir 
%S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k %s -### 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir 
%S/Inputs/darwin_toolchain_tree/bin/ -arch arm64 -miphoneos-version-min=7.0 %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir 
%S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.8 
-Wno-stdlibcxx-not-found %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-LIBSTDCXX
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir 
%S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.9 %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-LIBCXX
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir 
%S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=6.1 
-Wno-stdlibcxx-not-found %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-LIBSTDCXX
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir 
%S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir 
%S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-LIBCXX
 
-// CHECK: "-stdlib=libc++"
-// CHECK-NOT: "-stdlib=libstdc++"
+// CHECK-LIBCXX: "-stdlib=libc++"
+// CHECK-LIBSTDCXX-NOT: -stdlib=libc++
+// CHECK-LIBSTDCXX-NOT: -stdlib=libstdc++



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


[clang-tools-extra] 474c873 - Revert "[llvm] cmake config groundwork to have ZSTD in LLVM"

2022-07-08 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2022-07-08T13:48:05-07:00
New Revision: 474c873148b1441f1dd7a2b269441a1b20e30aa2

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

LOG: Revert "[llvm] cmake config groundwork to have ZSTD in LLVM"

This reverts commit f07caf20b9d35e45501c9d5d903fa182b3bdb95a which seems to 
break upstream https://lab.llvm.org/buildbot/#/builders/109/builds/42253.

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/test/lit.cfg.py
clang-tools-extra/clangd/test/lit.site.cfg.py.in
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in
compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
compiler-rt/test/lit.common.cfg.py
compiler-rt/test/lit.common.configured.in
flang/CMakeLists.txt
lld/ELF/CMakeLists.txt
lld/test/lit.site.cfg.py.in
lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
lldb/test/Shell/lit.site.cfg.py.in
llvm/CMakeLists.txt
llvm/cmake/config-ix.cmake
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/include/llvm/Config/llvm-config.h.cmake
llvm/test/lit.site.cfg.py.in
utils/bazel/llvm_configs/llvm-config.h.cmake

Removed: 
llvm/cmake/modules/FindZSTD.cmake



diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index bda9d8c1585eb..7cfbd6f95750e 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -29,7 +29,6 @@ llvm_canonicalize_cmake_booleans(
   CLANGD_MALLOC_TRIM
   CLANGD_TIDY_CHECKS
   LLVM_ENABLE_ZLIB
-  LLVM_ENABLE_ZSTD
 )
 
 configure_file(

diff  --git a/clang-tools-extra/clangd/test/lit.cfg.py 
b/clang-tools-extra/clangd/test/lit.cfg.py
index 8a31cd54de8ee..0f3d8b310b290 100644
--- a/clang-tools-extra/clangd/test/lit.cfg.py
+++ b/clang-tools-extra/clangd/test/lit.cfg.py
@@ -36,6 +36,3 @@ def calculate_arch_features(arch_string):
 
 if config.have_zlib:
   config.available_features.add('zlib')
-
-if config.have_zstd:
-  config.available_features.add('zstd')

diff  --git a/clang-tools-extra/clangd/test/lit.site.cfg.py.in 
b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
index 83bfe322a9adc..20caa72af3da1 100644
--- a/clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -17,7 +17,6 @@ config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
 config.clangd_tidy_checks = @CLANGD_TIDY_CHECKS@
 config.have_zlib = @LLVM_ENABLE_ZLIB@
-config.have_zstd = @LLVM_ENABLE_ZSTD@
 
 # Delegate logic to lit.cfg.py.
 lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")

diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 5af7c30835996..5b604b2a3eeba 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -11,7 +11,6 @@ llvm_canonicalize_cmake_booleans(
   CLANG_SPAWN_CC1
   ENABLE_BACKTRACES
   LLVM_ENABLE_ZLIB
-  LLVM_ENABLE_ZSTD
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
   LLVM_ENABLE_THREADS
   LLVM_WITH_Z3

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index eb1013059e0ea..8a9849fe4549d 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -21,7 +21,6 @@ config.host_cc = "@CMAKE_C_COMPILER@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
-config.have_zstd = @LLVM_ENABLE_ZSTD@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
 config.clang_enable_opaque_pointers = @CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL@

diff  --git 
a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh 
b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
index f4f242feae013..b6f731566c19b 100755
--- a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
+++ b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
@@ -140,7 +140,6 @@ if [[ ! -d ${LLVM_BUILD} ]]; then
 -DLLVM_TABLEGEN=$TBLGEN \
 -DLLVM_DEFAULT_TARGET_TRIPLE="${TARGET_TRIPLE}" \
 -DLLVM_ENABLE_ZLIB=ON \
--DLLVM_ENABLE_ZSTD=ON \
 -DLLVM_ENABLE_TERMINFO=OFF \
 -DLLVM_ENABLE_THREADS=OFF \
   $LLVM_SRC

diff  --git a/compiler-rt/test/lit.common.cfg.py 
b/compiler-rt/test/lit.common.cfg.py
index a38c1308ecf43..62a73dd313968 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -217,9 +217,6 @@ def get_path_from_clang(args, allow_failure):
 
 if config.have_zlib == "1":
   config.available_features.add("zlib")
-  
-if config.have_zstd == "1":
-  config.available_features.add("zstd")
 
 # Use ugly construction to explicitly prohibit 

[clang] 4ac58b6 - [clang][Fuchsia] Ensure static sanitizer libs are only linked in after the -nostdlib check

2022-02-08 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2022-02-08T10:53:22-08:00
New Revision: 4ac58b61022d128d60ffea06c20611b8eaf8601a

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

LOG: [clang][Fuchsia] Ensure static sanitizer libs are only linked in after the 
-nostdlib check

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Fuchsia.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 8addee22a2bd..40364d23c559 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -771,11 +771,6 @@ static const char *getAsNeededOption(const ToolChain , 
bool as_needed) {
 
 void tools::linkSanitizerRuntimeDeps(const ToolChain ,
  ArgStringList ) {
-  // Fuchsia never needs these.  Any sanitizer runtimes with system
-  // dependencies use the `.deplibs` feature instead.
-  if (TC.getTriple().isOSFuchsia())
-return;
-
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
   CmdArgs.push_back(getAsNeededOption(TC, false));

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index bd1600d060c8..9e0b259dfcae 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -127,10 +127,7 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
   D.getLTOMode() == LTOK_Thin);
   }
 
-  bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
-  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_r)) {
@@ -153,11 +150,14 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
   }
 }
 
-if (NeedsSanitizerDeps)
-  linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
+// Note that Fuchsia never needs to link in sanitizer runtime deps.  Any
+// sanitizer runtimes with system dependencies use the `.deplibs` feature
+// instead.
+addSanitizerRuntimes(ToolChain, Args, CmdArgs);
 
-if (NeedsXRayDeps)
-  linkXRayRuntimeDeps(ToolChain, CmdArgs);
+addXRayRuntime(ToolChain, Args, CmdArgs);
+
+ToolChain.addProfileRTLibs(Args, CmdArgs);
 
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 



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


[libunwind] f178a05 - [libunwind] Fix unwind_leaffunction test

2021-12-03 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-12-03T11:21:20-08:00
New Revision: f178a05f220403f2a9d73c7640bfcc7dc2d7be72

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

LOG: [libunwind] Fix unwind_leaffunction test

It's possible for this test not to pass if the libc used does not provide
unwind info for raise. We can replace it with __builtin_cast, which can lead
to a SIGTRAP on x86_64 and a SIGILL on aarch64.

Using this alternative, a nop is needed before the __builtin_cast. This is
because libunwind incorrectly decrements pc, which can cause pc to jump into
the previous function and use the incorrect FDE.

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

Added: 


Modified: 
libunwind/test/unwind_leaffunction.pass.cpp

Removed: 




diff  --git a/libunwind/test/unwind_leaffunction.pass.cpp 
b/libunwind/test/unwind_leaffunction.pass.cpp
index 2a6d8311e24c7..8ff21dd35449c 100644
--- a/libunwind/test/unwind_leaffunction.pass.cpp
+++ b/libunwind/test/unwind_leaffunction.pass.cpp
@@ -39,11 +39,17 @@ void signal_handler(int signum) {
 }
 
 __attribute__((noinline)) void crashing_leaf_func(void) {
-  raise(SIGSEGV);
+  // libunwind searches for the address before the return address which points
+  // to the trap instruction. NOP guarantees the trap instruction is not the
+  // first instruction of the function.
+  // We should keep this here for other unwinders that also decrement pc.
+  __asm__ __volatile__("nop");
+  __builtin_trap();
 }
 
 int main(int, char**) {
-  signal(SIGSEGV, signal_handler);
+  signal(SIGTRAP, signal_handler);
+  signal(SIGILL, signal_handler);
   crashing_leaf_func();
   return -2;
 }



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


[clang] 456a7e5 - [clang][asan] Add test for ensuring PR52382 is fixed

2021-11-05 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-11-05T14:10:34-07:00
New Revision: 456a7e52310d632be4e41a4b7c4853e910648621

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

LOG: [clang][asan] Add test for ensuring PR52382 is fixed

The fix for PR52382 was already introduced in D112732 which ensures that module
instrumentation always runs after function instrumentation. This adds a test
that ensures the PR is addressed and prevent regression.

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

Added: 
clang/test/CodeGen/pr52382.c

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/pr52382.c b/clang/test/CodeGen/pr52382.c
new file mode 100644
index 0..6150c936f6bbd
--- /dev/null
+++ b/clang/test/CodeGen/pr52382.c
@@ -0,0 +1,19 @@
+// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -o - 
-fsanitize=address %s | FileCheck %s
+
+// Ensure that ASan properly instruments a load into a global where the index
+// happens to be within the padding after the global which is used for the
+// redzone.
+
+// This global is 400 bytes long, but gets padded with 112 bytes for redzones,
+// rounding the total size after instrumentation to 512.
+int global_array[100] = {-1};
+
+// This access is 412 bytes after the start of the global: past the end of the
+// uninstrumented array, but within the bounds of the extended instrumented
+// array. We should ensure this is still instrumented.
+int main(void) { return global_array[103]; }
+
+// CHECK: @main
+// CHECK-NEXT: entry:
+// CHECK: call void @__asan_report_load4
+// CHECK: }



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


[clang] 04aff39 - Revert "Reland "[clang-repl] Re-implement clang-interpreter as a test case.""

2021-10-08 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-10-08T17:43:23-07:00
New Revision: 04aff395047ab39811eea1fd811a5874d3e4dfe4

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

LOG: Revert "Reland "[clang-repl] Re-implement clang-interpreter as a test 
case.""

This reverts commit 1dba6b37bdc70210f75a480eff3715ebe1f1d8be.

Reverting because the ClangReplInterpreterExceptionTests test fails on
our builders with this patch.

Added: 
clang/examples/clang-interpreter/CMakeLists.txt
clang/examples/clang-interpreter/README.txt
clang/examples/clang-interpreter/Test.cxx
clang/test/Misc/interpreter.c

Modified: 
clang/docs/ClangFormattedStatus.rst
clang/examples/CMakeLists.txt
clang/include/clang/Interpreter/Interpreter.h
clang/lib/Interpreter/IncrementalExecutor.cpp
clang/lib/Interpreter/IncrementalExecutor.h
clang/lib/Interpreter/Interpreter.cpp
clang/test/CMakeLists.txt
clang/test/lit.cfg.py
clang/unittests/Interpreter/CMakeLists.txt
clang/unittests/Interpreter/InterpreterTest.cpp

Removed: 
clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp



diff  --git a/clang/docs/ClangFormattedStatus.rst 
b/clang/docs/ClangFormattedStatus.rst
index 6a09214bcfafe..d9af218518509 100644
--- a/clang/docs/ClangFormattedStatus.rst
+++ b/clang/docs/ClangFormattedStatus.rst
@@ -59,6 +59,11 @@ tree in terms of conformance to :doc:`ClangFormat` as of: 
October 02, 2021 15:06
  - `1`
  - `0`
  - :good:`100%`
+   * - clang/examples/clang-interpreter
+ - `1`
+ - `0`
+ - `1`
+ - :none:`0%`
* - clang/examples/PrintFunctionNames
  - `1`
  - `0`

diff  --git a/clang/examples/CMakeLists.txt b/clang/examples/CMakeLists.txt
index 8a4139f5d8c11..300d8d795c674 100644
--- a/clang/examples/CMakeLists.txt
+++ b/clang/examples/CMakeLists.txt
@@ -3,6 +3,7 @@ if(NOT CLANG_BUILD_EXAMPLES)
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
+add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)
 add_subdirectory(Attribute)

diff  --git a/clang/examples/clang-interpreter/CMakeLists.txt 
b/clang/examples/clang-interpreter/CMakeLists.txt
new file mode 100644
index 0..11056aa379ae8
--- /dev/null
+++ b/clang/examples/clang-interpreter/CMakeLists.txt
@@ -0,0 +1,93 @@
+set(LLVM_LINK_COMPONENTS
+  Core
+  ExecutionEngine
+  MC
+  MCJIT
+  Object
+  OrcJit
+  Option
+  RuntimeDyld
+  Support
+  native
+  )
+
+add_clang_executable(clang-interpreter
+  main.cpp
+  )
+
+add_dependencies(clang-interpreter
+  clang-resource-headers
+  )
+
+clang_target_link_libraries(clang-interpreter
+  PRIVATE
+  clangBasic
+  clangCodeGen
+  clangDriver
+  clangFrontend
+  clangSerialization
+  )
+
+export_executable_symbols(clang-interpreter)
+
+if (MSVC)
+  # Is this a CMake bug that even with export_executable_symbols, Windows
+  # needs to explictly export the type_info vtable
+  set_property(TARGET clang-interpreter
+   APPEND_STRING PROPERTY LINK_FLAGS " /EXPORT:??_7type_info@@6B@")
+endif()
+
+function(clang_enable_exceptions TARGET)
+  # Really have to jump through hoops to enable exception handling independent
+  # of how LLVM is being built.
+  if (NOT LLVM_REQUIRES_EH AND NOT LLVM_REQUIRES_RTTI)
+if (MSVC)
+  # /EHs to allow throwing from extern "C"
+  set(excptnExceptions_ON "/D _HAS_EXCEPTIONS=1 /EHs /wd4714")
+  set(excptnExceptions_OFF "/D _HAS_EXCEPTIONS=0 /EHs-c-")
+  set(excptnRTTI_ON "/GR")
+  set(excptnRTTI_OFF "/GR-")
+  set(excptnEHRTTIRegEx "(/EHs(-c-?)|_HAS_EXCEPTIONS=(0|1))")
+else()
+  set(excptnExceptions_ON "-fexceptions")
+  set(excptnExceptions_OFF "-fno-exceptions")
+  set(excptnRTTI_ON "-frtti")
+  set(excptnRTTI_OFF "-fno-rtti")
+  set(excptnEHRTTIRegEx "-f(exceptions|no-exceptions)")
+endif()
+if (LLVM_REQUIRES_EH)
+  set(excptnExceptions_DFLT ${excptnExceptions_ON})
+else()
+  set(excptnExceptions_DFLT ${excptnExceptions_OFF})
+endif()
+if (LLVM_REQUIRES_RTTI)
+  set(excptnRTTI_DFLT ${excptnRTTI_ON})
+else()
+  set(excptnRTTI_DFLT ${excptnRTTI_OFF})
+endif()
+
+# Strip the exception & rtti flags from the target
+get_property(addedFlags TARGET ${TARGET} PROPERTY COMPILE_FLAGS)
+string(REGEX REPLACE ${excptnEHRTTIRegEx} "" editedFlags "${addedFlags}")
+string(REPLACE ${excptnRTTI_OFF} "" editedFlags "${editedFlags}")
+set_property(TARGET ${TARGET} PROPERTY COMPILE_FLAGS "${editedFlags}")
+
+get_property(addedFlags TARGET ${TARGET} PROPERTY COMPILE_DEFINITIONS)
+string(REGEX REPLACE ${excptnEHRTTIRegEx} "" editedFlags "${addedFlags}")
+string(REPLACE ${excptnRTTI_OFF} "" 

[clang] 976aa4d - Reland "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes build"

2021-10-07 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-10-07T14:19:29-07:00
New Revision: 976aa4d759c7c85786a23de5d09ad771f1e890e0

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

LOG: Reland "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes build"

This reverts commit a625fd26cea579853bfe6c00f8fd8e6e88388630.

Round 3: The scudo test was addressed in
6727832c324c1fb43946275d24e2931fde94bc0d.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 151ac815b8105..baf6adbaa6e6e 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -120,6 +120,7 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING 
"")
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")



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


[clang] a625fd2 - Revert "Reland "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes build""

2021-10-06 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-10-06T15:09:40-07:00
New Revision: a625fd26cea579853bfe6c00f8fd8e6e88388630

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

LOG: Revert "Reland "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes 
build""

This reverts commit c52d60ec3b9202eaa9e109be539f1d2a03fbad70.

The failing scudo test came up again.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index baf6adbaa6e6..151ac815b810 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -120,7 +120,6 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING 
"")
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
-set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")



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


[clang] c7e7278 - [clang][Fuchsia] Add -static-libgcc to TSAN tests

2021-10-06 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-10-06T14:01:39-07:00
New Revision: c7e72784aef9ee5f32e438e4d2d09a9710d5538b

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

LOG: [clang][Fuchsia] Add -static-libgcc to TSAN tests

This will ensure that tsan tests are built with the built libunwind.a
rather than the host libunwind.so.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 5efa3028a0c6..baf6adbaa6e6 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -137,7 +137,7 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
 set(RUNTIMES_${target}_COMPILER_RT_TEST_COMPILER_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
 set(RUNTIMES_${target}_SANITIZER_COMMON_TEST_TARGET_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
-set(RUNTIMES_${target}_TSAN_TEST_TARGET_CFLAGS "--unwindlib=libunwind" 
CACHE STRING "")
+set(RUNTIMES_${target}_TSAN_TEST_TARGET_CFLAGS "--unwindlib=libunwind 
-static-libgcc" CACHE STRING "")
 set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 



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


[clang] c52d60e - Reland "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes build"

2021-10-06 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-10-06T13:57:24-07:00
New Revision: c52d60ec3b9202eaa9e109be539f1d2a03fbad70

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

LOG: Reland "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes build"

This reverts commit 95f824ad7c2da1e8142dbade4e4e12f389f1eb78.

We should've addressed the remaining issues on our CI builders.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 1fbbaf74b0ec..5efa3028a0c6 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -120,6 +120,7 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING 
"")
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")



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


[clang] 95f824a - Revert "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes build"

2021-10-04 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-10-04T16:11:43-07:00
New Revision: 95f824ad7c2da1e8142dbade4e4e12f389f1eb78

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

LOG: Revert "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes build"

This reverts commit 8480063f25b8527d935722769d54d47f0c0d5689.

We're seeing some test failures on our builders.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 5efa3028a0c6..1fbbaf74b0ec 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -120,7 +120,6 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING 
"")
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
-set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")



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


[clang] 8480063 - [clang][Fuchsia] Re-enable compiler-rt tests in runtimes build

2021-10-04 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-10-04T14:11:49-07:00
New Revision: 8480063f25b8527d935722769d54d47f0c0d5689

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

LOG: [clang][Fuchsia] Re-enable compiler-rt tests in runtimes build

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 1fbbaf74b0ec8..5efa3028a0c65 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -120,6 +120,7 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING 
"")
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")



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


[clang] 78f7ad5 - [clang][Fuchsia] Remove COMPILER_RT_CAN_EXECUTE_TESTS

2021-09-08 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-09-08T15:52:02-07:00
New Revision: 78f7ad5a83c3b7f37b5331486c289eba1040d56a

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

LOG: [clang][Fuchsia] Remove COMPILER_RT_CAN_EXECUTE_TESTS

I forgot that we run `check-runtimes-x86_64-unknown-linux-gnu`, which
will run all compiler-rt tests also even though we are currently not in
a state where we can run them all yet. Remove this for now to fix our CI
builders.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 5efa3028a0c65..1fbbaf74b0ec8 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -120,7 +120,6 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING 
"")
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
-set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")



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


[clang] e567356 - [compiler-rt][Fuchsia] Support building + running compiler-rt tests on fuchsia's host toolchain

2021-09-08 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-09-08T11:32:11-07:00
New Revision: e5673564a06b7792c6aa9afe3d82f8b2203f975e

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

LOG: [compiler-rt][Fuchsia] Support building + running compiler-rt tests on 
fuchsia's host toolchain

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 09e8a0780c54c..5efa3028a0c65 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -60,7 +60,6 @@ if(APPLE)
   set(COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
 
   set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
-  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
   set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
@@ -121,9 +120,9 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING 
"")
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
@@ -136,6 +135,10 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI "libc++" CACHE STRING "")
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_TEST_COMPILER_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
+set(RUNTIMES_${target}_SANITIZER_COMMON_TEST_TARGET_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
+set(RUNTIMES_${target}_TSAN_TEST_TARGET_CFLAGS "--unwindlib=libunwind" 
CACHE STRING "")
+set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
 # Use .build-id link.



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


[clang] e2ff880 - [clang][cache] Update Fuchsia-stage2.cmake to create hwasan multilibs

2021-08-10 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-08-10T10:52:24-07:00
New Revision: e2ff880a7ed464f0649c47132603562312fff102

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

LOG: [clang][cache] Update Fuchsia-stage2.cmake to create hwasan multilibs

This is a reland of commit a9d1970384aa3908adbf6f50f110c375def58947.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index aa45c1549340b..e58ae3ac247aa 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -226,11 +226,30 @@ if(FUCHSIA_SDK)
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;compat;asan+noexcept" CACHE STRING 
"")
+  # HWAsan
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LLVM_BUILD_COMPILER_RT OFF CACHE 
BOOL "")
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LLVM_USE_SANITIZER "HWAddress" 
CACHE STRING "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_CMAKE_CXX_FLAGS 
"${FUCHSIA_aarch64-unknown-fuchsia_COMPILER_FLAGS} -mllvm --hwasan-globals=0" 
CACHE STRING "")
+
+  # HWASan+noexcept
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LLVM_USE_SANITIZER 
"HWAddress" CACHE STRING "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_CMAKE_CXX_FLAGS 
"${FUCHSIA_aarch64-unknown-fuchsia_COMPILER_FLAGS} -mllvm --hwasan-globals=0" 
CACHE STRING "")
+
+  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;compat;asan+noexcept;hwasan;hwasan+noexcept" CACHE STRING "")
+
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_compat_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_hwasan_TARGETS "aarch64-unknown-fuchsia" CACHE 
STRING "")
+  set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS "aarch64-unknown-fuchsia" 
CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")



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


[clang] bb438f6 - [clang][cache] Update Fuchsia-stage2.cmake to create hwasan multilibs

2021-07-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-07-30T11:53:21-07:00
New Revision: bb438f6cbfc08eaa2cd9124a0ad581dd29f819b4

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

LOG: [clang][cache] Update Fuchsia-stage2.cmake to create hwasan multilibs

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index aa45c1549340b..8c7518d7da312 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -226,11 +226,30 @@ if(FUCHSIA_SDK)
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;compat;asan+noexcept" CACHE STRING 
"")
+  # HWAsan
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LLVM_BUILD_COMPILER_RT OFF CACHE 
BOOL "")
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LLVM_USE_SANITIZER "HWAddress" 
CACHE STRING "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_CMAKE_CXX_FLAGS 
"${RUNTIMES_aarch64-unknown-fuchsia+hwasan_CMAKE_CXX_FLAGS} -mllvm 
--hwasan-globals=0" CACHE STRING "")
+
+  # HWASan+noexcept
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LLVM_USE_SANITIZER 
"HWAddress" CACHE STRING "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+  
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
+  set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_CMAKE_CXX_FLAGS 
"${RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_CMAKE_CXX_FLAGS} -mllvm 
--hwasan-globals=0" CACHE STRING "")
+
+  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;compat;asan+noexcept;hwasan;hwasan+noexcept" CACHE STRING "")
+
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_compat_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_hwasan_TARGETS "aarch64-unknown-fuchsia" CACHE 
STRING "")
+  set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS "aarch64-unknown-fuchsia" 
CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")



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


[clang] 9b0ddc2 - [clang][Fuchsia] Remove relative-vtables multilibs

2021-06-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-06-30T11:21:37-07:00
New Revision: 9b0ddc2662addaa563b632c577996e515e1a7802

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

LOG: [clang][Fuchsia] Remove relative-vtables multilibs

As of D102374, relative vtables is enabled on Fuchsia by default, so we don't 
need any of the RV multilibs.

Differential revision: https://reviews.llvm.org/D105145

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index eb001ef6579ce..c031465002cca 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -222,41 +222,15 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE 
BOOL "")
 set(RUNTIMES_${target}+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE 
BOOL "")
 
-set(RUNTIMES_${target}+relative-vtables_LLVM_BUILD_COMPILER_RT OFF CACHE 
BOOL "")
-set(RUNTIMES_${target}+relative-vtables_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-set(RUNTIMES_${target}+relative-vtables+asan_LLVM_BUILD_COMPILER_RT OFF 
CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan_LLVM_USE_SANITIZER "Address" 
CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+asan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-set(RUNTIMES_${target}+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+noexcept_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LLVM_USE_SANITIZER 
"Address" CACHE STRING "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}+relative-vtables+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}+relative-vtables+asan+noexcept_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;compat;asan+noexcept;relative-vtables;relative-vtables+noexcept;relative-vtables+asan;relative-vtables+asan+noexcept"
 CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;compat;asan+noexcept" CACHE STRING 
"")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_compat_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")



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


[clang] e6f88dc - [clang][Fuchsia] Turn on relative-vtables by default for Fuchsia

2021-06-01 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-06-01T15:46:09-07:00
New Revision: e6f88dc01a7208b6f4671c4fcb5d9e68d0808a34

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

LOG: [clang][Fuchsia] Turn on relative-vtables by default for Fuchsia

All fuchsia targets will now use the relative-vtables ABI by default.
Also remove -fexperimental-relative-c++-abi-vtables from test RUNs targeting 
fuchsia.

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

Added: 


Modified: 
clang/include/clang/Basic/TargetCXXABI.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/available_externally-vtable.cpp

clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-1.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-2.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/diamond-inheritance.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/inheritted-virtual-function.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/member-function-pointer.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/no-alias-when-dso-local.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/override-pure-virtual-method.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/overriden-virtual-function.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-flag.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/thunk-mangling.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/vbase-offset.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/virtual-function-call.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/vtable-hidden-when-in-comdat.cpp
clang/test/CodeGenCXX/constructor-destructor-return-this.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetCXXABI.h 
b/clang/include/clang/Basic/TargetCXXABI.h
index 91189996a4d9a..e727f85edad72 100644
--- a/clang/include/clang/Basic/TargetCXXABI.h
+++ b/clang/include/clang/Basic/TargetCXXABI.h
@@ -64,6 +64,12 @@ class TargetCXXABI {
 return getABIMap().find(Name) != getABIMap().end();
   }
 
+  // Return true if this target should use the relative vtables C++ ABI by
+  // default.
+  static bool usesRelativeVTables(const llvm::Triple ) {
+return T.isOSFuchsia();
+  }
+
   /// A bogus initialization of the platform ABI.
   TargetCXXABI() : TheKind(GenericItanium) {}
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c4fc6463d1058..076ce3f85fa8e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1932,10 +1932,14 @@ defm fine_grained_bitfield_accesses : BoolOption<"f", 
"fine-grained-bitfield-acc
   BothFlags<[CC1Option]>>,
   Group;
 
-defm experimental_relative_cxx_abi_vtables : 
BoolFOption<"experimental-relative-c++-abi-vtables",
-  LangOpts<"RelativeCXXABIVTables">, DefaultFalse,
-  PosFlag, NegFlag,
-  BothFlags<[CC1Option], " the experimental C++ class ABI for classes with 
virtual tables">>;
+def fexperimental_relative_cxx_abi_vtables :
+  Flag<["-"], "fexperimental-relative-c++-abi-vtables">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Use the experimental C++ class ABI for classes with virtual 
tables">;
+def fno_experimental_relative_cxx_abi_vtables :
+  Flag<["-"], "fno-experimental-relative-c++-abi-vtables">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Do not use the experimental C++ class ABI for classes with virtual 
tables">;
 
 def fcxx_abi_EQ : Joined<["-"], "fc++-abi=">,
   Group, Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c974c80f1f10e..0177f7fd80be8 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5386,6 +5386,9 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   if (Arg *A = Args.getLastArg(options::OPT_fcxx_abi_EQ))
 A->render(Args, CmdArgs);
 
+  Args.AddLastArg(CmdArgs, options::OPT_fexperimental_relative_cxx_abi_vtables,
+  options::OPT_fno_experimental_relative_cxx_abi_vtables);
+
   // Handle -{std, ansi, trigraphs} -- take the last of -{std, ansi}
   // (-ansi is equivalent 

[clang] da1db49 - [Fuchsia] Add compat multilibs to cache file

2021-06-01 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-06-01T15:14:56-07:00
New Revision: da1db49409657d5212185ab9952ee35d99b773d4

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

LOG: [Fuchsia] Add compat multilibs to cache file

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index db1631f7f1430..7a3853f9e7aa5 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -195,6 +195,12 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
+# Compat multilibs.
+set(RUNTIMES_${target}+compat_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
+set(RUNTIMES_${target}+compat_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL 
"")
+set(RUNTIMES_${target}+compat_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(RUNTIMES_${target}+compat_CMAKE_CXX_FLAGS 
"${FUCHSIA_${target}_COMPILER_FLAGS} -fc++-abi=itanium" CACHE STRING "")
+
 set(RUNTIMES_${target}+asan_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
 set(RUNTIMES_${target}+asan_LLVM_USE_SANITIZER "Address" CACHE STRING "")
 set(RUNTIMES_${target}+asan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF 
CACHE BOOL "")
@@ -237,9 +243,10 @@ if(FUCHSIA_SDK)
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;asan+noexcept;relative-vtables;relative-vtables+noexcept;relative-vtables+asan;relative-vtables+asan+noexcept"
 CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;compat;asan+noexcept;relative-vtables;relative-vtables+noexcept;relative-vtables+asan;relative-vtables+asan+noexcept"
 CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_compat_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")



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


[clang] 5cb1772 - [clang][Fuchsia] Introduce compat multilibs

2021-05-11 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-05-11T15:45:38-07:00
New Revision: 5cb17728d19408725d4ced928ff3276dd4ffd1c9

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

LOG: [clang][Fuchsia] Introduce compat multilibs

These are GCC-compatible multilibs that use the generic Itanium C++ ABI
instead of the Fuchsia C++ ABI.

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

Added: 

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-unknown-fuchsia/compat/libc++.so

Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index cf562335e18e6..502afdc1e30c9 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -242,6 +242,8 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   .flag("+fsanitize=hwaddress")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
+  // Use Itanium C++ ABI for the compat multilib.
+  Multilibs.push_back(Multilib("compat", {}, {}, 
12).flag("+fc++-abi=itanium"));
 
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
@@ -263,6 +265,8 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
options::OPT_fno_experimental_relative_cxx_abi_vtables,
/*default=*/false),
   "fexperimental-relative-c++-abi-vtables", Flags);
+  addMultilibFlag(Args.getLastArgValue(options::OPT_fcxx_abi_EQ) == "itanium",
+  "fc++-abi=itanium", Flags);
 
   Multilibs.setFilePathsCallback(FilePaths);
 

diff  --git 
a/clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-unknown-fuchsia/compat/libc++.so
 
b/clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-unknown-fuchsia/compat/libc++.so
new file mode 100644
index 0..e69de29bb2d1d

diff  --git a/clang/test/Driver/fuchsia.cpp b/clang/test/Driver/fuchsia.cpp
index 86a0acebc0842..bd4c7ebeb5601 100644
--- a/clang/test/Driver/fuchsia.cpp
+++ b/clang/test/Driver/fuchsia.cpp
@@ -144,6 +144,23 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s 
-check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-NOEXCEPT-X86
+
+// Test compat multilibs.
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -fc++-abi=itanium \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1\
+// RUN: | FileCheck %s 
-check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-COMPAT-X86
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -fc++-abi=itanium 
-fc++-abi=fuchsia \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1\
+// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -fc++-abi=fuchsia 
-fc++-abi=itanium \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1\
+// RUN: | FileCheck %s 
-check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-COMPAT-X86
 // CHECK-MULTILIB-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-MULTILIB-ASAN-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-unknown-fuchsia{{/|}}asan"
 // CHECK-MULTILIB-NOEXCEPT-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-unknown-fuchsia{{/|}}noexcept"
@@ -156,4 +173,5 @@
 // CHECK-MULTILIB-HWASAN-NOEXCEPT-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-unknown-fuchsia{{/|}}hwasan+noexcept"
 // CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-unknown-fuchsia{{/|}}relative-vtables+hwasan"
 // CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-NOEXCEPT-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-unknown-fuchsia{{/|}}relative-vtables+hwasan+noexcept"
+// CHECK-MULTILIB-COMPAT-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-unknown-fuchsia{{/|}}compat"
 // CHECK-MULTILIB-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-unknown-fuchsia"



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


[clang] 0277a24 - [clang][test] Update -fc++-abi tests

2021-05-04 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-05-04T15:53:00-07:00
New Revision: 0277a24f4bbac284ba7a2ace7eeefdf6305e7f69

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

LOG: [clang][test] Update -fc++-abi tests

This attempts to move driver tests out of Frontend and to Driver, separates
RUNs that should fail from RUNs that should succeed, and prevent creating
output files or dumping output.

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

Added: 
clang/test/Driver/cxx-abi-flag.cpp
clang/test/Frontend/valid-cxx-abi.cpp

Modified: 
clang/test/Frontend/invalid-cxx-abi.cpp

Removed: 




diff  --git a/clang/test/Driver/cxx-abi-flag.cpp 
b/clang/test/Driver/cxx-abi-flag.cpp
new file mode 100644
index ..e6b13dbaf4e4
--- /dev/null
+++ b/clang/test/Driver/cxx-abi-flag.cpp
@@ -0,0 +1,11 @@
+// Ensure that the driver flag is propagated to cc1.
+// RUN: %clang -### -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s \
+// RUN:   2>&1 | FileCheck %s -check-prefix=ITANIUM
+// RUN: %clang -### -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s \
+// RUN:   2>&1 | FileCheck %s -check-prefix=FUCHSIA
+// RUN: %clang -### -fc++-abi=microsoft -target x86_64-unknown-windows-msvc %s 
\
+// RUN:   2>&1 | FileCheck %s -check-prefix=MICROSOFT
+//
+// ITANIUM: -fc++-abi=itanium
+// FUCHSIA: -fc++-abi=fuchsia
+// MICROSOFT: -fc++-abi=microsoft

diff  --git a/clang/test/Frontend/invalid-cxx-abi.cpp 
b/clang/test/Frontend/invalid-cxx-abi.cpp
index 2bc0aac52cc7..df1ea9463670 100644
--- a/clang/test/Frontend/invalid-cxx-abi.cpp
+++ b/clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,24 +1,9 @@
-// REQUIRES: x86-registered-target
-
-// These should succeed.
-// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
-// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
-// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
-
-// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang -c -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
-// RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
+// These shouldn't be valid -fc++-abi values.
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=InvalidABI %s 2>&1 
| FileCheck %s -check-prefix=INVALID
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=Fuchsia %s 2>&1 | 
FileCheck %s -check-prefix=CASE-SENSITIVE
 // INVALID: error: Invalid C++ ABI name 'InvalidABI'
 // CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
 
-// The flag is propgated from the driver to cc1.
-// RUN: %clang -fc++-abi=InvalidABI %s -### 2>&1 | FileCheck %s 
-check-prefix=CC1-FLAG
-// CC1-FLAG: -fc++-abi=InvalidABI
-
 // Some C++ ABIs are not supported on some platforms.
-// RUN: not %clang_cc1 -c -fc++-abi=fuchsia -triple i386 %s 2>&1 | FileCheck 
%s -check-prefix=UNSUPPORTED-FUCHSIA
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=fuchsia -triple 
i386 %s 2>&1 | FileCheck %s -check-prefix=UNSUPPORTED-FUCHSIA
 // UNSUPPORTED-FUCHSIA: error: C++ ABI 'fuchsia' is not supported on target 
triple 'i386'

diff  --git a/clang/test/Frontend/valid-cxx-abi.cpp 
b/clang/test/Frontend/valid-cxx-abi.cpp
new file mode 100644
index ..99f8dc869e0d
--- /dev/null
+++ b/clang/test/Frontend/valid-cxx-abi.cpp
@@ -0,0 +1,4 @@
+// These should be valid cxx abi flags for these targets.
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s -S 
-emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s -S 
-emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s -S 
-emit-llvm -o /dev/null



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


[clang] 9c72a21 - Fix for test failure caused by 84c475437267e7fffedc40029ce274b099d8f8f3.

2021-05-04 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-05-04T11:45:32-07:00
New Revision: 9c72a210b58f19632af0e91679da7aa63f51ad7a

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

LOG: Fix for test failure caused by 84c475437267e7fffedc40029ce274b099d8f8f3.

Reduces the number of targets/triples for this test since not all cmake
invocations will build for those targets.

Added: 


Modified: 
clang/test/Frontend/invalid-cxx-abi.cpp

Removed: 




diff  --git a/clang/test/Frontend/invalid-cxx-abi.cpp 
b/clang/test/Frontend/invalid-cxx-abi.cpp
index 95ee442f286d..2bc0aac52cc7 100644
--- a/clang/test/Frontend/invalid-cxx-abi.cpp
+++ b/clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,21 +1,11 @@
+// REQUIRES: x86-registered-target
+
 // These should succeed.
-// RUN: %clang -c -fc++-abi=itanium %s
-// RUN: %clang -c -fc++-abi=arm -target arm64 %s
-// RUN: %clang -c -fc++-abi=ios -target arm64-apple-ios %s
-// RUN: %clang -c -fc++-abi=aarch64 -target arm64 %s
-// RUN: %clang -c -fc++-abi=mips -target mips %s
-// RUN: %clang -c -fc++-abi=webassembly -target wasm64 %s
+// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
 // RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -S -fc++-abi=xl -target powerpc-unknown-aix %s -o /dev/null
 // RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium %s
-// RUN: %clang_cc1 -fc++-abi=arm -triple arm64 %s
-// RUN: %clang_cc1 -fc++-abi=ios -triple arm64-apple-ios %s
-// RUN: %clang_cc1 -fc++-abi=aarch64 -triple arm64 %s
-// RUN: %clang_cc1 -fc++-abi=mips -triple mips %s
-// RUN: %clang_cc1 -fc++-abi=webassembly -triple wasm64 %s
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
 // RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -S -fc++-abi=xl -triple powerpc-unknown-aix %s -o /dev/null
 // RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
 
 // RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID



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


[clang] 84c4754 - [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-05-04 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-05-04T10:52:13-07:00
New Revision: 84c475437267e7fffedc40029ce274b099d8f8f3

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

LOG: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

This implements the flag proposed in RFC
http://lists.llvm.org/pipermail/cfe-dev/2020-August/066437.html.

The goal is to add a way to override the default target C++ ABI through a
compiler flag. This makes it easier to test and transition between different
C++ ABIs through compile flags rather than build flags.

In this patch:

- Store -fc++-abi= in a LangOpt. This isn't stored in a CodeGenOpt because
  there are instances outside of codegen where Clang needs to know what the
  ABI is (particularly through ASTContext::createCXXABI), and we should be
  able to override the target default if the flag is provided at that point.
- Expose the existing ABIs in TargetCXXABI as values that can be passed
  through this flag.
  - Create a .def file for these ABIs to make it easier to check flag values.
  - Add an error for diagnosing bad ABI flag values.

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

Added: 
clang/include/clang/Basic/TargetCXXABI.def
clang/test/CodeGenCXX/cxx-abi-switch.cpp
clang/test/Frontend/invalid-cxx-abi.cpp

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/TargetCXXABI.h
clang/include/clang/Driver/Options.td
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1b73e4a2b8ee9..bef793831c6b2 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -40,6 +40,7 @@
 #include "clang/Basic/ProfileList.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
+#include "clang/Basic/TargetCXXABI.h"
 #include "clang/Basic/XRayLists.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -730,6 +731,11 @@ class ASTContext : public RefCountedBase {
 return FullSourceLoc(Loc,SourceMgr);
   }
 
+  /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
+  /// at compile time with `-fc++-abi=`. If this is not provided, we instead 
use
+  /// the default ABI set by the target.
+  TargetCXXABI::Kind getCXXABIKind() const;
+
   /// All comments in this translation unit.
   RawCommentList Comments;
 

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 92ce91c11b71e..0e3ac3065ebc5 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -540,6 +540,9 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE 
setting %0 is not recognize
 def err_aix_default_altivec_abi : Error<
   "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' 
for the extended Altivec ABI">;
 
+def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">;
+def err_unsupported_cxx_abi : Error<"C++ ABI '%0' is not supported on target 
triple '%1'">;
+
 def note_cc1_round_trip_original : Note<"Original arguments in round-trip: 
%0">;
 def note_cc1_round_trip_generated : Note<"Generated arguments #%0 in 
round-trip: %1">;
 def remark_cc1_round_trip_generated : Remark<"Generated arguments #%0 in 
round-trip: %1">, InGroup;

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 85fe4af720235..5ccac6367a5f3 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -19,6 +19,7 @@
 #include "clang/Basic/LangStandard.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Sanitizers.h"
+#include "clang/Basic/TargetCXXABI.h"
 #include "clang/Basic/Visibility.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/StringRef.h"
@@ -337,6 +338,10 @@ class LangOptions : public LangOptionsBase {
   /// like CUDA/HIP.
   std::string CUID;
 
+  /// C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
+  /// This overrides the default ABI used by the target.
+  llvm::Optional CXXABI;
+
   /// Indicates whether the front-end is explicitly told that the
   /// input is a header file (i.e. -x c-header).
   bool IsHeaderFile = false;

diff  --git a/clang/include/clang/Basic/TargetCXXABI.def 
b/clang/include/clang/Basic/TargetCXXABI.def
new file mode 100644
index 0..9501cca760945
--- /dev/null
+++ 

[clang] 1abaadb - [clang][driver] Support HWASan in the Fuchsia toolchain

2021-03-25 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-03-25T13:36:23-07:00
New Revision: 1abaadb30d37e229eedb0e2ede6cd7f788aed76b

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

LOG: [clang][driver] Support HWASan in the Fuchsia toolchain

These contain clang driver changes for supporting HWASan on Fuchsia.
This includes hwasan multilibs and the dylib path change.

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

Added: 

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/hwasan+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/hwasan/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+hwasan+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+hwasan/libc++.so

Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 8e086010a984..25b7e4ed1d52 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -95,6 +95,8 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
 std::string Dyld = D.DyldPrefix;
 if (SanArgs.needsAsanRt() && SanArgs.needsSharedRt())
   Dyld += "asan/";
+if (SanArgs.needsHwasanRt() && SanArgs.needsSharedRt())
+  Dyld += "hwasan/";
 if (SanArgs.needsTsanRt() && SanArgs.needsSharedRt())
   Dyld += "tsan/";
 Dyld += "ld.so.1";
@@ -210,23 +212,41 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
+  // HWASan has higher priority because we always want the instrumentated
+  // version.
+  Multilibs.push_back(
+  Multilib("hwasan", {}, {}, 4).flag("+fsanitize=hwaddress"));
+  // Use the hwasan+noexcept variant with HWASan and -fno-exceptions.
+  Multilibs.push_back(Multilib("hwasan+noexcept", {}, {}, 5)
+  .flag("+fsanitize=hwaddress")
+  .flag("-fexceptions")
+  .flag("+fno-exceptions"));
   // Use the relative vtables ABI.
   // TODO: Remove these multilibs once relative vtables are enabled by default
   // for Fuchsia.
-  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
+  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 6)
   .flag("+fexperimental-relative-c++-abi-vtables"));
-  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
+  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 7)
   .flag("+fexperimental-relative-c++-abi-vtables")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
-  Multilibs.push_back(Multilib("relative-vtables+asan", {}, {}, 6)
+  Multilibs.push_back(Multilib("relative-vtables+asan", {}, {}, 8)
   .flag("+fexperimental-relative-c++-abi-vtables")
   .flag("+fsanitize=address"));
-  Multilibs.push_back(Multilib("relative-vtables+asan+noexcept", {}, {}, 7)
+  Multilibs.push_back(Multilib("relative-vtables+asan+noexcept", {}, {}, 9)
   .flag("+fexperimental-relative-c++-abi-vtables")
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
+  Multilibs.push_back(Multilib("relative-vtables+hwasan", {}, {}, 10)
+  .flag("+fexperimental-relative-c++-abi-vtables")
+  .flag("+fsanitize=hwaddress"));
+  Multilibs.push_back(Multilib("relative-vtables+hwasan+noexcept", {}, {}, 11)
+  .flag("+fexperimental-relative-c++-abi-vtables")
+  .flag("+fsanitize=hwaddress")
+  .flag("-fexceptions")
+  .flag("+fno-exceptions"));
+
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
 return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
@@ -239,6 +259,8 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, 
true),
   "fexceptions", Flags);
   addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", 
Flags);
+  addMultilibFlag(getSanitizerArgs().needsHwasanRt(), "fsanitize=hwaddress",
+  Flags);
 
   addMultilibFlag(
   Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
@@ -368,6 +390,7 @@ void 

[clang] 70af0bf - [clang][Driver] Expose -fexperimental-relative-c++-abi-vtables flag

2021-03-10 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-03-10T16:28:40-08:00
New Revision: 70af0bf6fe462cc16a2e56657d20eeed126d41d0

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

LOG: [clang][Driver] Expose -fexperimental-relative-c++-abi-vtables flag

Initially, this flag was meant to only be used through cc1 and not directly
through the clang driver. However, we accidentally ended up using this flag
as a driver flag already for selecting multilibs within the fuchsia toolchain.
We're currently in an awkward state where it's only accepted as a driver flag
when targeting Fuchsia, and all other instances it can only be added via
-Xclang. Since we're ready to use this in Fuchsia, we can just expose this to
the driver for simplicity.

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

Added: 
clang/test/Driver/relative-vtables-flag.cpp

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7e7ad9437a1c..246bdf42a66a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4869,6 +4869,9 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   Args.AddLastArg(CmdArgs, options::OPT_ffine_grained_bitfield_accesses,
   options::OPT_fno_fine_grained_bitfield_accesses);
 
+  Args.AddLastArg(CmdArgs, options::OPT_fexperimental_relative_cxx_abi_vtables,
+  options::OPT_fno_experimental_relative_cxx_abi_vtables);
+
   // Handle segmented stacks.
   if (Args.hasArg(options::OPT_fsplit_stack))
 CmdArgs.push_back("-split-stacks");

diff  --git a/clang/test/Driver/relative-vtables-flag.cpp 
b/clang/test/Driver/relative-vtables-flag.cpp
new file mode 100644
index ..1253809e1d42
--- /dev/null
+++ b/clang/test/Driver/relative-vtables-flag.cpp
@@ -0,0 +1,7 @@
+// RUN: %clangxx --target=aarch64-unknown-fuchsia 
-fexperimental-relative-c++-abi-vtables -c %s -### 2>&1 | FileCheck %s 
--check-prefix=RV
+// RUN: %clangxx --target=aarch64-unknown-fuchsia 
-fno-experimental-relative-c++-abi-vtables -c %s -### 2>&1 | FileCheck %s 
--check-prefix=NO-RV
+// RUN: %clangxx --target=aarch64-unknown-fuchsia -c %s -### 2>&1 | FileCheck 
%s --check-prefix=NO-RV
+// RUN: %clangxx --target=aarch64-unknown-linux-gnu -c %s -### 2>&1 | 
FileCheck %s --check-prefix=NO-RV
+
+// RV: "-fexperimental-relative-c++-abi-vtables"
+// NO-RV-NOT: "-fexperimental-relative-c++-abi-vtables"



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


[clang] 6dad7ec - [clang] Fix noderef for AddrOf on MemberExpr

2020-12-07 Thread Leonard Chan via cfe-commits

Author: Jann Horn
Date: 2020-12-07T14:48:41-08:00
New Revision: 6dad7ec539cbcf6f59b63753a86b8015bd6ea66f

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

LOG: [clang] Fix noderef for AddrOf on MemberExpr

Committing on behalf of thejh (Jann Horn).

As part of this change, one existing test case has to be adjusted
because it accidentally stripped the NoDeref attribute without
getting caught.

Depends on D92140

Differential Review: https://reviews.llvm.org/D92141

Added: 


Modified: 
clang/lib/Sema/SemaExprMember.cpp
clang/test/Frontend/noderef.c

Removed: 




diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 3e9d2a056c5c..f5afcb76fc96 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1810,6 +1810,14 @@ Sema::BuildFieldReferenceExpr(Expr *BaseExpr, bool 
IsArrow,
 Qualifiers Combined = BaseQuals + MemberQuals;
 if (Combined != MemberQuals)
   MemberType = Context.getQualifiedType(MemberType, Combined);
+
+// Pick up NoDeref from the base in case we end up using AddrOf on the
+// result. E.g. the expression
+// >pointerMember
+// should be a noderef pointer again.
+if (BaseType->hasAttr(attr::NoDeref))
+  MemberType =
+  Context.getAttributedType(attr::NoDeref, MemberType, MemberType);
   }
 
   auto *CurMethod = dyn_cast(CurContext);

diff  --git a/clang/test/Frontend/noderef.c b/clang/test/Frontend/noderef.c
index b548ffa13273..d136ff0c7192 100644
--- a/clang/test/Frontend/noderef.c
+++ b/clang/test/Frontend/noderef.c
@@ -70,6 +70,12 @@ int test() {
   x = sizeof(s->a + (s->b)); // ok
   x = sizeof(int[++s->a]);   // expected-warning{{dereferencing s; was 
declared with a 'noderef' type}}
 
+  // Struct member access should carry NoDeref type information through to an
+  // enclosing AddrOf.
+  p2 = >a;   // expected-warning{{casting to dereferenceable pointer 
removes 'noderef' attribute}}
+  p2 = &(*s).a; // expected-warning{{casting to dereferenceable pointer 
removes 'noderef' attribute}}
+  x = *>a;   // expected-warning{{dereferencing expression marked as 
'noderef'}}
+
   // Nested struct access
   struct S2 NODEREF *s2_noderef;// expected-note 5 {{s2_noderef declared 
here}}
   p = s2_noderef->a;  // ok since result is an array in a struct
@@ -113,7 +119,7 @@ int test() {
 
   p = s2_arr[1]->a;
   p = s2_arr[1]->b; // expected-warning{{dereferencing expression marked as 
'noderef'}}
-  int **bptr = _arr[1]->b;
+  int *NODEREF *bptr = _arr[1]->b;
 
   x = s2->s2->a;// expected-warning{{dereferencing expression marked 
as 'noderef'}}
   x = s2_noderef->a[1]; // expected-warning{{dereferencing s2_noderef; was 
declared with a 'noderef' type}}



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


[clang] 155fca3 - [clang] Fix noderef for array member of deref expr

2020-12-07 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-12-07T14:39:42-08:00
New Revision: 155fca3cae275562e626d3e4fbfac70b4b75d2e7

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

LOG: [clang] Fix noderef for array member of deref expr

Committing on behalf of thejh (Jann Horn).

Given an attribute((noderef)) pointer "p" to the struct

struct s { int a[2]; };
ensure that the following expressions are treated the same way by the
noderef logic:

p->a
(*p).a
Until now, the first expression would be treated correctly (nothing is
added to PossibleDerefs because CheckMemberAccessOfNoDeref() bails out
on array members), but the second expression would incorrectly warn
because "*p" creates a PossibleDerefs entry.

Handle this case the same way as for the AddrOf operator.

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

Added: 


Modified: 
clang/lib/Sema/SemaExprMember.cpp
clang/test/Frontend/noderef.c

Removed: 




diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 23cfae81df46..3e9d2a056c5c 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1739,12 +1739,23 @@ void Sema::CheckMemberAccessOfNoDeref(const MemberExpr 
*E) {
 
   QualType ResultTy = E->getType();
 
-  // Do not warn on member accesses to arrays since this returns an array
-  // lvalue and does not actually dereference memory.
-  if (isa(ResultTy))
-return;
-
-  if (E->isArrow()) {
+  // Member accesses have four cases:
+  // 1: non-array member via "->": dereferences
+  // 2: non-array member via ".": nothing interesting happens
+  // 3: array member access via "->": nothing interesting happens
+  //(this returns an array lvalue and does not actually dereference memory)
+  // 4: array member access via ".": *adds* a layer of indirection
+  if (ResultTy->isArrayType()) {
+if (!E->isArrow()) {
+  // This might be something like:
+  // (*structPtr).arrayMember
+  // which behaves roughly like:
+  // &(*structPtr).pointerMember
+  // in that the apparent dereference in the base expression does not
+  // actually happen.
+  CheckAddressOfNoDeref(E->getBase());
+}
+  } else if (E->isArrow()) {
 if (const auto *Ptr = dyn_cast(
 E->getBase()->getType().getDesugaredType(Context))) {
   if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))

diff  --git a/clang/test/Frontend/noderef.c b/clang/test/Frontend/noderef.c
index 3388f2a39992..b548ffa13273 100644
--- a/clang/test/Frontend/noderef.c
+++ b/clang/test/Frontend/noderef.c
@@ -73,6 +73,7 @@ int test() {
   // Nested struct access
   struct S2 NODEREF *s2_noderef;// expected-note 5 {{s2_noderef declared 
here}}
   p = s2_noderef->a;  // ok since result is an array in a struct
+  p = (*s2_noderef).a; // ok since result is an array in a struct
   p = s2_noderef->a2; // ok
   p = s2_noderef->b;  // expected-warning{{dereferencing s2_noderef; was 
declared with a 'noderef' type}}
   p = s2_noderef->b2; // expected-warning{{dereferencing s2_noderef; was 
declared with a 'noderef' type}}



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


[clang] 1e91803 - Recommit "[clang][Fuchsia] Add relative-vtables multilib"

2020-12-01 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-12-01T17:03:13-08:00
New Revision: 1e91803c671a105f1eabce0e496766b512242f1d

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

LOG: Recommit "[clang][Fuchsia] Add relative-vtables multilib"

This recommits fdbd84c6c819d4462546961f6086c1524d5d5ae8 whose initial
build issues were fixed in 19bdc8e5a307f6eb209d4f91620d70bd2f80219e.

Added: 

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables/libc++.so

Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 6e9ae85e7318..74c393fa7a8b 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -211,14 +211,24 @@ if(FUCHSIA_SDK)
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
 
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
+set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
+
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT
 OFF CACHE BOOL "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS
 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS}
 -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}-unknown-fuchsia")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;asan+noexcept" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;asan+noexcept;relative-vtables;relative-vtables+noexcept" CACHE 
STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 79d3a8d554de..29ad3f0dbf80 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -210,6 +210,13 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
+  // Use the relative vtables ABI.
+  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
+  .flag("+fexperimental-relative-c++-abi-vtables"));
+  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
+  .flag("+fexperimental-relative-c++-abi-vtables")
+  .flag("-fexceptions")
+  .flag("+fno-exceptions"));
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
 return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
@@ -222,6 +229,13 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, 
true),
   "fexceptions", Flags);
   addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", 
Flags);
+
+  addMultilibFlag(
+  Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
+   

[clang] 7bc944c - Revert "[clang][Fuchsia] Add relative-vtables multilib"

2020-11-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-11-30T19:21:35-08:00
New Revision: 7bc944c102c2bdb009da4fe7d53dda15ea19ee71

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

LOG: Revert "[clang][Fuchsia] Add relative-vtables multilib"

This reverts commit fdbd84c6c819d4462546961f6086c1524d5d5ae8.

Reverting due to failing CI builders for Fuchsia's toolchain:
https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-x64/b8862150211240186992?

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp

Removed: 

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables/libc++.so



diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 74c393fa7a8b..6e9ae85e7318 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -211,24 +211,14 @@ if(FUCHSIA_SDK)
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
 
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS
 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS}
 -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}-unknown-fuchsia")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;asan+noexcept;relative-vtables;relative-vtables+noexcept" CACHE 
STRING "")
+  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;asan+noexcept" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 29ad3f0dbf80..79d3a8d554de 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -210,13 +210,6 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
-  // Use the relative vtables ABI.
-  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
-  .flag("+fexperimental-relative-c++-abi-vtables"));
-  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
-  .flag("+fexperimental-relative-c++-abi-vtables")
-  .flag("-fexceptions")
-  .flag("+fno-exceptions"));
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
 return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
@@ -229,13 +222,6 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, 
true),
   "fexceptions", Flags);
   addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", 
Flags);
-
-  addMultilibFlag(
-  

[clang] fdbd84c - [clang][Fuchsia] Add relative-vtables multilib

2020-11-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-11-30T18:21:10-08:00
New Revision: fdbd84c6c819d4462546961f6086c1524d5d5ae8

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

LOG: [clang][Fuchsia] Add relative-vtables multilib

This adds multilibs for Fuchsia that is built with the relative vtables ABI,
one with and another without exceptions.

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

Added: 

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables/libc++.so

Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 6e9ae85e7318..74c393fa7a8b 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -211,14 +211,24 @@ if(FUCHSIA_SDK)
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
 
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
+set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
+
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT
 OFF CACHE BOOL "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS
 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS}
 -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}-unknown-fuchsia")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;asan+noexcept" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;asan+noexcept;relative-vtables;relative-vtables+noexcept" CACHE 
STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 79d3a8d554de..29ad3f0dbf80 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -210,6 +210,13 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
+  // Use the relative vtables ABI.
+  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
+  .flag("+fexperimental-relative-c++-abi-vtables"));
+  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
+  .flag("+fexperimental-relative-c++-abi-vtables")
+  .flag("-fexceptions")
+  .flag("+fno-exceptions"));
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
 return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
@@ -222,6 +229,13 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, 
true),
   "fexceptions", Flags);
   addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", 
Flags);
+
+  addMultilibFlag(
+  Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
+   

[clang] a160189 - Revert "[clang][Fuchsia] Add relative-vtables multilib"

2020-11-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-11-30T18:20:01-08:00
New Revision: a160189c5dfaa6b3d7c3db71991e50eebea9a63d

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

LOG: Revert "[clang][Fuchsia] Add relative-vtables multilib"

This reverts commit 7c2bc3b71dc072987d43a2a86609871bd01f981f.

Forgot to add the ifferential revision.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp

Removed: 

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables/libc++.so



diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 74c393fa7a8b..6e9ae85e7318 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -211,24 +211,14 @@ if(FUCHSIA_SDK)
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
 
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS
 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS}
 -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}-unknown-fuchsia")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;asan+noexcept;relative-vtables;relative-vtables+noexcept" CACHE 
STRING "")
+  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;asan+noexcept" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 29ad3f0dbf80..79d3a8d554de 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -210,13 +210,6 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
-  // Use the relative vtables ABI.
-  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
-  .flag("+fexperimental-relative-c++-abi-vtables"));
-  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
-  .flag("+fexperimental-relative-c++-abi-vtables")
-  .flag("-fexceptions")
-  .flag("+fno-exceptions"));
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
 return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
@@ -229,13 +222,6 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, 
true),
   "fexceptions", Flags);
   addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", 
Flags);
-
-  addMultilibFlag(
-  Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
-   options::OPT_fno_experimental_relative_cxx_abi_vtables,
-   

[clang] 7c2bc3b - [clang][Fuchsia] Add relative-vtables multilib

2020-11-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-11-30T18:17:38-08:00
New Revision: 7c2bc3b71dc072987d43a2a86609871bd01f981f

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

LOG: [clang][Fuchsia] Add relative-vtables multilib

This adds a multilib for Fuchsia that is built with the relative vtables
ABI.

Added: 

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables/libc++.so

Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 6e9ae85e7318..74c393fa7a8b 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -211,14 +211,24 @@ if(FUCHSIA_SDK)
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
 
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
+set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
+
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT
 OFF CACHE BOOL "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS
 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS}
 -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}-unknown-fuchsia")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;asan+noexcept" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;asan+noexcept;relative-vtables;relative-vtables+noexcept" CACHE 
STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 79d3a8d554de..29ad3f0dbf80 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -210,6 +210,13 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
+  // Use the relative vtables ABI.
+  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
+  .flag("+fexperimental-relative-c++-abi-vtables"));
+  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
+  .flag("+fexperimental-relative-c++-abi-vtables")
+  .flag("-fexceptions")
+  .flag("+fno-exceptions"));
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
 return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
@@ -222,6 +229,13 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, 
true),
   "fexceptions", Flags);
   addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", 
Flags);
+
+  addMultilibFlag(
+  Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
+   options::OPT_fno_experimental_relative_cxx_abi_vtables,
+   /*default=*/false),
+  

[clang] cf8ff75 - [clang][RelativeVTablesABI] Use dso_local_equivalent rather than emitting stubs

2020-11-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-11-30T16:02:35-08:00
New Revision: cf8ff75bade763b054476321dcb82dcb2e7744c7

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

LOG: [clang][RelativeVTablesABI] Use dso_local_equivalent rather than emitting 
stubs

Thanks to D77248, we can bypass the use of stubs altogether and use PLT
relocations if they are available for the target. LLVM and LLD support the
R_AARCH64_PLT32 relocation, so we can also guarantee a static PLT relocation on 
AArch64.
Not emitting these stubs saves a lot of extra binary size.

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

Added: 


Modified: 
clang/lib/CodeGen/CGVTables.cpp

clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-1.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-2.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/diamond-inheritance.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/inheritted-virtual-function.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/inline-virtual-function.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/override-pure-virtual-method.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/overriden-virtual-function.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-flag.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp

Removed: 
clang/test/CodeGenCXX/RelativeVTablesABI/no-stub-when-dso-local.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/pass-byval-attributes.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp



diff  --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 75afc860cc47..bef9a293b7ed 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -641,7 +641,7 @@ void 
CodeGenVTables::addRelativeComponent(ConstantArrayBuilder ,
 
   llvm::Constant *target;
   if (auto *func = dyn_cast(globalVal)) {
-target = getOrCreateRelativeStub(func, stubLinkage, isCompleteDtor);
+target = llvm::DSOLocalEquivalent::get(func);
   } else {
 llvm::SmallString<16> rttiProxyName(globalVal->getName());
 rttiProxyName.append(".rtti_proxy");
@@ -669,74 +669,6 @@ void 
CodeGenVTables::addRelativeComponent(ConstantArrayBuilder ,
   /*position=*/vtableAddressPoint);
 }
 
-llvm::Function *CodeGenVTables::getOrCreateRelativeStub(
-llvm::Function *func, llvm::GlobalValue::LinkageTypes stubLinkage,
-bool isCompleteDtor) const {
-  // A complete object destructor can later be substituted in the vtable for an
-  // appropriate base object destructor when optimizations are enabled. This 
can
-  // happen for child classes that don't have their own destructor. In the case
-  // where a parent virtual destructor is not guaranteed to be in the same
-  // linkage unit as the child vtable, it's possible for an external reference
-  // for this destructor to be substituted into the child vtable, preventing it
-  // from being in rodata. If this function is a complete virtual destructor, 
we
-  // can just force a stub to be emitted for it.
-  if (func->isDSOLocal() && !isCompleteDtor)
-return func;
-
-  llvm::SmallString<16> stubName(func->getName());
-  stubName.append(".stub");
-
-  // Instead of taking the offset between the vtable and virtual function
-  // directly, we emit a dso_local stub that just contains a tail call to the
-  // original virtual function and take the offset between that and the
-  // vtable. We do this because there are some cases where the original
-  // function that would've been inserted into the vtable is not dso_local
-  // which may require some kind of dynamic relocation which prevents the
-  // vtable from being readonly. On x86_64, taking the offset between the
-  // function and the vtable gets lowered to the offset between the PLT entry
-  // for the function and the vtable which gives us a PLT32 reloc. On AArch64,
-  // right now only CALL26 and JUMP26 instructions generate PLT relocations,
-  // so we manifest them with stubs that are just jumps to the original
-  // function.
-  auto  = CGM.getModule();
-  llvm::Function *stub = module.getFunction(stubName);
-  if (stub) {
-

[clang] 79829a4 - Revert "[clang] Add -fc++-abi= flag for specifying which C++ ABI to use"

2020-10-15 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-10-15T14:24:38-07:00
New Revision: 79829a47040512fe54001db839ac59146ca55aec

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

LOG: Revert "[clang] Add -fc++-abi= flag for specifying which C++ ABI to use"

This reverts commits 683b308c07bf827255fe1403056413f790e03729 and
8487bfd4e9ae186f9f588ef989d27a96cc2438c9.

We will go for a more restricted approach that does not give freedom to
everyone to change ABIs on whichever platform.

See the discussion on https://reviews.llvm.org/D85802.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/TargetCXXABI.h
clang/include/clang/Driver/Options.td
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 
clang/include/clang/Basic/TargetCXXABI.def
clang/test/Frontend/invalid-cxx-abi.cpp



diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index e5c80866a0a9..3f4079e2569b 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -39,7 +39,6 @@
 #include "clang/Basic/SanitizerBlacklist.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
-#include "clang/Basic/TargetCXXABI.h"
 #include "clang/Basic/XRayLists.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -698,11 +697,6 @@ class ASTContext : public RefCountedBase {
 return FullSourceLoc(Loc,SourceMgr);
   }
 
-  /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
-  /// at compile time with `-fc++-abi=`. If this is not provided, we instead 
use
-  /// the default ABI set by the target.
-  TargetCXXABI::Kind getCXXABIKind() const;
-
   /// All comments in this translation unit.
   RawCommentList Comments;
 

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index d87983ef5249..29bc19e5a84e 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -524,6 +524,4 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE 
setting %0 is not recognize
 
 def err_drv_invalid_sve_vector_bits : Error<
   "'-msve-vector-bits' is not supported without SVE enabled">;
-
-def err_invalid_cxx_abi : Error<"invalid C++ ABI name '%0'">;
 }

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 147fab614308..84d25c359c55 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -18,7 +18,6 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Sanitizers.h"
-#include "clang/Basic/TargetCXXABI.h"
 #include "clang/Basic/Visibility.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/StringRef.h"
@@ -295,10 +294,6 @@ class LangOptions : public LangOptionsBase {
   /// host code generation.
   std::string OMPHostIRFile;
 
-  /// C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
-  /// This overrides the default ABI used by the target.
-  llvm::Optional CXXABI;
-
   /// Indicates whether the front-end is explicitly told that the
   /// input is a header file (i.e. -x c-header).
   bool IsHeaderFile = false;

diff  --git a/clang/include/clang/Basic/TargetCXXABI.def 
b/clang/include/clang/Basic/TargetCXXABI.def
deleted file mode 100644
index 0ae0bb555f60..
--- a/clang/include/clang/Basic/TargetCXXABI.def
+++ /dev/null
@@ -1,129 +0,0 @@
-//===--- TargetCXXABI.def - Target C++ ABI database --- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This file defines the various C++ ABI kinds used on 
diff erent platforms.
-// Users of this file must define the CXXABI macro to make use of this
-// information.
-//
-//===--===//
-
-#ifndef CXXABI
-#error Define the CXXABI macro to handle C++ ABI kinds.
-#endif
-
-#ifndef ITANIUM_CXXABI
-#define ITANIUM_CXXABI(Name, Str) CXXABI(Name, Str)
-#endif
-
-#ifndef MICROSOFT_CXXABI
-#define MICROSOFT_CXXABI(Name, Str) CXXABI(Name, Str)
-#endif
-
-/// The generic Itanium ABI is the standard ABI of most open-source
-/// and Unix-like platforms.  It is the primary 

Re: [clang] 683b308 - [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2020-10-14 Thread Leonard Chan via cfe-commits
Updated with 8487bfd4e9ae186f9f588ef989d27a96cc2438c9

On Wed, Oct 14, 2020 at 1:53 PM Richard Smith  wrote:

> On Wed, 14 Oct 2020 at 12:31, Leonard Chan via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Leonard Chan
>> Date: 2020-10-14T12:31:21-07:00
>> New Revision: 683b308c07bf827255fe1403056413f790e03729
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/683b308c07bf827255fe1403056413f790e03729
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/683b308c07bf827255fe1403056413f790e03729.diff
>>
>> LOG: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use
>>
>> This implements the flag proposed in RFC
>> http://lists.llvm.org/pipermail/cfe-dev/2020-August/066437.html.
>>
>> The goal is to add a way to override the default target C++ ABI through
>> a compiler flag. This makes it easier to test and transition between
>> different
>> C++ ABIs through compile flags rather than build flags.
>>
>> In this patch:
>> - Store `-fc++-abi=` in a LangOpt. This isn't stored in a
>>   CodeGenOpt because there are instances outside of codegen where Clang
>>   needs to know what the ABI is (particularly through
>>   ASTContext::createCXXABI), and we should be able to override the
>>   target default if the flag is provided at that point.
>> - Expose the existing ABIs in TargetCXXABI as values that can be passed
>>   through this flag.
>>   - Create a .def file for these ABIs to make it easier to check flag
>> values.
>>   - Add an error for diagnosing bad ABI flag values.
>>
>> Differential Revision: https://reviews.llvm.org/D85802
>>
>> Added:
>> clang/include/clang/Basic/TargetCXXABI.def
>> clang/test/Frontend/invalid-cxx-abi.cpp
>>
>> Modified:
>> clang/include/clang/AST/ASTContext.h
>> clang/include/clang/Basic/DiagnosticDriverKinds.td
>> clang/include/clang/Basic/LangOptions.h
>> clang/include/clang/Basic/TargetCXXABI.h
>> clang/include/clang/Driver/Options.td
>> clang/lib/AST/ASTContext.cpp
>> clang/lib/CodeGen/CodeGenModule.cpp
>> clang/lib/CodeGen/ItaniumCXXABI.cpp
>> clang/lib/Driver/ToolChains/Clang.cpp
>> clang/lib/Frontend/CompilerInvocation.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/include/clang/AST/ASTContext.h
>> b/clang/include/clang/AST/ASTContext.h
>> index 3f4079e2569b..e5c80866a0a9 100644
>> --- a/clang/include/clang/AST/ASTContext.h
>> +++ b/clang/include/clang/AST/ASTContext.h
>> @@ -39,6 +39,7 @@
>>  #include "clang/Basic/SanitizerBlacklist.h"
>>  #include "clang/Basic/SourceLocation.h"
>>  #include "clang/Basic/Specifiers.h"
>> +#include "clang/Basic/TargetCXXABI.h"
>>  #include "clang/Basic/XRayLists.h"
>>  #include "llvm/ADT/APSInt.h"
>>  #include "llvm/ADT/ArrayRef.h"
>> @@ -697,6 +698,11 @@ class ASTContext : public RefCountedBase
>> {
>>  return FullSourceLoc(Loc,SourceMgr);
>>}
>>
>> +  /// Return the C++ ABI kind that should be used. The C++ ABI can be
>> overriden
>> +  /// at compile time with `-fc++-abi=`. If this is not provided, we
>> instead use
>> +  /// the default ABI set by the target.
>> +  TargetCXXABI::Kind getCXXABIKind() const;
>> +
>>/// All comments in this translation unit.
>>RawCommentList Comments;
>>
>>
>> diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td
>> b/clang/include/clang/Basic/DiagnosticDriverKinds.td
>> index 29bc19e5a84e..f1b3d4d9087e 100644
>> --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
>> +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
>> @@ -524,4 +524,6 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE
>> setting %0 is not recognize
>>
>>  def err_drv_invalid_sve_vector_bits : Error<
>>"'-msve-vector-bits' is not supported without SVE enabled">;
>> +
>> +def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">;
>>
>
> Diagnostics should start with a lowercase letter.
>
>
>>  }
>>
>> diff  --git a/clang/include/clang/Basic/LangOptions.h
>> b/clang/include/clang/Basic/LangOptions.h
>> index 84d25c359c55..147fab614308 100644
>> --- a/clang/include/clang/Basic/LangOptions.h
>> +++ b/clang/include/clang/Basic/LangOptions.h
>> @@ -18,6 +18,7

[clang] 8487bfd - [clang][NFC] Change diagnostic to start with lowercase letter

2020-10-14 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-10-14T15:48:29-07:00
New Revision: 8487bfd4e9ae186f9f588ef989d27a96cc2438c9

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

LOG: [clang][NFC] Change diagnostic to start with lowercase letter

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/test/Frontend/invalid-cxx-abi.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index f1b3d4d9087e..d87983ef5249 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -525,5 +525,5 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE 
setting %0 is not recognize
 def err_drv_invalid_sve_vector_bits : Error<
   "'-msve-vector-bits' is not supported without SVE enabled">;
 
-def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">;
+def err_invalid_cxx_abi : Error<"invalid C++ ABI name '%0'">;
 }

diff  --git a/clang/test/Frontend/invalid-cxx-abi.cpp 
b/clang/test/Frontend/invalid-cxx-abi.cpp
index 20c6d7bde22c..02a5f3a4e368 100644
--- a/clang/test/Frontend/invalid-cxx-abi.cpp
+++ b/clang/test/Frontend/invalid-cxx-abi.cpp
@@ -12,5 +12,5 @@
 
 // RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
 // RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
-// INVALID: error: Invalid C++ ABI name 'InvalidABI'
-// CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
+// INVALID: error: invalid C++ ABI name 'InvalidABI'
+// CASE-SENSITIVE: error: invalid C++ ABI name 'Fuchsia'



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


[clang] 683b308 - [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2020-10-14 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-10-14T12:31:21-07:00
New Revision: 683b308c07bf827255fe1403056413f790e03729

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

LOG: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

This implements the flag proposed in RFC 
http://lists.llvm.org/pipermail/cfe-dev/2020-August/066437.html.

The goal is to add a way to override the default target C++ ABI through
a compiler flag. This makes it easier to test and transition between different
C++ ABIs through compile flags rather than build flags.

In this patch:
- Store `-fc++-abi=` in a LangOpt. This isn't stored in a
  CodeGenOpt because there are instances outside of codegen where Clang
  needs to know what the ABI is (particularly through
  ASTContext::createCXXABI), and we should be able to override the
  target default if the flag is provided at that point.
- Expose the existing ABIs in TargetCXXABI as values that can be passed
  through this flag.
  - Create a .def file for these ABIs to make it easier to check flag
values.
  - Add an error for diagnosing bad ABI flag values.

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

Added: 
clang/include/clang/Basic/TargetCXXABI.def
clang/test/Frontend/invalid-cxx-abi.cpp

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/TargetCXXABI.h
clang/include/clang/Driver/Options.td
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 3f4079e2569b..e5c80866a0a9 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -39,6 +39,7 @@
 #include "clang/Basic/SanitizerBlacklist.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
+#include "clang/Basic/TargetCXXABI.h"
 #include "clang/Basic/XRayLists.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -697,6 +698,11 @@ class ASTContext : public RefCountedBase {
 return FullSourceLoc(Loc,SourceMgr);
   }
 
+  /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
+  /// at compile time with `-fc++-abi=`. If this is not provided, we instead 
use
+  /// the default ABI set by the target.
+  TargetCXXABI::Kind getCXXABIKind() const;
+
   /// All comments in this translation unit.
   RawCommentList Comments;
 

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 29bc19e5a84e..f1b3d4d9087e 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -524,4 +524,6 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE 
setting %0 is not recognize
 
 def err_drv_invalid_sve_vector_bits : Error<
   "'-msve-vector-bits' is not supported without SVE enabled">;
+
+def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">;
 }

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 84d25c359c55..147fab614308 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -18,6 +18,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Sanitizers.h"
+#include "clang/Basic/TargetCXXABI.h"
 #include "clang/Basic/Visibility.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/StringRef.h"
@@ -294,6 +295,10 @@ class LangOptions : public LangOptionsBase {
   /// host code generation.
   std::string OMPHostIRFile;
 
+  /// C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
+  /// This overrides the default ABI used by the target.
+  llvm::Optional CXXABI;
+
   /// Indicates whether the front-end is explicitly told that the
   /// input is a header file (i.e. -x c-header).
   bool IsHeaderFile = false;

diff  --git a/clang/include/clang/Basic/TargetCXXABI.def 
b/clang/include/clang/Basic/TargetCXXABI.def
new file mode 100644
index ..0ae0bb555f60
--- /dev/null
+++ b/clang/include/clang/Basic/TargetCXXABI.def
@@ -0,0 +1,129 @@
+//===--- TargetCXXABI.def - Target C++ ABI database --- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This 

[clang] 64c0792 - [clang][feature] Add cxx_abi_relative_vtable feature

2020-10-08 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-10-08T10:30:54-07:00
New Revision: 64c0792946b792839b2f39e4e208fdd7398aaea0

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

LOG: [clang][feature] Add cxx_abi_relative_vtable feature

This will be enabled if relative vtables is enabled.

Differential revision: https://reviews.llvm.org/D85924

Added: 
clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp

Modified: 
clang/include/clang/Basic/Features.def

Removed: 




diff  --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index 999bcb7e2e29..302c56763c39 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -256,5 +256,7 @@ EXTENSION(gnu_asm, LangOpts.GNUAsm)
 EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm)
 EXTENSION(matrix_types, LangOpts.MatrixTypes)
 
+FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && 
LangOpts.RelativeCXXABIVTables)
+
 #undef EXTENSION
 #undef FEATURE

diff  --git a/clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp 
b/clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp
new file mode 100644
index ..d0f0c27b09d3
--- /dev/null
+++ b/clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ -o - | FileCheck %s 
--check-prefix=NO-RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ 
-fexperimental-relative-c++-abi-vtables -o - | FileCheck %s 
--check-prefix=RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ 
-fno-experimental-relative-c++-abi-vtables -o - | FileCheck %s 
--check-prefix=NO-RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c 
-fexperimental-relative-c++-abi-vtables -o - | FileCheck %s 
--check-prefix=NO-RELATIVE-VTABLE
+
+#if __has_feature(cxx_abi_relative_vtable)
+int has_relative_vtable();
+#else
+int has_no_relative_vtable();
+#endif
+
+// RELATIVE-VTABLE: has_relative_vtable
+// NO-RELATIVE-VTABLE: has_no_relative_vtable



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


Re: [PATCH] D87822: [FPEnv] Evaluate constant expressions under non-default rounding modes

2020-09-29 Thread Leonard Chan via cfe-commits
Thanks for looking into it. We have that commit but it still seems to be
failing for us with the same error.

On Tue, Sep 29, 2020 at 12:58 AM Serge Pavlov  wrote:

> Hi!
>
> This issue must be fixed by: https://reviews.llvm.org/rGf91b9c0f9858
> Do you have recent changes from the trunk?
>
> Thanks,
> --Serge
>
>
> On Tue, Sep 29, 2020 at 4:22 AM Leonard Chan via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> leonardchan added a comment.
>>
>> Hi! It looks like this is causing a test failure on our aach64 builders (
>> https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-arm64/b8868095822628984976?
>> ):
>>
>>   [1113/1114] Running the Clang regression tests
>>   llvm-lit:
>> /b/s/w/ir/k/staging/llvm_build/bin/../../../llvm-project/llvm/utils/lit/lit/llvm/config.py:379:
>> note: using clang: /b/s/w/ir/k/staging/llvm_build/bin/clang
>>   -- Testing: 26708 tests, 256 workers --
>>   Testing:
>>   FAIL: Clang :: AST/const-fpfeatures-diag.c (269 of 26708)
>>    TEST 'Clang :: AST/const-fpfeatures-diag.c' FAILED
>> 
>>   Script:
>>   --
>>   : 'RUN: at line 1';   /b/s/w/ir/k/staging/llvm_build/bin/clang -cc1
>> -internal-isystem /b/s/w/ir/k/staging/llvm_build/lib/clang/12.0.0/include
>> -nostdsysteminc -verify -ffp-exception-behavior=strict -Wno-unknown-pragmas
>> /b/s/w/ir/k/llvm-project/clang/test/AST/const-fpfeatures-diag.c
>>   --
>>   Exit Code: 1
>>
>>   Command Output (stderr):
>>   --
>>   error: 'error' diagnostics expected but not seen:
>> File /b/s/w/ir/k/llvm-project/clang/test/AST/const-fpfeatures-diag.c
>> Line 8: initializer element is not a compile-time constant
>>   error: 'warning' diagnostics seen but not expected:
>> (frontend): overriding currently unsupported use of floating point
>> exceptions on this target
>>   2 errors generated.
>>
>>   --
>>
>>   
>>   Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
>>   
>>   Failed Tests (1):
>> Clang :: AST/const-fpfeatures-diag.c
>>
>> Would you mind taking a look and sending out a fix? Thanks.
>>
>>
>> Repository:
>>   rG LLVM Github Monorepo
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D87822/new/
>>
>> https://reviews.llvm.org/D87822
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 15d94a7 - Revert "Canonicalize declaration pointers when forming APValues."

2020-09-22 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-09-22T17:40:53-07:00
New Revision: 15d94a7d0f8f0d6b3b5308fff51b286957e45650

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

LOG: Revert "Canonicalize declaration pointers when forming APValues."

This reverts commit 905b9ca26c94fa86339451a528cedde5004fc1bb.

Reverting because this strips `weak` attributes off function
declarations, leading to the linker error we see at
https://ci.chromium.org/p/fuchsia/builders/ci/clang_toolchain.fuchsia-arm64-debug-subbuild/b8868932035091473008.

See https://reviews.llvm.org/rG905b9ca26c94 for reproducer details.

Added: 


Modified: 
clang/include/clang/AST/APValue.h
clang/lib/AST/APValue.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/AST/ExprConstant.cpp
clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
clang/test/OpenMP/ordered_messages.cpp

Removed: 




diff  --git a/clang/include/clang/AST/APValue.h 
b/clang/include/clang/AST/APValue.h
index 6307f8a92e5a..5103cfa8604e 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -174,7 +174,6 @@ class APValue {
   return !(LHS == RHS);
 }
 friend llvm::hash_code hash_value(const LValueBase );
-friend struct llvm::DenseMapInfo;
 
   private:
 PtrTy Ptr;
@@ -202,7 +201,8 @@ class APValue {
 
   public:
 LValuePathEntry() : Value() {}
-LValuePathEntry(BaseOrMemberType BaseOrMember);
+LValuePathEntry(BaseOrMemberType BaseOrMember)
+: Value{reinterpret_cast(BaseOrMember.getOpaqueValue())} {}
 static LValuePathEntry ArrayIndex(uint64_t Index) {
   LValuePathEntry Result;
   Result.Value = Index;

diff  --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index 32d3ff7ce1d0..08ae0ff3c67d 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -38,7 +38,7 @@ static_assert(
 "Type is insufficiently aligned");
 
 APValue::LValueBase::LValueBase(const ValueDecl *P, unsigned I, unsigned V)
-: Ptr(P ? cast(P->getCanonicalDecl()) : nullptr), Local{I, V} {}
+: Ptr(P), Local{I, V} {}
 APValue::LValueBase::LValueBase(const Expr *P, unsigned I, unsigned V)
 : Ptr(P), Local{I, V} {}
 
@@ -82,19 +82,13 @@ bool operator==(const APValue::LValueBase ,
 const APValue::LValueBase ) {
   if (LHS.Ptr != RHS.Ptr)
 return false;
-  if (LHS.is() || LHS.is())
+  if (LHS.is())
 return true;
   return LHS.Local.CallIndex == RHS.Local.CallIndex &&
  LHS.Local.Version == RHS.Local.Version;
 }
 }
 
-APValue::LValuePathEntry::LValuePathEntry(BaseOrMemberType BaseOrMember) {
-  if (const Decl *D = BaseOrMember.getPointer())
-BaseOrMember.setPointer(D->getCanonicalDecl());
-  Value = reinterpret_cast(BaseOrMember.getOpaqueValue());
-}
-
 namespace {
   struct LVBase {
 APValue::LValueBase Base;
@@ -119,16 +113,14 @@ APValue::LValueBase::operator bool () const {
 
 clang::APValue::LValueBase
 llvm::DenseMapInfo::getEmptyKey() {
-  clang::APValue::LValueBase B;
-  B.Ptr = DenseMapInfo::getEmptyKey();
-  return B;
+  return clang::APValue::LValueBase(
+  DenseMapInfo::getEmptyKey());
 }
 
 clang::APValue::LValueBase
 llvm::DenseMapInfo::getTombstoneKey() {
-  clang::APValue::LValueBase B;
-  B.Ptr = DenseMapInfo::getTombstoneKey();
-  return B;
+  return clang::APValue::LValueBase(
+  DenseMapInfo::getTombstoneKey());
 }
 
 namespace clang {
@@ -781,10 +773,8 @@ void APValue::MakeMemberPointer(const ValueDecl *Member, 
bool IsDerivedMember,
   assert(isAbsent() && "Bad state change");
   MemberPointerData *MPD = new ((void*)(char*)Data.buffer) MemberPointerData;
   Kind = MemberPointer;
-  MPD->MemberAndIsDerivedMember.setPointer(
-  Member ? cast(Member->getCanonicalDecl()) : nullptr);
+  MPD->MemberAndIsDerivedMember.setPointer(Member);
   MPD->MemberAndIsDerivedMember.setInt(IsDerivedMember);
   MPD->resizePath(Path.size());
-  for (unsigned I = 0; I != Path.size(); ++I)
-MPD->getPath()[I] = Path[I]->getCanonicalDecl();
+  memcpy(MPD->getPath(), Path.data(), Path.size()*sizeof(const 
CXXRecordDecl*));
 }

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index ae38e3dd2a72..0ee1399d42df 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -4686,7 +4686,7 @@ char *Buffer = new (getASTContext(), 1) char[Name.size() 
+ 1];
 void ValueDecl::anchor() {}
 
 bool ValueDecl::isWeak() const {
-  for (const auto *I : getMostRecentDecl()->attrs())
+  for (const auto *I : attrs())
 if (isa(I) || isa(I))
   return true;
 

diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index ab2b55c0762e..f4314d0bd961 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -720,7 +720,7 @@ bool Decl::isWeakImported() const {
 

[clang] de172dd - [clang][RelativeVTablesABI] Update CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp

2020-06-29 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-06-29T13:06:42-07:00
New Revision: de172dd17f0334e1fcbbf28a33d0ea24f7cbff1a

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

LOG: [clang][RelativeVTablesABI] Update 
CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp

After c7bcd431d9c4bfeb631a3599f1d628603e6351d6, this test started failing when
running with the new pass manager. One of the CHECKs in this file checks how the
vtable is loaded for a void cast, which involves taking 2 bitcasts from the 
pointer
to the original object. The order of these bitcasts changes under the new PM.
The order doesn't matter, so this relaxes the CHECKs.

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

Added: 


Modified: 
clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp 
b/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
index 56b56a1b9398..62d674669661 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
@@ -35,13 +35,13 @@
 // CHECK-NEXT:   [[isnull:%[0-9]+]] = icmp eq %class.B* %b, null
 // CHECK-NEXT:   br i1 [[isnull]], label %[[dynamic_cast_end:[a-z0-9._]+]], 
label %[[dynamic_cast_notnull:[a-z0-9._]+]]
 // CHECK:  [[dynamic_cast_notnull]]:
-// CHECK-NEXT:   [[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
-// CHECK-NEXT:   [[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
-// CHECK-NEXT:   [[offset_ptr:%.+]] = getelementptr inbounds i32, i32* 
[[vtable]], i64 -2
-// CHECK-NEXT:   [[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
-// CHECK-NEXT:   [[b:%[0-9]+]] = bitcast %class.B* %b to i8*
-// CHECK-NEXT:   [[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
-// CHECK-NEXT:   [[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 
[[offset_to_top2]]
+// CHECK-DAG:[[b2:%[0-9]+]] = bitcast %class.B* %b to i32**
+// CHECK-DAG:[[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8
+// CHECK-DAG:[[offset_ptr:%.+]] = getelementptr inbounds i32, i32* 
[[vtable]], i64 -2
+// CHECK-DAG:[[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4
+// CHECK-DAG:[[b:%[0-9]+]] = bitcast %class.B* %b to i8*
+// CHECK-DAG:[[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64
+// CHECK-DAG:[[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 
[[offset_to_top2]]
 // CHECK-NEXT:   br label %[[dynamic_cast_end]]
 // CHECK:  [[dynamic_cast_end]]:
 // CHECK-NEXT:   [[res:%[0-9]+]] = phi i8* [ [[casted]], 
%[[dynamic_cast_notnull]] ], [ null, %entry ]



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


[clang] 2f6bb2a - [clang][Attribute] Fix noderef attribute false-negatives

2020-06-10 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-06-10T12:20:54-07:00
New Revision: 2f6bb2a69215f9cae883da12f8f596d3f80f8d71

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

LOG: [clang][Attribute] Fix noderef attribute false-negatives

`noderef` was failing to trigger warnings in some cases related to c++ style
casting. This patch addresses them.

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

Added: 


Modified: 
clang/include/clang/Sema/Initialization.h
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaInit.cpp
clang/test/Frontend/noderef.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index d50ec2addc8f..ca9e0a198cb9 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -689,6 +689,9 @@ class InitializationKind {
 return Context >= IC_StaticCast;
   }
 
+  /// Determine whether this initialization is a static cast.
+  bool isStaticCast() const { return Context == IC_StaticCast; }
+
   /// Determine whether this initialization is a C-style cast.
   bool isCStyleOrFunctionalCast() const {
 return Context >= IC_CStyleCast;

diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index f483f7315aec..2efe26052c78 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -161,6 +161,30 @@ namespace {
   PlaceholderKind = (BuiltinType::Kind) 0;
 }
   };
+
+  void CheckNoDeref(Sema , const QualType FromType, const QualType ToType,
+SourceLocation OpLoc) {
+if (const auto *PtrType = dyn_cast(FromType)) {
+  if (PtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
+if (const auto *DestType = dyn_cast(ToType)) {
+  if (!DestType->getPointeeType()->hasAttr(attr::NoDeref)) {
+S.Diag(OpLoc, diag::warn_noderef_to_dereferenceable_pointer);
+  }
+}
+  }
+}
+  }
+
+  struct CheckNoDerefRAII {
+CheckNoDerefRAII(CastOperation ) : Op(Op) {}
+~CheckNoDerefRAII() {
+  if (!Op.SrcExpr.isInvalid())
+CheckNoDeref(Op.Self, Op.SrcExpr.get()->getType(), Op.ResultType,
+ Op.OpRange.getBegin());
+}
+
+CastOperation 
+  };
 }
 
 static void DiagnoseCastQual(Sema , const ExprResult ,
@@ -723,6 +747,8 @@ static TryCastResult 
getCastAwayConstnessCastKind(CastAwayConstnessKind CACK,
 /// Refer to C++ 5.2.7 for details. Dynamic casts are used mostly for runtime-
 /// checked downcasts in class hierarchies.
 void CastOperation::CheckDynamicCast() {
+  CheckNoDerefRAII NoderefCheck(*this);
+
   if (ValueKind == VK_RValue)
 SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
   else if (isPlaceholder())
@@ -876,6 +902,8 @@ void CastOperation::CheckDynamicCast() {
 /// const char *str = "literal";
 /// legacy_function(const_cast\(str));
 void CastOperation::CheckConstCast() {
+  CheckNoDerefRAII NoderefCheck(*this);
+
   if (ValueKind == VK_RValue)
 SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
   else if (isPlaceholder())
@@ -1045,6 +1073,8 @@ void CastOperation::CheckReinterpretCast() {
 /// Refer to C++ 5.2.9 for details. Static casts are mostly used for making
 /// implicit conversions explicit and getting rid of data loss warnings.
 void CastOperation::CheckStaticCast() {
+  CheckNoDerefRAII NoderefCheck(*this);
+
   if (isPlaceholder()) {
 checkNonOverloadPlaceholders();
 if (SrcExpr.isInvalid())

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 0a98cb2a5ce0..d46e7f86d6b3 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -8200,9 +8200,13 @@ ExprResult InitializationSequence::Perform(Sema ,
 if (const auto *ToPtrType = Step->Type->getAs()) {
   if (FromPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
   !ToPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
-S.Diag(CurInit.get()->getExprLoc(),
-   diag::warn_noderef_to_dereferenceable_pointer)
-<< CurInit.get()->getSourceRange();
+// Do not check static casts here because they are checked earlier
+// in Sema::ActOnCXXNamedCast()
+if (!Kind.isStaticCast()) {
+  S.Diag(CurInit.get()->getExprLoc(),
+ diag::warn_noderef_to_dereferenceable_pointer)
+  << CurInit.get()->getSourceRange();
+}
   }
 }
   }

diff  --git a/clang/test/Frontend/noderef.cpp b/clang/test/Frontend/noderef.cpp
index 15eb4e457c20..32d5ca34d1b1 100644
--- a/clang/test/Frontend/noderef.cpp
+++ b/clang/test/Frontend/noderef.cpp
@@ -80,12 +80,28 @@ class A {
   int member;
   int NODEREF *member2;

[clang] ef37444 - [Lexer] Fix invalid suffix diagnostic for fixed-point literals

2020-05-27 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-05-27T16:16:56-07:00
New Revision: ef37444058550b0f49441b994c9e9368d8e42da8

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

LOG: [Lexer] Fix invalid suffix diagnostic for fixed-point literals

Committing on behalf of nagart, who authored this patch.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Lex/LiteralSupport.h
clang/lib/Lex/LiteralSupport.cpp
clang/test/Frontend/fixed_point_errors.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index ef90bdf84c8a..fa07e9ae76c8 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -175,7 +175,7 @@ def ext_unknown_escape : ExtWarn<"unknown escape sequence 
'\\%0'">,
 def err_invalid_digit : Error<
   "invalid digit '%0' in %select{decimal|octal|binary}1 constant">;
 def err_invalid_suffix_constant : Error<
-  "invalid suffix '%0' on %select{integer|floating}1 constant">;
+  "invalid suffix '%0' on %select{integer|floating|fixed-point}1 constant">;
 def warn_cxx11_compat_digit_separator : Warning<
   "digit separators are incompatible with C++ standards before C++14">,
   InGroup, DefaultIgnore;

diff  --git a/clang/include/clang/Lex/LiteralSupport.h 
b/clang/include/clang/Lex/LiteralSupport.h
index b9d64c24a00b..6829771b2830 100644
--- a/clang/include/clang/Lex/LiteralSupport.h
+++ b/clang/include/clang/Lex/LiteralSupport.h
@@ -71,7 +71,9 @@ class NumericLiteralParser {
   bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr
   bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk
 
-  bool isFixedPointLiteral() const { return saw_fixed_point_suffix; }
+  bool isFixedPointLiteral() const {
+return (saw_period || saw_exponent) && saw_fixed_point_suffix;
+  }
 
   bool isIntegerLiteral() const {
 return !saw_period && !saw_exponent && !isFixedPointLiteral();

diff  --git a/clang/lib/Lex/LiteralSupport.cpp 
b/clang/lib/Lex/LiteralSupport.cpp
index 2b1add4d9b98..f44614b4bec4 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -583,6 +583,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
 
   // Parse the suffix.  At this point we can classify whether we have an FP or
   // integer constant.
+  bool isFixedPointConstant = isFixedPointLiteral();
   bool isFPConstant = isFloatingLiteral();
 
   // Loop over all of the characters of the suffix.  If we see something bad,
@@ -737,7 +738,8 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
   // Report an error if there are any.
   PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, SuffixBegin - ThisTokBegin),
   diag::err_invalid_suffix_constant)
-  << StringRef(SuffixBegin, ThisTokEnd - SuffixBegin) << isFPConstant;
+  << StringRef(SuffixBegin, ThisTokEnd - SuffixBegin)
+  << (isFixedPointConstant ? 2 : isFPConstant);
   hadError = true;
 }
   }

diff  --git a/clang/test/Frontend/fixed_point_errors.c 
b/clang/test/Frontend/fixed_point_errors.c
index db15bd874b31..9b600fbc2642 100644
--- a/clang/test/Frontend/fixed_point_errors.c
+++ b/clang/test/Frontend/fixed_point_errors.c
@@ -137,15 +137,15 @@ _Sat longfract_t td_sat_long_fract; // 
expected-error{{'_Sat' specifier
 _Sat longaccum_t td_sat_long_accum; // expected-error{{'_Sat' 
specifier is only valid on '_Fract' or '_Accum', not 'type-name'}}
 
 /* Bad suffixes  */
-_Accum fk = 1.0fk;// expected-error{{invalid suffix 'fk' on integer 
constant}}
-_Accum kk = 1.0kk;// expected-error{{invalid suffix 'kk' on integer 
constant}}
-_Accum rk = 1.0rk;// expected-error{{invalid suffix 'rk' on integer 
constant}}
-_Accum rk = 1.0rr;// expected-error{{invalid suffix 'rr' on integer 
constant}}
-_Accum qk = 1.0qr;// expected-error{{invalid suffix 'qr' on integer 
constant}}
+_Accum fk = 1.0fk; // expected-error{{invalid suffix 'fk' on fixed-point 
constant}}
+_Accum kk = 1.0kk; // expected-error{{invalid suffix 'kk' on fixed-point 
constant}}
+_Accum rk = 1.0rk; // expected-error{{invalid suffix 'rk' on fixed-point 
constant}}
+_Accum rk = 1.0rr; // expected-error{{invalid suffix 'rr' on fixed-point 
constant}}
+_Accum qk = 1.0qr; // expected-error{{invalid suffix 'qr' on fixed-point 
constant}}
 
 /* Using wrong exponent notation */
-_Accum dec_with_hex_exp1 = 0.1p10k;// expected-error{{invalid suffix 
'p10k' on integer constant}}
-_Accum dec_with_hex_exp2 = 0.1P10k;// expected-error{{invalid suffix 
'P10k' on integer constant}}
+_Accum dec_with_hex_exp1 = 0.1p10k;// expected-error{{invalid suffix 

[clang] 592303a - [Fuchsia] Do not enable the Z3 solver for a fuchsia toolchain

2020-05-14 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-05-14T17:03:58-07:00
New Revision: 592303a53e6bc0737c3999e91aab9ea2147f73ab

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

LOG: [Fuchsia] Do not enable the Z3 solver for a fuchsia toolchain

gLinux started shipping incompatible versions of Z3, which can lead to a
missing `z3.h` header when building the Z3 solver locally. This patch
disables the Z3 solver when building a clang toolchain for Fuchsia.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index eb2a03e164dd..4ef404b8aaef 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -17,6 +17,7 @@ set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
+set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)



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


[clang] e9802aa - Revert "Run Coverage pass before other *San passes under new pass manager"

2020-05-14 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-05-14T15:19:27-07:00
New Revision: e9802aa4221ba3857041c2328639ce2aac0ace67

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

LOG: Revert "Run Coverage pass before other *San passes under new pass manager"

This reverts commit 7d5bb94d78386e4653535c35d3e8258bf4502340.

Reverting since this leads to a linker error we're seeing on Fuchsia.
The underlying issue seems to be that inlining is run after sanitizers
and causes different comdat groups instrumented by Sancov to reference
non-key symbols defined in other comdat groups.

Will re-land this patch after a fix for that is landed.

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 7b876df852b5..33627f3a6733 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1001,15 +1001,6 @@ static void addSanitizersAtO0(ModulePassManager ,
   const Triple ,
   const LangOptions ,
   const CodeGenOptions ) {
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-MPM.addPass(ModuleSanitizerCoveragePass(
-SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
-CodeGenOpts.SanitizeCoverageBlacklistFiles));
-  }
-
   auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
 MPM.addPass(RequireAnalysisPass());
 bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
@@ -1250,17 +1241,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 EntryExitInstrumenterPass(/*PostInlining=*/false)));
   });
 
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-PB.registerPipelineStartEPCallback([&](ModulePassManager ) {
-  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-  MPM.addPass(ModuleSanitizerCoveragePass(
-  SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
-  CodeGenOpts.SanitizeCoverageBlacklistFiles));
-});
-  }
-
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out
@@ -1345,6 +1325,15 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   }
 }
 
+if (CodeGenOpts.SanitizeCoverageType ||
+CodeGenOpts.SanitizeCoverageIndirectCalls ||
+CodeGenOpts.SanitizeCoverageTraceCmp) {
+  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+  MPM.addPass(ModuleSanitizerCoveragePass(
+  SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
+  CodeGenOpts.SanitizeCoverageBlacklistFiles));
+}
+
 if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
   bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
   MPM.addPass(HWAddressSanitizerPass(



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


[libunwind] 1c70dec - [libunwind] Remove __FILE__ and __LINE__ from error reporting

2020-03-10 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-03-10T18:58:41-07:00
New Revision: 1c70dec18c7e530264cc70841cc60f385259b9e0

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

LOG: [libunwind] Remove __FILE__ and __LINE__ from error reporting

We were seeing non-deterministic binary size differences depending on which
toolchain was used to build fuchsia. This is because libunwind embeded the
FILE path into a logging macro, even for release builds, which makes the code
dependent on the build directory.

This removes the file and line number from the error message. This is
consistent with how other runtimes report error, e.g.
https://github.com/llvm/llvm-project/blob/master/libcxxabi/src/abort_message.cpp#L30.

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

Added: 


Modified: 
libunwind/src/config.h

Removed: 




diff  --git a/libunwind/src/config.h b/libunwind/src/config.h
index dcd3cef94552..5658b3210cf3 100644
--- a/libunwind/src/config.h
+++ b/libunwind/src/config.h
@@ -122,8 +122,7 @@
 #else
 #define _LIBUNWIND_ABORT(msg)  
\
   do { 
\
-fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  
\
-__LINE__, msg);
\
+fprintf(stderr, "libunwind: %s - %s\n", __func__, msg);
\
 fflush(stderr);
\
 abort();   
\
   } while (0)



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


[clang] d2cbaf1 - Fix for the test failues introduced in https://reviews.llvm.org/D74704.

2020-02-26 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-02-26T12:23:15-08:00
New Revision: d2cbaf1755ffa90300365c0d71400a5ee4ada3bd

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

LOG: Fix for the test failues introduced in https://reviews.llvm.org/D74704.

Added: 


Modified: 
clang/test/Driver/riscv32-toolchain-extra.c
clang/test/Driver/riscv64-toolchain-extra.c

Removed: 




diff  --git a/clang/test/Driver/riscv32-toolchain-extra.c 
b/clang/test/Driver/riscv32-toolchain-extra.c
index ff9842b37c02..3182e0cfc1ae 100644
--- a/clang/test/Driver/riscv32-toolchain-extra.c
+++ b/clang/test/Driver/riscv32-toolchain-extra.c
@@ -11,6 +11,7 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
+// REQUIRES: platform-linker
 // RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
 // RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/bin/clang ] || rm 
%T/testroot-riscv32-baremetal-nogcc/bin/clang
 // RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld 
] || rm %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld

diff  --git a/clang/test/Driver/riscv64-toolchain-extra.c 
b/clang/test/Driver/riscv64-toolchain-extra.c
index 6b474e88f473..081fc67e01cf 100644
--- a/clang/test/Driver/riscv64-toolchain-extra.c
+++ b/clang/test/Driver/riscv64-toolchain-extra.c
@@ -11,6 +11,7 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
+// REQUIRES: platform-linker
 // RUN: mkdir -p %T/testroot-riscv64-baremetal-nogcc/bin
 // RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/clang ] || rm 
%T/testroot-riscv64-baremetal-nogcc/bin/clang
 // RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld 
] || rm %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld



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


Re: [PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Leonard Chan via cfe-commits
Yup, I added it to both *-extra.c files and it seemed to fix the tests.

On Wed, Feb 26, 2020 at 11:37 AM Serge Guelton  wrote:

> Does adding
>
> // REQUIRES: platform-linker
>
> to Driver/riscv32-toolchain-extra.c fixes your issue?
>
>
> On Wed, Feb 26, 2020 at 06:25:39PM +, Leonard Chan via Phabricator
> wrote:
> > leonardchan added a comment.
> >
> > Hi again, I think e058667a2e017d3225a9bb067dbac7f2159576f7 <
> https://reviews.llvm.org/rGe058667a2e017d3225a9bb067dbac7f2159576f7>
> might've broken our toolchain again:
> >
> >   FAIL: Clang :: Driver/riscv32-toolchain-extra.c (5723 of 17018)
> >    TEST 'Clang :: Driver/riscv32-toolchain-extra.c'
> FAILED 
> >   Script:
> >   --
> >   : 'RUN: at line 14';   mkdir -p
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin
> >   : 'RUN: at line 15';   [ ! -s
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
> ] || rm
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
> >   : 'RUN: at line 16';   [ ! -s
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
> ] || rm
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
> >   : 'RUN: at line 17';   [ ! -s
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
> ] || rm
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
> >   : 'RUN: at line 18';   ln -s
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/clang
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
> >   : 'RUN: at line 19';   ln -s
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
> >   : 'RUN: at line 20';   ln -s
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
> >   : 'RUN: at line 21';
>  
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c
> -### -no-canonical-prefixes
>  
> --gcc-toolchain=/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/invalid
>-target riscv32-unknown-elf --rtlib=platform 2>&1 |
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/FileCheck
> -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c
> >   --
> >   Exit Code: 1
> >
> >   Command Output (stderr):
> >   --
> >
>  
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c:27:34:
> error: C-RV32-BAREMETAL-ILP32-NOGCC: expected string not found in input
> >   // C-RV32-BAREMETAL-ILP32-NOGCC:
> "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
> >^
> >   :5:1070: note: scanning from here
> >
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang"
> "-cc1" "-triple" "riscv32-unknown-unknown-elf" "-emit-obj" "-mrelax-all"
> "--mrelax-relocations" "-disable-free" "-disable-llvm-verifier"
> "-discard-value-names" "-main-file-name" "riscv32-toolchain-extra.c"
> "-mrelocation-model" "static" "-mthread-model" "posix"
> "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-masm-verbose"
> "-mconstructor-aliases" "-nostdsysteminc" "-target-feature" "+m"
> "-target-feature" "+a" "-target-feature" "+c" "-target-feature" "+relax"
> "-target-feature" "-save-restore" "-target-abi" "ilp32"
> "-dwarf-column-info" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb"
> "-resource-dir"
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/lib/clang/11.0.0"
> "-internal-isystem"
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include"
> "-fdebug-compilation-dir"
> 

Re: [PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Leonard Chan via cfe-commits
Will you be sending out the patch for this?

On Wed, Feb 26, 2020 at 12:05 PM Leonard Chan 
wrote:

> Yup, I added it to both *-extra.c files and it seemed to fix the tests.
>
> On Wed, Feb 26, 2020 at 11:37 AM Serge Guelton 
> wrote:
>
>> Does adding
>>
>> // REQUIRES: platform-linker
>>
>> to Driver/riscv32-toolchain-extra.c fixes your issue?
>>
>>
>> On Wed, Feb 26, 2020 at 06:25:39PM +, Leonard Chan via Phabricator
>> wrote:
>> > leonardchan added a comment.
>> >
>> > Hi again, I think e058667a2e017d3225a9bb067dbac7f2159576f7 <
>> https://reviews.llvm.org/rGe058667a2e017d3225a9bb067dbac7f2159576f7>
>> might've broken our toolchain again:
>> >
>> >   FAIL: Clang :: Driver/riscv32-toolchain-extra.c (5723 of 17018)
>> >    TEST 'Clang :: Driver/riscv32-toolchain-extra.c'
>> FAILED 
>> >   Script:
>> >   --
>> >   : 'RUN: at line 14';   mkdir -p
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin
>> >   : 'RUN: at line 15';   [ ! -s
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>> ] || rm
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>> >   : 'RUN: at line 16';   [ ! -s
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>> ] || rm
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>> >   : 'RUN: at line 17';   [ ! -s
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>> ] || rm
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>> >   : 'RUN: at line 18';   ln -s
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/clang
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>> >   : 'RUN: at line 19';   ln -s
>> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>> >   : 'RUN: at line 20';   ln -s
>> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>> >   : 'RUN: at line 21';
>>  
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c
>> -### -no-canonical-prefixes
>>  
>> --gcc-toolchain=/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/invalid
>>-target riscv32-unknown-elf --rtlib=platform 2>&1 |
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/FileCheck
>> -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC
>> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c
>> >   --
>> >   Exit Code: 1
>> >
>> >   Command Output (stderr):
>> >   --
>> >
>>  
>> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c:27:34:
>> error: C-RV32-BAREMETAL-ILP32-NOGCC: expected string not found in input
>> >   // C-RV32-BAREMETAL-ILP32-NOGCC:
>> "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
>> >^
>> >   :5:1070: note: scanning from here
>> >
>> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang"
>> "-cc1" "-triple" "riscv32-unknown-unknown-elf" "-emit-obj" "-mrelax-all"
>> "--mrelax-relocations" "-disable-free" "-disable-llvm-verifier"
>> "-discard-value-names" "-main-file-name" "riscv32-toolchain-extra.c"
>> "-mrelocation-model" "static" "-mthread-model" "posix"
>> "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-masm-verbose"
>> "-mconstructor-aliases" "-nostdsysteminc" "-target-feature" "+m"
>> "-target-feature" "+a" "-target-feature" "+c" "-target-feature" "+relax"
>> "-target-feature" "-save-restore" "-target-abi" "ilp32"
>> "-dwarf-column-info" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb"
>> "-resource-dir"
>> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/lib/clang/11.0.0"
>> "-internal-isystem"
>> 

[clang] e278c13 - [Sema] Add MacroQualified case for FunctionTypeUnwrapper

2019-11-12 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2019-11-12T16:22:13-08:00
New Revision: e278c138a937a68f3e6c89df8eaeffa913f9b0f7

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

LOG: [Sema] Add MacroQualified case for FunctionTypeUnwrapper

This is a fix for PR43315. An assertion error is hit for this minimal example:

```
//clang -cc1 -triple x86_64-- -S tstVMStructRC-min.cpp
int (a b)();  // Assertion `Chunk.Kind == DeclaratorChunk::Function' failed.
```

This is because we do not cover the case in the FunctionTypeUnwrapper where it
receives a MacroQualifiedType. We have not run into this earlier because this
is a unique case where the __attribute__ contains both __cdecl__ and
__regparm__ (in that order), and we are compiling for x86_64. Changing the
architecture or the order of __cdecl__ and __regparm__ does not raise the
assertion.

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

Added: 


Modified: 
clang/lib/Sema/SemaType.cpp
clang/test/Frontend/macro_defined_type.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index abee6e68c0eb..06f5e6f9ee34 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -6325,7 +6325,8 @@ namespace {
   Pointer,
   BlockPointer,
   Reference,
-  MemberPointer
+  MemberPointer,
+  MacroQualified,
 };
 
 QualType Original;
@@ -6356,6 +6357,9 @@ namespace {
 } else if (isa(Ty)) {
   T = cast(Ty)->getEquivalentType();
   Stack.push_back(Attributed);
+} else if (isa(Ty)) {
+  T = cast(Ty)->getUnderlyingType();
+  Stack.push_back(MacroQualified);
 } else {
   const Type *DTy = Ty->getUnqualifiedDesugaredType();
   if (Ty == DTy) {
@@ -6412,6 +6416,9 @@ namespace {
 return C.getParenType(New);
   }
 
+  case MacroQualified:
+return wrap(C, cast(Old)->getUnderlyingType(), I);
+
   case Pointer: {
 QualType New = wrap(C, cast(Old)->getPointeeType(), I);
 return C.getPointerType(New);

diff  --git a/clang/test/Frontend/macro_defined_type.cpp 
b/clang/test/Frontend/macro_defined_type.cpp
index d4f54b65a8d6..71a0ff18477d 100644
--- a/clang/test/Frontend/macro_defined_type.cpp
+++ b/clang/test/Frontend/macro_defined_type.cpp
@@ -19,3 +19,7 @@ void Func() {
 struct A {
   _LIBCPP_FLOAT_ABI int operator()() throw(); // expected-warning{{'pcs' 
calling convention is not supported for this target}}
 };
+
+// Added test for fix for PR43315
+#define a __attribute__((__cdecl__, __regparm__(0)))
+int(a b)();



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


[clang] 85b718f - [Driver] Enable ShadowCallStack, not SafeStack, by default on AArch64 Fuchsia

2019-10-28 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2019-10-28T14:19:38-07:00
New Revision: 85b718f53a3575bca2f1b7fdb1b3aaa6df7c10e3

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

LOG: [Driver] Enable ShadowCallStack, not SafeStack, by default on AArch64 
Fuchsia

Submitted for mcgrathr.

On AArch64, Fuchsia fully supports both SafeStack and ShadowCallStack ABIs.
The latter is now preferred and will be the default. It's possible to
enable both simultaneously, but ShadowCallStack is believed to have most
of the practical benefit of SafeStack with less cost.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index e7d38ff9f227..df2b4724dc22 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -343,5 +343,10 @@ SanitizerMask Fuchsia::getSupportedSanitizers() const {
 }
 
 SanitizerMask Fuchsia::getDefaultSanitizers() const {
-  return SanitizerKind::SafeStack;
+  SanitizerMask Res;
+  if (getTriple().getArch() == llvm::Triple::aarch64)
+Res |= SanitizerKind::ShadowCallStack;
+  else
+Res |= SanitizerKind::SafeStack;
+  return Res;
 }

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index bf8e5a04dc91..b5f9c326ea69 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -13,7 +13,8 @@
 // CHECK: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
-// CHECK: "-fsanitize=safe-stack"
+// CHECK-AARCH64: "-fsanitize=shadow-call-stack"
+// CHECK-X86_64: "-fsanitize=safe-stack"
 // CHECK: "-stack-protector" "2"
 // CHECK: "-fno-common"
 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "rodynamic" "-z" 
"separate-loadable-segments"
@@ -102,7 +103,7 @@
 // RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-AARCH64
 // CHECK-ASAN-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK-ASAN-AARCH64: "-fsanitize=address"
+// CHECK-ASAN-AARCH64: "-fsanitize=address,shadow-call-stack"
 // CHECK-ASAN-AARCH64: "-fsanitize-address-globals-dead-stripping"
 // CHECK-ASAN-AARCH64: "-dynamic-linker" "asan/ld.so.1"
 // CHECK-ASAN-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aarch64-fuchsia{{/|}}libclang_rt.asan.so"
@@ -134,7 +135,7 @@
 // RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-FUZZER-AARCH64
 // CHECK-FUZZER-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK-FUZZER-AARCH64: "-fsanitize=fuzzer,fuzzer-no-link,safe-stack"
+// CHECK-FUZZER-AARCH64: "-fsanitize=fuzzer,fuzzer-no-link,shadow-call-stack"
 // CHECK-FUZZER-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aarch64-fuchsia{{/|}}libclang_rt.fuzzer.a"
 
 // RUN: %clang %s -### --target=x86_64-fuchsia \
@@ -153,7 +154,7 @@
 // RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-AARCH64
 // CHECK-SCUDO-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK-SCUDO-AARCH64: "-fsanitize=safe-stack,scudo"
+// CHECK-SCUDO-AARCH64: "-fsanitize=shadow-call-stack,scudo"
 // CHECK-SCUDO-AARCH64: "-pie"
 // CHECK-SCUDO-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aarch64-fuchsia{{/|}}libclang_rt.scudo.so"
 



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


r371326 - [NewPM][Sancov] Create the Sancov Pass after building the pipelines

2019-09-08 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Sun Sep  8 00:30:17 2019
New Revision: 371326

URL: http://llvm.org/viewvc/llvm-project?rev=371326=rev
Log:
[NewPM][Sancov] Create the Sancov Pass after building the pipelines

We're running into linker errors from missing sancov sections:

```
ld.lld: error: relocation refers to a discarded section: __sancov_guards
>>> defined in 
>>> user-arm64-ubsan-sancov-full.shlib/obj/third_party/ulib/scudo/scudo.wrappers_c.cc.o
>>> referenced by common.h:26 (../../zircon/third_party/ulib/scudo/common.h:26)
... many other references
```

I believe this is due to a pass in the default pipeline that somehow discards
these sections. The ModuleSanitizerCoveragePass was initially added at the
start of the pipeline. This now adds it to the end of the pipeline for
optimized and unoptimized builds.

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=371326=371325=371326=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sun Sep  8 00:30:17 2019
@@ -1149,16 +1149,6 @@ void EmitAssemblyHelper::EmitAssemblyWit
 EntryExitInstrumenterPass(/*PostInlining=*/false)));
   });
 
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-PB.registerPipelineStartEPCallback(
-[SancovOpts](ModulePassManager ) {
-  MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
-});
-  }
-
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out
@@ -1226,6 +1216,13 @@ void EmitAssemblyHelper::EmitAssemblyWit
   }
 }
 
+if (CodeGenOpts.SanitizeCoverageType ||
+CodeGenOpts.SanitizeCoverageIndirectCalls ||
+CodeGenOpts.SanitizeCoverageTraceCmp) {
+  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+  MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
+}
+
 if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
   bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
   MPM.addPass(HWAddressSanitizerPass(
@@ -1237,13 +1234,6 @@ void EmitAssemblyHelper::EmitAssemblyWit
 }
 
 if (CodeGenOpts.OptimizationLevel == 0) {
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
-  }
-
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
 }
   }


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


r370971 - [NewPM][Sancov] Make Sancov a Module Pass instead of 2 Passes

2019-09-04 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Wed Sep  4 13:30:29 2019
New Revision: 370971

URL: http://llvm.org/viewvc/llvm-project?rev=370971=rev
Log:
[NewPM][Sancov] Make Sancov a Module Pass instead of 2 Passes

This patch merges the sancov module and funciton passes into one module pass.

The reason for this is because we ran into an out of memory error when
attempting to run asan fuzzer on some protobufs (pc.cc files). I traced the OOM
error to the destructor of SanitizerCoverage where we only call
appendTo[Compiler]Used which calls appendToUsedList. I'm not sure where 
precisely
in appendToUsedList causes the OOM, but I am able to confirm that it's calling
this function *repeatedly* that causes the OOM. (I hacked sancov a bit such that
I can still create and destroy a new sancov on every function run, but only call
appendToUsedList after all functions in the module have finished. This passes, 
but
when I make it such that appendToUsedList is called on every sancov destruction,
we hit OOM.)

I don't think the OOM is from just adding to the SmallSet and SmallVector inside
appendToUsedList since in either case for a given module, they'll have the same
max size. I suspect that when the existing llvm.compiler.used global is erased,
the memory behind it isn't freed. I could be wrong on this though.

This patch works around the OOM issue by just calling appendToUsedList at the
end of every module run instead of function run. The same amount of constants
still get added to llvm.compiler.used, abd we make the pass usage and logic
simpler by not having any inter-pass dependencies.

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=370971=370970=370971=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Sep  4 13:30:29 2019
@@ -224,7 +224,6 @@ static void addSanitizerCoveragePass(con
   const CodeGenOptions  = BuilderWrapper.getCGOpts();
   auto Opts = getSancovOptsFromCGOpts(CGOpts);
   PM.add(createModuleSanitizerCoverageLegacyPassPass(Opts));
-  PM.add(createSanitizerCoverageLegacyPassPass(Opts));
 }
 
 // Check if ASan should use GC-friendly instrumentation for globals.
@@ -1159,11 +1158,6 @@ void EmitAssemblyHelper::EmitAssemblyWit
 [SancovOpts](ModulePassManager ) {
   MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
 });
-PB.registerOptimizerLastEPCallback(
-[SancovOpts](FunctionPassManager ,
- PassBuilder::OptimizationLevel Level) {
-  FPM.addPass(SanitizerCoveragePass(SancovOpts));
-});
   }
 
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
@@ -1249,8 +1243,6 @@ void EmitAssemblyHelper::EmitAssemblyWit
   CodeGenOpts.SanitizeCoverageTraceCmp) {
 auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
 MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
-MPM.addPass(createModuleToFunctionPassAdaptor(
-SanitizerCoveragePass(SancovOpts)));
   }
 
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);


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


r369550 - [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1 under the new pass manager

2019-08-21 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Wed Aug 21 10:24:14 2019
New Revision: 369550

URL: http://llvm.org/viewvc/llvm-project?rev=369550=rev
Log:
[LTO] Always mark regular LTO units with EnableSplitLTOUnit=1 under the new 
pass manager

Match the behavior of D65009 under the new pass manager. This addresses
the test clang/test/CodeGen/split-lto-unit.c when running under the new
PM.

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/split-lto-unit.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=369550=369549=369550=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Aug 21 10:24:14 2019
@@ -1291,7 +1291,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- CodeGenOpts.EnableSplitLTOUnit);
+ uint32_t(1));
   }
   MPM.addPass(
   BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, 
EmitLTOSummary));

Modified: cfe/trunk/test/CodeGen/split-lto-unit.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-lto-unit.c?rev=369550=369549=369550=diff
==
--- cfe/trunk/test/CodeGen/split-lto-unit.c (original)
+++ cfe/trunk/test/CodeGen/split-lto-unit.c Wed Aug 21 10:24:14 2019
@@ -7,6 +7,7 @@
 // SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
 //
 // ; Check that regular LTO has EnableSplitLTOUnit = 1
-// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | 
llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" 
--check-prefix=SPLIT
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -flto -triple 
x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s 
--implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -flto -triple 
x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s 
--implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
 
 int main() {}


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


r369442 - [NewPM] Run ubsan-coroutines test under the legacy pass manager only

2019-08-20 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Tue Aug 20 13:55:36 2019
New Revision: 369442

URL: http://llvm.org/viewvc/llvm-project?rev=369442=rev
Log:
[NewPM] Run ubsan-coroutines test under the legacy pass manager only

The passes that lower the llvm.coro.* instrinsics have not yet been ported,
so only run under the legacy PM for now.

See https://bugs.llvm.org/show_bug.cgi?id=42867

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

Modified:
cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp

Modified: cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp?rev=369442=369441=369442=diff
==
--- cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp Tue Aug 20 13:55:36 2019
@@ -1,6 +1,8 @@
 // This test merely verifies that emitting the object file does not cause a
 // crash when the LLVM coroutines passes are run.
-// RUN: %clang_cc1 -emit-obj -std=c++2a -fsanitize=null %s -o %t.o
+// PR42867: Disable this test for the new PM since the passes that lower the
+// llvm.coro.* intrinsics have not yet been ported.
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-obj -std=c++2a 
-fsanitize=null %s -o %t.o
 
 namespace std::experimental {
 template  struct coroutine_traits {


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


Re: r369281 - Implement P1668R1

2019-08-19 Thread Leonard Chan via cfe-commits
 Thanks

On Mon, Aug 19, 2019 at 11:34 AM Keane, Erich  wrote:

> Yeah, sorry about that.  I fixed it in 369284.
>
>
>
> *From:* Leonard Chan [mailto:leonardc...@google.com]
> *Sent:* Monday, August 19, 2019 11:33 AM
> *To:* Keane, Erich 
> *Cc:* cfe-commits cfe 
> *Subject:* Re: r369281 - Implement P1668R1
>
>
>
> Not sure if this was caught by upstream bots already, but we're seeing a
> failing test ob our x64 bots:
>
>
>
> ```
>
> FAIL: Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp (9574 of 15387)
>  TEST 'Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp'
> FAILED 
> Script:
> --
> : 'RUN: at line 1';
> /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1
> -internal-isystem
> /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include
> -nostdsysteminc -std=c++1z -verify -fsyntax-only -fblocks
> /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
> -fcxx-exceptions
> : 'RUN: at line 2';
> /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1
> -internal-isystem
> /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include
> -nostdsysteminc -std=c++2a -verify -fsyntax-only -fblocks
> /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
> -fcxx-exceptions
> : 'RUN: at line 3';
> /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1
> -internal-isystem
> /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include
> -nostdsysteminc -std=c++1z -verify -fsyntax-only -fblocks
> -fdelayed-template-parsing
> /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
> -fcxx-exceptions
> : 'RUN: at line 4';
> /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1
> -internal-isystem
> /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include
> -nostdsysteminc -std=c++14 -verify -fsyntax-only -fblocks
> /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
> -DCPP14_AND_EARLIER -fcxx-exceptions
> --
> Exit Code: 1
>
> Command Output (stderr):
> --
> error: 'error' diagnostics expected but not seen:
>   File
> /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
> Line 26 (directive at
> /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp:28):
> use of this statement in a constexpr function is a C++2a extension
> error: 'warning' diagnostics seen but not expected:
>   File
> /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
> Line 26: use of this statement in a constexpr function is a C++2a extension
> 2 errors generated.
>
> --
>
> 
> Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
> Testing Time: 79.76s
> 
> Failing Tests (1):
> Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp
>
> ```
>
>
>
> Could you look into this? Thanks.
>
>
>
> On Mon, Aug 19, 2019 at 10:39 AM Erich Keane via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: erichkeane
> Date: Mon Aug 19 10:39:59 2019
> New Revision: 369281
>
> URL: http://llvm.org/viewvc/llvm-project?rev=369281=rev
> Log:
> Implement P1668R1
>
> Allow inline assembly statements in unexecuted branches of constexpr
> functions.
>
> Modified:
> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
> cfe/trunk/test/Lexer/cxx-features.cpp
> cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
>
> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=369281=369280=369281=diff
>
> ==
> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Aug 19 10:39:59 2019
> @@ -480,6 +480,7 @@ static void InitializeCPlusPlusFeatureTe
>  Builder.defineMacro("__cpp_user_defined_literals", "200809L");
>  Builder.defineMacro("__cpp_lambdas", "200907L");
>  Builder.defineMacro("__cpp_constexpr",
> +LangOpts.CPlusPlus2a ? "201907L" :
>  LangOpts.CPlusPlus17 ? "201603L" :
>  LangOpts.CPlusPlus14 ? "201304L" : "200704");
>  Builder.defineMacro("__cpp_range_based_for",
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=369281=369280=369281=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Aug 19 10:39:59 2019
> @@ -1995,6 +1995,9 @@ CheckConstexprFunctionStmt(Sema 
>  return false;
>  return true;
>
> +  case Stmt::GCCAsmStmtClass:
> +  case Stmt::MSAsmStmtClass:
> +// C++2a allows inline assembly 

Re: r369281 - Implement P1668R1

2019-08-19 Thread Leonard Chan via cfe-commits
Not sure if this was caught by upstream bots already, but we're seeing a
failing test ob our x64 bots:

```
FAIL: Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp (9574 of 15387)
 TEST 'Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp'
FAILED 
Script:
--
: 'RUN: at line 1';
/b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1
-internal-isystem
/b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include
-nostdsysteminc -std=c++1z -verify -fsyntax-only -fblocks
/b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
-fcxx-exceptions
: 'RUN: at line 2';
/b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1
-internal-isystem
/b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include
-nostdsysteminc -std=c++2a -verify -fsyntax-only -fblocks
/b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
-fcxx-exceptions
: 'RUN: at line 3';
/b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1
-internal-isystem
/b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include
-nostdsysteminc -std=c++1z -verify -fsyntax-only -fblocks
-fdelayed-template-parsing
/b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
-fcxx-exceptions
: 'RUN: at line 4';
/b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1
-internal-isystem
/b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include
-nostdsysteminc -std=c++14 -verify -fsyntax-only -fblocks
/b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
-DCPP14_AND_EARLIER -fcxx-exceptions
--
Exit Code: 1

Command Output (stderr):
--
error: 'error' diagnostics expected but not seen:
  File
/b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
Line 26 (directive at
/b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp:28):
use of this statement in a constexpr function is a C++2a extension
error: 'warning' diagnostics seen but not expected:
  File
/b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
Line 26: use of this statement in a constexpr function is a C++2a extension
2 errors generated.

--


Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
Testing Time: 79.76s

Failing Tests (1):
Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp
```

Could you look into this? Thanks.

On Mon, Aug 19, 2019 at 10:39 AM Erich Keane via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: erichkeane
> Date: Mon Aug 19 10:39:59 2019
> New Revision: 369281
>
> URL: http://llvm.org/viewvc/llvm-project?rev=369281=rev
> Log:
> Implement P1668R1
>
> Allow inline assembly statements in unexecuted branches of constexpr
> functions.
>
> Modified:
> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
> cfe/trunk/test/Lexer/cxx-features.cpp
> cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
>
> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=369281=369280=369281=diff
>
> ==
> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Aug 19 10:39:59 2019
> @@ -480,6 +480,7 @@ static void InitializeCPlusPlusFeatureTe
>  Builder.defineMacro("__cpp_user_defined_literals", "200809L");
>  Builder.defineMacro("__cpp_lambdas", "200907L");
>  Builder.defineMacro("__cpp_constexpr",
> +LangOpts.CPlusPlus2a ? "201907L" :
>  LangOpts.CPlusPlus17 ? "201603L" :
>  LangOpts.CPlusPlus14 ? "201304L" : "200704");
>  Builder.defineMacro("__cpp_range_based_for",
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=369281=369280=369281=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Aug 19 10:39:59 2019
> @@ -1995,6 +1995,9 @@ CheckConstexprFunctionStmt(Sema 
>  return false;
>  return true;
>
> +  case Stmt::GCCAsmStmtClass:
> +  case Stmt::MSAsmStmtClass:
> +// C++2a allows inline assembly statements.
>case Stmt::CXXTryStmtClass:
>  if (Cxx2aLoc.isInvalid())
>Cxx2aLoc = S->getBeginLoc();
>
> Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp?rev=369281=369280=369281=diff
>
> ==
> --- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp 

r367157 - [NewPM] Run avx*-builtins.c tests under the new pass manager only

2019-07-26 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Fri Jul 26 14:19:37 2019
New Revision: 367157

URL: http://llvm.org/viewvc/llvm-project?rev=367157=rev
Log:
[NewPM] Run avx*-builtins.c tests under the new pass manager only

This patch changes the following tests to run under the new pass manager only:

```
Clang :: CodeGen/avx512-reduceMinMaxIntrin.c (1 of 4)
Clang :: CodeGen/avx512vl-builtins.c (2 of 4)
Clang :: CodeGen/avx512vlbw-builtins.c (3 of 4)
Clang :: CodeGen/avx512f-builtins.c (4 of 4)
```

The new PM added extra bitcasts that weren't checked before. For
reduceMinMaxIntrin.c, the issue was mostly the alloca's being in a different
order. Other changes involved extra bitcasts, and differently ordered loads and
stores, but the logic should still be the same.

Differential revision: https://reviews.llvm.org/D65110

Modified:
cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c

Modified: cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c?rev=367157=367156=367157=diff
==
--- cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c (original)
+++ cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c Fri Jul 26 14:19:37 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64-apple-darwin 
-target-cpu skylake-avx512 -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -ffreestanding %s -O0 
-triple=x86_64-apple-darwin -target-cpu skylake-avx512 -emit-llvm -o - -Wall 
-Werror | FileCheck %s
 
 #include 
 
@@ -27,10 +27,10 @@
 // CHECK-NEXT:store <8 x i64> [[SHUFFLE_I]], <8 x i64>* [[__T1_I]], align 
64
 // CHECK-NEXT:[[TMP3:%.*]] = load <8 x i64>, <8 x i64>* [[__V_ADDR_I]], 
align 64
 // CHECK-NEXT:[[TMP4:%.*]] = load <8 x i64>, <8 x i64>* [[__T1_I]], align 
64
-// CHECK-NEXT:store <8 x i64> [[TMP3]], <8 x i64>* [[__A_ADDR_I_I]], align 
64
-// CHECK-NEXT:store <8 x i64> [[TMP4]], <8 x i64>* [[__B_ADDR_I_I]], align 
64
-// CHECK-NEXT:[[TMP5:%.*]] = load <8 x i64>, <8 x i64>* [[__A_ADDR_I_I]], 
align 64
-// CHECK-NEXT:[[TMP6:%.*]] = load <8 x i64>, <8 x i64>* [[__B_ADDR_I_I]], 
align 64
+// CHECK-NEXT:store <8 x i64> [[TMP3]], <8 x i64>* [[__A_ADDR_I7_I]], 
align 64
+// CHECK-NEXT:store <8 x i64> [[TMP4]], <8 x i64>* [[__B_ADDR_I8_I]], 
align 64
+// CHECK-NEXT:[[TMP5:%.*]] = load <8 x i64>, <8 x i64>* [[__A_ADDR_I7_I]], 
align 64
+// CHECK-NEXT:[[TMP6:%.*]] = load <8 x i64>, <8 x i64>* [[__B_ADDR_I8_I]], 
align 64
 // CHECK-NEXT:[[TMP7:%.*]] = icmp sgt <8 x i64> [[TMP5]], [[TMP6]]
 // CHECK-NEXT:[[TMP8:%.*]] = select <8 x i1> [[TMP7]], <8 x i64> [[TMP5]], 
<8 x i64> [[TMP6]]
 // CHECK-NEXT:store <8 x i64> [[TMP8]], <8 x i64>* [[__T2_I]], align 64
@@ -40,10 +40,10 @@
 // CHECK-NEXT:store <8 x i64> [[SHUFFLE1_I]], <8 x i64>* [[__T3_I]], align 
64
 // CHECK-NEXT:[[TMP11:%.*]] = load <8 x i64>, <8 x i64>* [[__T2_I]], align 
64
 // CHECK-NEXT:[[TMP12:%.*]] = load <8 x i64>, <8 x i64>* [[__T3_I]], align 
64
-// CHECK-NEXT:store <8 x i64> [[TMP11]], <8 x i64>* [[__A_ADDR_I7_I]], 
align 64
-// CHECK-NEXT:store <8 x i64> [[TMP12]], <8 x i64>* [[__B_ADDR_I8_I]], 
align 64
-// CHECK-NEXT:[[TMP13:%.*]] = load <8 x i64>, <8 x i64>* 
[[__A_ADDR_I7_I]], align 64
-// CHECK-NEXT:[[TMP14:%.*]] = load <8 x i64>, <8 x i64>* 
[[__B_ADDR_I8_I]], align 64
+// CHECK-NEXT:store <8 x i64> [[TMP11]], <8 x i64>* [[__A_ADDR_I5_I]], 
align 64
+// CHECK-NEXT:store <8 x i64> [[TMP12]], <8 x i64>* [[__B_ADDR_I6_I]], 
align 64
+// CHECK-NEXT:[[TMP13:%.*]] = load <8 x i64>, <8 x i64>* 
[[__A_ADDR_I5_I]], align 64
+// CHECK-NEXT:[[TMP14:%.*]] = load <8 x i64>, <8 x i64>* 
[[__B_ADDR_I6_I]], align 64
 // CHECK-NEXT:[[TMP15:%.*]] = icmp sgt <8 x i64> [[TMP13]], [[TMP14]]
 // CHECK-NEXT:[[TMP16:%.*]] = select <8 x i1> [[TMP15]], <8 x i64> 
[[TMP13]], <8 x i64> [[TMP14]]
 // CHECK-NEXT:store <8 x i64> [[TMP16]], <8 x i64>* [[__T4_I]], align 64
@@ -53,10 +53,10 @@
 // CHECK-NEXT:store <8 x i64> [[SHUFFLE3_I]], <8 x i64>* [[__T5_I]], align 
64
 // CHECK-NEXT:[[TMP19:%.*]] = load <8 x i64>, <8 x i64>* [[__T4_I]], align 
64
 // CHECK-NEXT:[[TMP20:%.*]] = load <8 x i64>, <8 x i64>* [[__T5_I]], align 
64
-// CHECK-NEXT:store <8 x i64> [[TMP19]], <8 x i64>* [[__A_ADDR_I5_I]], 
align 64
-// CHECK-NEXT:store <8 x i64> [[TMP20]], <8 x i64>* [[__B_ADDR_I6_I]], 
align 64
-// CHECK-NEXT:[[TMP21:%.*]] = load <8 x i64>, <8 x i64>* 
[[__A_ADDR_I5_I]], align 64
-// CHECK-NEXT:[[TMP22:%.*]] = load <8 x i64>, <8 x i64>* 
[[__B_ADDR_I6_I]], align 64
+// CHECK-NEXT:store <8 x i64> [[TMP19]], <8 x i64>* [[__A_ADDR_I_I]], 
align 64
+// CHECK-NEXT:store <8 x i64> [[TMP20]], <8 x 

r367053 - Reland the "[NewPM] Port Sancov" patch from rL365838. No functional

2019-07-25 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jul 25 13:53:15 2019
New Revision: 367053

URL: http://llvm.org/viewvc/llvm-project?rev=367053=rev
Log:
Reland the "[NewPM] Port Sancov" patch from rL365838. No functional
changes were made to the patch since then.



[NewPM] Port Sancov

This patch contains a port of SanitizerCoverage to the new pass manager. This 
one's a bit hefty.

Changes:

- Split SanitizerCoverageModule into 2 SanitizerCoverage for passing over
  functions and ModuleSanitizerCoverage for passing over modules.
- ModuleSanitizerCoverage exists for adding 2 module level calls to 
initialization
  functions but only if there's a function that was instrumented by sancov.
- Added legacy and new PM wrapper classes that own instances of the 2 new 
classes.
- Update llvm tests and add clang tests.

Added:
cfe/trunk/test/CodeGen/sancov-new-pm.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=367053=367052=367053=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jul 25 13:53:15 2019
@@ -60,6 +60,7 @@
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/InstrProfiling.h"
 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
+#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -195,11 +196,8 @@ static void addBoundsCheckingPass(const
   PM.add(createBoundsCheckingLegacyPass());
 }
 
-static void addSanitizerCoveragePass(const PassManagerBuilder ,
- legacy::PassManagerBase ) {
-  const PassManagerBuilderWrapper  =
-  static_cast(Builder);
-  const CodeGenOptions  = BuilderWrapper.getCGOpts();
+static SanitizerCoverageOptions
+getSancovOptsFromCGOpts(const CodeGenOptions ) {
   SanitizerCoverageOptions Opts;
   Opts.CoverageType =
   static_cast(CGOpts.SanitizeCoverageType);
@@ -215,7 +213,17 @@ static void addSanitizerCoveragePass(con
   Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
   Opts.PCTable = CGOpts.SanitizeCoveragePCTable;
   Opts.StackDepth = CGOpts.SanitizeCoverageStackDepth;
-  PM.add(createSanitizerCoverageModulePass(Opts));
+  return Opts;
+}
+
+static void addSanitizerCoveragePass(const PassManagerBuilder ,
+ legacy::PassManagerBase ) {
+  const PassManagerBuilderWrapper  =
+  static_cast(Builder);
+  const CodeGenOptions  = BuilderWrapper.getCGOpts();
+  auto Opts = getSancovOptsFromCGOpts(CGOpts);
+  PM.add(createModuleSanitizerCoverageLegacyPassPass(Opts));
+  PM.add(createSanitizerCoverageLegacyPassPass(Opts));
 }
 
 // Check if ASan should use GC-friendly instrumentation for globals.
@@ -1128,6 +1136,21 @@ void EmitAssemblyHelper::EmitAssemblyWit
 EntryExitInstrumenterPass(/*PostInlining=*/false)));
   });
 
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+PB.registerPipelineStartEPCallback(
+[SancovOpts](ModulePassManager ) {
+  MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
+});
+PB.registerOptimizerLastEPCallback(
+[SancovOpts](FunctionPassManager ,
+ PassBuilder::OptimizationLevel Level) {
+  FPM.addPass(SanitizerCoveragePass(SancovOpts));
+});
+  }
+
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out
@@ -1205,8 +1228,18 @@ void EmitAssemblyHelper::EmitAssemblyWit
   /*CompileKernel=*/true, /*Recover=*/true));
 }
 
-if (CodeGenOpts.OptimizationLevel == 0)
+if (CodeGenOpts.OptimizationLevel == 0) {
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
+MPM.addPass(createModuleToFunctionPassAdaptor(
+SanitizerCoveragePass(SancovOpts)));
+  }
+
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
+}
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We

Added: cfe/trunk/test/CodeGen/sancov-new-pm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sancov-new-pm.c?rev=367053=auto

r366153 - Revert "[NewPM] Port Sancov"

2019-07-15 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Jul 15 16:18:31 2019
New Revision: 366153

URL: http://llvm.org/viewvc/llvm-project?rev=366153=rev
Log:
Revert "[NewPM] Port Sancov"

This reverts commit 5652f35817f07b16f8b3856d594cc42f4d7ee29c.

Removed:
cfe/trunk/test/CodeGen/sancov-new-pm.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=366153=366152=366153=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Jul 15 16:18:31 2019
@@ -60,7 +60,6 @@
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/InstrProfiling.h"
 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
-#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -196,8 +195,11 @@ static void addBoundsCheckingPass(const
   PM.add(createBoundsCheckingLegacyPass());
 }
 
-static SanitizerCoverageOptions
-getSancovOptsFromCGOpts(const CodeGenOptions ) {
+static void addSanitizerCoveragePass(const PassManagerBuilder ,
+ legacy::PassManagerBase ) {
+  const PassManagerBuilderWrapper  =
+  static_cast(Builder);
+  const CodeGenOptions  = BuilderWrapper.getCGOpts();
   SanitizerCoverageOptions Opts;
   Opts.CoverageType =
   static_cast(CGOpts.SanitizeCoverageType);
@@ -213,17 +215,7 @@ getSancovOptsFromCGOpts(const CodeGenOpt
   Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
   Opts.PCTable = CGOpts.SanitizeCoveragePCTable;
   Opts.StackDepth = CGOpts.SanitizeCoverageStackDepth;
-  return Opts;
-}
-
-static void addSanitizerCoveragePass(const PassManagerBuilder ,
- legacy::PassManagerBase ) {
-  const PassManagerBuilderWrapper  =
-  static_cast(Builder);
-  const CodeGenOptions  = BuilderWrapper.getCGOpts();
-  auto Opts = getSancovOptsFromCGOpts(CGOpts);
-  PM.add(createModuleSanitizerCoverageLegacyPassPass(Opts));
-  PM.add(createSanitizerCoverageLegacyPassPass(Opts));
+  PM.add(createSanitizerCoverageModulePass(Opts));
 }
 
 // Check if ASan should use GC-friendly instrumentation for globals.
@@ -1143,21 +1135,6 @@ void EmitAssemblyHelper::EmitAssemblyWit
 EntryExitInstrumenterPass(/*PostInlining=*/false)));
   });
 
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-PB.registerPipelineStartEPCallback(
-[SancovOpts](ModulePassManager ) {
-  MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
-});
-PB.registerOptimizerLastEPCallback(
-[SancovOpts](FunctionPassManager ,
- PassBuilder::OptimizationLevel Level) {
-  FPM.addPass(SanitizerCoveragePass(SancovOpts));
-});
-  }
-
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out
@@ -1242,18 +1219,8 @@ void EmitAssemblyHelper::EmitAssemblyWit
   }
 }
 
-if (CodeGenOpts.OptimizationLevel == 0) {
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
-MPM.addPass(createModuleToFunctionPassAdaptor(
-SanitizerCoveragePass(SancovOpts)));
-  }
-
+if (CodeGenOpts.OptimizationLevel == 0)
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
-}
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We

Removed: cfe/trunk/test/CodeGen/sancov-new-pm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sancov-new-pm.c?rev=366152=auto
==
--- cfe/trunk/test/CodeGen/sancov-new-pm.c (original)
+++ cfe/trunk/test/CodeGen/sancov-new-pm.c (removed)
@@ -1,41 +0,0 @@
-// Test that SanitizerCoverage works under the new pass manager.
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s 
-fexperimental-new-pass-manager -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-O0
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s 
-fexperimental-new-pass-manager -O2 -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-O2
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s 

r365838 - [NewPM] Port Sancov

2019-07-11 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jul 11 15:35:40 2019
New Revision: 365838

URL: http://llvm.org/viewvc/llvm-project?rev=365838=rev
Log:
[NewPM] Port Sancov

This patch contains a port of SanitizerCoverage to the new pass manager. This 
one's a bit hefty.

Changes:

- Split SanitizerCoverageModule into 2 SanitizerCoverage for passing over
  functions and ModuleSanitizerCoverage for passing over modules.
- ModuleSanitizerCoverage exists for adding 2 module level calls to 
initialization
  functions but only if there's a function that was instrumented by sancov.
- Added legacy and new PM wrapper classes that own instances of the 2 new 
classes.
- Update llvm tests and add clang tests.

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

Added:
cfe/trunk/test/CodeGen/sancov-new-pm.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=365838=365837=365838=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jul 11 15:35:40 2019
@@ -60,6 +60,7 @@
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/InstrProfiling.h"
 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
+#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -195,11 +196,8 @@ static void addBoundsCheckingPass(const
   PM.add(createBoundsCheckingLegacyPass());
 }
 
-static void addSanitizerCoveragePass(const PassManagerBuilder ,
- legacy::PassManagerBase ) {
-  const PassManagerBuilderWrapper  =
-  static_cast(Builder);
-  const CodeGenOptions  = BuilderWrapper.getCGOpts();
+static SanitizerCoverageOptions
+getSancovOptsFromCGOpts(const CodeGenOptions ) {
   SanitizerCoverageOptions Opts;
   Opts.CoverageType =
   static_cast(CGOpts.SanitizeCoverageType);
@@ -215,7 +213,17 @@ static void addSanitizerCoveragePass(con
   Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
   Opts.PCTable = CGOpts.SanitizeCoveragePCTable;
   Opts.StackDepth = CGOpts.SanitizeCoverageStackDepth;
-  PM.add(createSanitizerCoverageModulePass(Opts));
+  return Opts;
+}
+
+static void addSanitizerCoveragePass(const PassManagerBuilder ,
+ legacy::PassManagerBase ) {
+  const PassManagerBuilderWrapper  =
+  static_cast(Builder);
+  const CodeGenOptions  = BuilderWrapper.getCGOpts();
+  auto Opts = getSancovOptsFromCGOpts(CGOpts);
+  PM.add(createModuleSanitizerCoverageLegacyPassPass(Opts));
+  PM.add(createSanitizerCoverageLegacyPassPass(Opts));
 }
 
 // Check if ASan should use GC-friendly instrumentation for globals.
@@ -1135,6 +1143,21 @@ void EmitAssemblyHelper::EmitAssemblyWit
 EntryExitInstrumenterPass(/*PostInlining=*/false)));
   });
 
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+PB.registerPipelineStartEPCallback(
+[SancovOpts](ModulePassManager ) {
+  MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
+});
+PB.registerOptimizerLastEPCallback(
+[SancovOpts](FunctionPassManager ,
+ PassBuilder::OptimizationLevel Level) {
+  FPM.addPass(SanitizerCoveragePass(SancovOpts));
+});
+  }
+
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out
@@ -1219,8 +1242,18 @@ void EmitAssemblyHelper::EmitAssemblyWit
   }
 }
 
-if (CodeGenOpts.OptimizationLevel == 0)
+if (CodeGenOpts.OptimizationLevel == 0) {
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
+MPM.addPass(createModuleToFunctionPassAdaptor(
+SanitizerCoveragePass(SancovOpts)));
+  }
+
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
+}
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We

Added: cfe/trunk/test/CodeGen/sancov-new-pm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sancov-new-pm.c?rev=365838=auto
==
--- cfe/trunk/test/CodeGen/sancov-new-pm.c (added)
+++ cfe/trunk/test/CodeGen/sancov-new-pm.c 

r364692 - Revert "[clang][NewPM] Fix broken profile test"

2019-06-28 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Fri Jun 28 17:10:22 2019
New Revision: 364692

URL: http://llvm.org/viewvc/llvm-project?rev=364692=rev
Log:
Revert "[clang][NewPM] Fix broken profile test"

This reverts commit ab2c0ed01edfec9a9402d03bdf8633b34b73f3a7.

See https://reviews.llvm.org/D63155

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/Profile/gcc-flag-compatibility.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=364692=364691=364692=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jun 28 17:10:22 2019
@@ -60,7 +60,6 @@
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/InstrProfiling.h"
 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
-#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -1222,11 +1221,6 @@ void EmitAssemblyHelper::EmitAssemblyWit
 
 if (CodeGenOpts.OptimizationLevel == 0)
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
-
-if (CodeGenOpts.hasProfileIRInstr()) {
-  // This file is stored as the ProfileFile.
-  MPM.addPass(PGOInstrumentationGenCreateVar(PGOOpt->ProfileFile));
-}
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We

Modified: cfe/trunk/test/Profile/gcc-flag-compatibility.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/gcc-flag-compatibility.c?rev=364692=364691=364692=diff
==
--- cfe/trunk/test/Profile/gcc-flag-compatibility.c (original)
+++ cfe/trunk/test/Profile/gcc-flag-compatibility.c Fri Jun 28 17:10:22 2019
@@ -7,29 +7,25 @@
 // -fprofile-use=Uses the profile file /default.profdata
 // -fprofile-use=/file   Uses the profile file /file
 
-// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate 
-fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN %s
-// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate 
-fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN %s
+// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck 
-check-prefix=PROFILE-GEN %s
 // PROFILE-GEN: __llvm_profile_filename
 
 // Check that -fprofile-generate=/path/to generates /path/to/default.profraw
-// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to 
-fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN-EQ %s
-// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to 
-fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN-EQ %s
+// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to | 
FileCheck -check-prefix=PROFILE-GEN-EQ %s
 // PROFILE-GEN-EQ: constant [{{.*}} x i8] c"/path/to{{/|\\5C}}{{.*}}\00"
 
 // Check that -fprofile-use=some/path reads some/path/default.profdata
 // RUN: rm -rf %t.dir
 // RUN: mkdir -p %t.dir/some/path
 // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o 
%t.dir/some/path/default.profdata
-// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path -fno-experimental-new-pass-manager | FileCheck 
-check-prefix=PROFILE-USE-2 %s
-// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path -fexperimental-new-pass-manager | FileCheck 
-check-prefix=PROFILE-USE-2 %s
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-2 %s
 // PROFILE-USE-2: = !{!"branch_weights", i32 101, i32 2}
 
 // Check that -fprofile-use=some/path/file.prof reads some/path/file.prof
 // RUN: rm -rf %t.dir
 // RUN: mkdir -p %t.dir/some/path
 // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o 
%t.dir/some/path/file.prof
-// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path/file.prof -fno-experimental-new-pass-manager | 
FileCheck -check-prefix=PROFILE-USE-3 %s
-// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path/file.prof -fexperimental-new-pass-manager | 
FileCheck -check-prefix=PROFILE-USE-3 %s
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path/file.prof | FileCheck 
-check-prefix=PROFILE-USE-3 %s
 // PROFILE-USE-3: = !{!"branch_weights", i32 101, i32 2}
 
 int X = 0;


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


r364202 - [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-24 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Jun 24 09:49:18 2019
New Revision: 364202

URL: http://llvm.org/viewvc/llvm-project?rev=364202=rev
Log:
[clang][NewPM] Add RUNS for tests that produce slightly different IR under new 
PM

For CodeGenOpenCL/convergent.cl, the new PM produced a slightly different for
loop, but this still checks for no loop unrolling as intended. This is
committed separately from D63174.

Modified:
cfe/trunk/test/CodeGenOpenCL/convergent.cl

Modified: cfe/trunk/test/CodeGenOpenCL/convergent.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/convergent.cl?rev=364202=364201=364202=diff
==
--- cfe/trunk/test/CodeGenOpenCL/convergent.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/convergent.cl Mon Jun 24 09:49:18 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | opt 
-instnamer -S | FileCheck -enable-var-scope %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fno-experimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fexperimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s --check-prefixes=CHECK,CHECK-NEWPM
 
 // This is initially assumed convergent, but can be deduced to not require it.
 
@@ -117,7 +118,12 @@ void test_unroll() {
 // CHECK: [[for_body]]:
 // CHECK:  tail call spir_func void @nodupfun() #[[attr5:[0-9]+]]
 // CHECK-NOT: call spir_func void @nodupfun()
-// CHECK:  br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]]
+
+// The new PM produces a slightly different IR for the loop from the legacy PM,
+// but the test still checks that the loop is not unrolled.
+// CHECK-LEGACY:  br i1 %{{.+}}, label %[[for_body]], label 
%[[for_cond_cleanup]]
+// CHECK-NEW: br i1 %{{.+}}, label %[[for_body_crit_edge:.+]], label 
%[[for_cond_cleanup]]
+// CHECK-NEW: [[for_body_crit_edge]]:
 
 void test_not_unroll() {
   for (int i = 0; i < 10; i++)


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


r364201 - [clang][NewPM] Remove exception handling before loading pgo sample profile data

2019-06-24 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Jun 24 09:44:27 2019
New Revision: 364201

URL: http://llvm.org/viewvc/llvm-project?rev=364201=rev
Log:
[clang][NewPM] Remove exception handling before loading pgo sample profile data

This patch ensures that SimplifyCFGPass comes before SampleProfileLoaderPass
on PGO runs in the new PM and fixes clang/test/CodeGen/pgo-sample.c.

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

Modified:
cfe/trunk/test/CodeGen/pgo-sample.c

Modified: cfe/trunk/test/CodeGen/pgo-sample.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample.c?rev=364201=364200=364201=diff
==
--- cfe/trunk/test/CodeGen/pgo-sample.c (original)
+++ cfe/trunk/test/CodeGen/pgo-sample.c Mon Jun 24 09:44:27 2019
@@ -1,6 +1,13 @@
 // Test if PGO sample use passes are invoked.
 //
 // Ensure Pass PGOInstrumentationGenPass is invoked.
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s 
-mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s
-// CHECK: Remove unused exception handling info
-// CHECK: Sample profile pass
+// RUN: %clang_cc1 -O2 -fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure 
-emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=LEGACY
+// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -fdebug-pass-manager 
-emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=NEWPM
+
+// LEGACY: Remove unused exception handling info
+// LEGACY: Sample profile pass
+
+// NEWPM: SimplifyCFGPass
+// NEWPM: SampleProfileLoaderPass
+
+int func(int a) { return a; }


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


r364066 - [clang][NewPM] Add -fno-experimental-new-pass-manager to tests

2019-06-21 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Fri Jun 21 09:03:06 2019
New Revision: 364066

URL: http://llvm.org/viewvc/llvm-project?rev=364066=rev
Log:
[clang][NewPM] Add -fno-experimental-new-pass-manager to tests

As per the discussion on D58375, we disable test that have optimizations under
the new PM. This patch adds -fno-experimental-new-pass-manager to RUNS that:

- Already run with optimizations (-O1 or higher) that were missed in D58375.
- Explicitly test new PM behavior along side some new PM RUNS, but are missing
  this flag if new PM is enabled by default.
- Specify -O without the number. Based on getOptimizationLevel(), it seems the
  default is 2, and the IR appears to be the same when changed to -O2, so
  update the test to explicitly say -O2 and provide 
-fno-experimental-new-pass-manager`.

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

Modified:
cfe/trunk/test/CodeGen/aggregate-assign-call.c
cfe/trunk/test/CodeGen/arm_acle.c
cfe/trunk/test/CodeGen/cspgo-instrumentation.c
cfe/trunk/test/CodeGen/cspgo-instrumentation_lto.c
cfe/trunk/test/CodeGen/cspgo-instrumentation_thinlto.c
cfe/trunk/test/CodeGen/pgo-instrumentation.c
cfe/trunk/test/CodeGen/thinlto-debug-pm.c
cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
cfe/trunk/test/CodeGenCXX/conditional-temporaries.cpp
cfe/trunk/test/CodeGenCXX/member-function-pointer-calls.cpp
cfe/trunk/test/CodeGenObjC/os_log.m
cfe/trunk/test/CodeGenObjCXX/os_log.mm
cfe/trunk/test/Misc/pr32207.c

Modified: cfe/trunk/test/CodeGen/aggregate-assign-call.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aggregate-assign-call.c?rev=364066=364065=364066=diff
==
--- cfe/trunk/test/CodeGen/aggregate-assign-call.c (original)
+++ cfe/trunk/test/CodeGen/aggregate-assign-call.c Fri Jun 21 09:03:06 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O1 -S -emit-llvm -o - %s 
| FileCheck %s --check-prefix=O1
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O1 
-fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=O1,O1-LEGACY
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O1 
-fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=O1,O1-NEWPM
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O0 -S -emit-llvm -o - %s 
| FileCheck %s --check-prefix=O0
 //
 // Ensure that we place appropriate lifetime markers around indirectly returned
@@ -50,34 +51,32 @@ struct S baz(int i, volatile int *j) {
   struct S r;
   // O1: %[[TMP1_ALLOCA:[^ ]+]] = alloca %struct.S
   // O1: %[[TMP2_ALLOCA:[^ ]+]] = alloca %struct.S
-  // O1: br label %[[DO_BODY:.+]]
 
   do {
-// O1: [[DO_BODY]]:
 // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8*
-// O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]])
-// O1: br i1 {{[^,]+}}, label %[[IF_THEN:[^,]+]], label %[[IF_END:[^,]+]]
+// O1-LEGACY: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]])
+// O1-NEWPM: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* nonnull 
%[[P]])
 //
-// O1: [[IF_THEN]]:
-// O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8*
-// O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]])
-// O1: br label %[[DO_END:.*]]
+// O1-LEGACY: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8*
+// O1-LEGACY: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]])
+// O1-NEWPM: %[[TMP3:.*]] = bitcast %struct.S* %[[TMP2_ALLOCA]] to i8*
+// O1-NEWPM: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* nonnull 
%[[P]])
 //
-// O1: [[IF_END]]:
-// O1: call void @foo_int(%struct.S* sret %[[TMP1_ALLOCA]],
+// O1-LEGACY: call void @foo_int(%struct.S* sret %[[TMP1_ALLOCA]],
+// O1-NEWPM: call void @foo_int(%struct.S* nonnull sret %[[TMP1_ALLOCA]],
 // O1: call void @llvm.memcpy
-// O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8*
-// O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]])
-// O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP2_ALLOCA]] to i8*
-// O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]])
-// O1: call void @foo_int(%struct.S* sret %[[TMP2_ALLOCA]],
+// O1-LEGACY: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8*
+// O1-LEGACY: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]])
+// O1-NEWPM: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* nonnull 
%[[P]])
+// O1-LEGACY: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP2_ALLOCA]] to i8*
+// O1-LEGACY: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]])
+// O1-NEWPM: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* nonnull 
%[[TMP3]])
+// O1-LEGACY: call void @foo_int(%struct.S* sret %[[TMP2_ALLOCA]],
+// O1-NEWPM: call void @foo_int(%struct.S* nonnull sret %[[TMP2_ALLOCA]],
 // O1: call void @llvm.memcpy
-// 

r363971 - [clang][NewPM] Do not eliminate available_externally durng `-O2 -flto` runs

2019-06-20 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jun 20 12:44:51 2019
New Revision: 363971

URL: http://llvm.org/viewvc/llvm-project?rev=363971=rev
Log:
[clang][NewPM] Do not eliminate available_externally durng `-O2 -flto` runs

This fixes CodeGen/available-externally-suppress.c when the new pass manager is
turned on by default. available_externally was not emitted during -O2 -flto
runs when it should still be retained for link time inlining purposes. This can
be fixed by checking that we aren't LTOPrelinking when adding the
EliminateAvailableExternallyPass.

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

Modified:
cfe/trunk/test/CodeGen/available-externally-suppress.c

Modified: cfe/trunk/test/CodeGen/available-externally-suppress.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/available-externally-suppress.c?rev=363971=363970=363971=diff
==
--- cfe/trunk/test/CodeGen/available-externally-suppress.c (original)
+++ cfe/trunk/test/CodeGen/available-externally-suppress.c Thu Jun 20 12:44:51 
2019
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin10 %s | 
FileCheck %s
-// RUN: %clang_cc1 -O2 -fno-inline -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s
-// RUN: %clang_cc1 -flto -O2 -fno-inline -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s -check-prefix=LTO
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -O2 -fno-inline 
-emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -flto -O2 -fno-inline 
-emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s 
-check-prefix=LTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -O2 -fno-inline -emit-llvm 
-o - -triple x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -flto -O2 -fno-inline 
-emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s 
-check-prefix=LTO
 
 // Ensure that we don't emit available_externally functions at -O0.
 // Also should not emit them at -O2, unless -flto is present in which case


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


r363969 - [clang][NewPM] Move EntryExitInstrumenterPass to the start of the pipeline

2019-06-20 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jun 20 12:35:25 2019
New Revision: 363969

URL: http://llvm.org/viewvc/llvm-project?rev=363969=rev
Log:
[clang][NewPM] Move EntryExitInstrumenterPass to the start of the pipeline

This fixes CodeGen/x86_64-instrument-functions.c when running under the new
pass manager. The pass should go before any other pass to prevent
`__cyg_profile_func_enter/exit()` from not being emitted by inlined functions.

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/x86_64-instrument-functions.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=363969=363968=363969=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 20 12:35:25 2019
@@ -67,6 +67,7 @@
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
@@ -1131,6 +1132,11 @@ void EmitAssemblyHelper::EmitAssemblyWit
   // configure the pipeline.
   PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
 
+  PB.registerPipelineStartEPCallback([](ModulePassManager ) {
+MPM.addPass(createModuleToFunctionPassAdaptor(
+EntryExitInstrumenterPass(/*PostInlining=*/false)));
+  });
+
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out

Modified: cfe/trunk/test/CodeGen/x86_64-instrument-functions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-instrument-functions.c?rev=363969=363968=363969=diff
==
--- cfe/trunk/test/CodeGen/x86_64-instrument-functions.c (original)
+++ cfe/trunk/test/CodeGen/x86_64-instrument-functions.c Thu Jun 20 12:35:25 
2019
@@ -1,6 +1,9 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions 
-O2 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S 
-finstrument-functions-after-inlining -O2 -o - %s | FileCheck 
-check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | 
FileCheck -check-prefix=NOINLINE %s
+
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | 
FileCheck -check-prefix=NOINLINE %s
 
 // It's not so nice having asm tests in Clang, but we need to check that we set
 // up the pipeline correctly in order to have the instrumentation inserted.


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


r363846 - [clang][NewPM] Fixing remaining -O0 tests that are broken under new PM

2019-06-19 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Wed Jun 19 10:41:30 2019
New Revision: 363846

URL: http://llvm.org/viewvc/llvm-project?rev=363846=rev
Log:
[clang][NewPM] Fixing remaining -O0 tests that are broken under new PM

- CodeGen/flatten.c will fail under new PM becausec the new PM AlwaysInliner
  seems to intentionally inline functions but not call sites marked with
  alwaysinline (D23299)
- Tests that check remarks happen to check them for the inliner which is not
  turned on at O0. These tests just check that remarks work, but we can make
  separate tests for the new PM with -O1 so we can turn on the inliner and
  check the remarks with minimal changes.

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

Added:
cfe/trunk/test/Frontend/optimization-remark-new-pm.c
cfe/trunk/test/Frontend/optimization-remark-with-hotness-new-pm.c
Modified:
cfe/trunk/test/CMakeLists.txt
cfe/trunk/test/CodeGen/flatten.c
cfe/trunk/test/CodeGenCXX/flatten.cpp
cfe/trunk/test/Frontend/optimization-remark-line-directive.c
cfe/trunk/test/Frontend/optimization-remark-with-hotness.c
cfe/trunk/test/Frontend/optimization-remark.c
cfe/trunk/test/lit.cfg.py
cfe/trunk/test/lit.site.cfg.py.in

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=363846=363845=363846=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed Jun 19 10:41:30 2019
@@ -23,6 +23,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_ENABLE_ARCMT
   CLANG_ENABLE_STATIC_ANALYZER
   ENABLE_BACKTRACES
+  ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
   HAVE_LIBZ
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
   LLVM_ENABLE_PLUGINS)

Modified: cfe/trunk/test/CodeGen/flatten.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/flatten.c?rev=363846=363845=363846=diff
==
--- cfe/trunk/test/CodeGen/flatten.c (original)
+++ cfe/trunk/test/CodeGen/flatten.c Wed Jun 19 10:41:30 2019
@@ -1,3 +1,9 @@
+// UNSUPPORTED: experimental-new-pass-manager
+// Currently, different code seems to be intentionally generated under the new
+// PM since we alwaysinline functions and not callsites under new PM.
+// Under new PM, f() will not be inlined from g() since f is not marked as
+// alwaysinline.
+
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu %s -emit-llvm -o - | FileCheck %s
 
 void f(void) {}

Modified: cfe/trunk/test/CodeGenCXX/flatten.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/flatten.cpp?rev=363846=363845=363846=diff
==
--- cfe/trunk/test/CodeGenCXX/flatten.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/flatten.cpp Wed Jun 19 10:41:30 2019
@@ -1,3 +1,7 @@
+// UNSUPPORTED: experimental-new-pass-manager
+// See the comment for CodeGen/flatten.c on why this is unsupported with the 
new
+// PM.
+
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -std=c++11 %s -emit-llvm -o - | 
FileCheck %s
 
 void f(void) {}

Modified: cfe/trunk/test/Frontend/optimization-remark-line-directive.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-line-directive.c?rev=363846=363845=363846=diff
==
--- cfe/trunk/test/Frontend/optimization-remark-line-directive.c (original)
+++ cfe/trunk/test/Frontend/optimization-remark-line-directive.c Wed Jun 19 
10:41:30 2019
@@ -2,7 +2,11 @@
 // directives. We cannot map #line directives back to
 // a SourceLocation.
 
-// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only 
-dwarf-column-info -emit-llvm-only -verify
+// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only 
-dwarf-column-info -emit-llvm-only -verify -fno-experimental-new-pass-manager
+
+// The new PM inliner is not added to the default pipeline at O0, so we add
+// some optimizations to trigger it.
+// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -O1 
-debug-info-kind=line-tables-only -dwarf-column-info -emit-llvm-only -verify
 
 int foo(int x, int y) __attribute__((always_inline));
 int foo(int x, int y) { return x + y; }

Added: cfe/trunk/test/Frontend/optimization-remark-new-pm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-new-pm.c?rev=363846=auto
==
--- cfe/trunk/test/Frontend/optimization-remark-new-pm.c (added)
+++ cfe/trunk/test/Frontend/optimization-remark-new-pm.c Wed Jun 19 10:41:30 
2019
@@ -0,0 +1,20 @@
+// Verify that remarks for the inliner appear. The remarks under the new PM 
will
+// be slightly different than those emitted by the legacy PM. The new PM 
inliner
+// also doesnot appear to be added at O0, so we test at O1.
+// RUN: %clang_cc1 %s 

r363287 - [clang][NewPM] Fix broken -O0 test from missing assumptions

2019-06-13 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jun 13 11:18:40 2019
New Revision: 363287

URL: http://llvm.org/viewvc/llvm-project?rev=363287=rev
Log:
[clang][NewPM] Fix broken -O0 test from missing assumptions

Add an AssumptionCache callback to the InlineFuntionInfo used for the
AlwaysInlinerPass to match codegen of the AlwaysInlinerLegacyPass to generate
llvm.assume. This fixes CodeGen/builtin-movdir.c when new PM is enabled by
default.

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

Modified:
cfe/trunk/test/CodeGen/builtin-movdir.c
cfe/trunk/test/CodeGen/lto-newpm-pipeline.c

Modified: cfe/trunk/test/CodeGen/builtin-movdir.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-movdir.c?rev=363287=363286=363287=diff
==
--- cfe/trunk/test/CodeGen/builtin-movdir.c (original)
+++ cfe/trunk/test/CodeGen/builtin-movdir.c Thu Jun 13 11:18:40 2019
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple 
x86_64-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s 
-emit-llvm -o - | FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown 
-target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | 
FileCheck %s --check-prefix=X86 --check-prefix=CHECK
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fno-experimental-new-pass-manager -triple x86_64-unknown-unknown 
-target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | 
FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fno-experimental-new-pass-manager -triple i386-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefix=X86 --check-prefix=CHECK
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fexperimental-new-pass-manager -triple x86_64-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefix=X86_64 --check-prefix=CHECK
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fexperimental-new-pass-manager -triple i386-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefix=X86 --check-prefix=CHECK
 
 #include 
 #include 

Modified: cfe/trunk/test/CodeGen/lto-newpm-pipeline.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lto-newpm-pipeline.c?rev=363287=363286=363287=diff
==
--- cfe/trunk/test/CodeGen/lto-newpm-pipeline.c (original)
+++ cfe/trunk/test/CodeGen/lto-newpm-pipeline.c Thu Jun 13 11:18:40 2019
@@ -27,6 +27,7 @@
 
 // CHECK-FULL-O0: Starting llvm::Module pass manager run.
 // CHECK-FULL-O0: Running pass: AlwaysInlinerPass
+// CHECK-FULL-O0-NEXT: Running analysis: InnerAnalysisManagerProxy
 // CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
@@ -34,6 +35,7 @@
 
 // CHECK-THIN-O0: Starting llvm::Module pass manager run.
 // CHECK-THIN-O0: Running pass: AlwaysInlinerPass
+// CHECK-THIN-O0-NEXT: Running analysis: InnerAnalysisManagerProxy
 // CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass


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


r363281 - [clang][NewPM] Fix split debug test

2019-06-13 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jun 13 10:40:03 2019
New Revision: 363281

URL: http://llvm.org/viewvc/llvm-project?rev=363281=rev
Log:
[clang][NewPM] Fix split debug test

This contains the part of D62225 which fixes CodeGen/split-debug-single-file.c
by not placing .dwo sections when using -enable-split-dwarf=split.

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/split-debug-single-file.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=363281=363280=363281=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 13 10:40:03 2019
@@ -1275,7 +1275,8 @@ void EmitAssemblyHelper::EmitAssemblyWit
 NeedCodeGen = true;
 CodeGenPasses.add(
 createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
-if (!CodeGenOpts.SplitDwarfFile.empty()) {
+if (!CodeGenOpts.SplitDwarfFile.empty() &&
+CodeGenOpts.getSplitDwarfMode() == CodeGenOptions::SplitFileFission) {
   DwoOS = openOutputFile(CodeGenOpts.SplitDwarfFile);
   if (!DwoOS)
 return;

Modified: cfe/trunk/test/CodeGen/split-debug-single-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-debug-single-file.c?rev=363281=363280=363281=diff
==
--- cfe/trunk/test/CodeGen/split-debug-single-file.c (original)
+++ cfe/trunk/test/CodeGen/split-debug-single-file.c Thu Jun 13 10:40:03 2019
@@ -2,13 +2,19 @@
 
 // Testing to ensure -enable-split-dwarf=single allows to place .dwo sections 
into regular output object.
 //  RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
-//  RUN:   -enable-split-dwarf=single -split-dwarf-file %t.o -emit-obj -o %t.o 
%s
+//  RUN:   -enable-split-dwarf=single -split-dwarf-file %t.o -emit-obj -o %t.o 
%s -fno-experimental-new-pass-manager
+//  RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SINGLE %s
+//  RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
+//  RUN:   -enable-split-dwarf=single -split-dwarf-file %t.o -emit-obj -o %t.o 
%s -fexperimental-new-pass-manager
 //  RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SINGLE %s
 //  MODE-SINGLE: .dwo
 
 // Testing to ensure -enable-split-dwarf=split does not place .dwo sections 
into regular output object.
 //  RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
-//  RUN:   -enable-split-dwarf=split -split-dwarf-file %t.o -emit-obj -o %t.o 
%s
+//  RUN:   -enable-split-dwarf=split -split-dwarf-file %t.o -emit-obj -o %t.o 
%s -fno-experimental-new-pass-manager
+//  RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SPLIT %s
+//  RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
+//  RUN:   -enable-split-dwarf=split -split-dwarf-file %t.o -emit-obj -o %t.o 
%s -fexperimental-new-pass-manager
 //  RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SPLIT %s
 //  MODE-SPLIT-NOT: .dwo
 


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


r363278 - [clang][NewPM] Fix broken profile test

2019-06-13 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jun 13 10:25:36 2019
New Revision: 363278

URL: http://llvm.org/viewvc/llvm-project?rev=363278=rev
Log:
[clang][NewPM] Fix broken profile test

This contains the part of D62225 which fixes Profile/gcc-flag-compatibility.c
by adding the pass that allows default profile generation to work under the new
PM. It seems that ./default.profraw was not being generated with new PM enabled.

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/Profile/gcc-flag-compatibility.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=363278=363277=363278=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 13 10:25:36 2019
@@ -60,6 +60,7 @@
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/InstrProfiling.h"
 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
+#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -1216,6 +1217,11 @@ void EmitAssemblyHelper::EmitAssemblyWit
 
 if (CodeGenOpts.OptimizationLevel == 0)
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
+
+if (CodeGenOpts.hasProfileIRInstr()) {
+  // This file is stored as the ProfileFile.
+  MPM.addPass(PGOInstrumentationGenCreateVar(PGOOpt->ProfileFile));
+}
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We

Modified: cfe/trunk/test/Profile/gcc-flag-compatibility.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/gcc-flag-compatibility.c?rev=363278=363277=363278=diff
==
--- cfe/trunk/test/Profile/gcc-flag-compatibility.c (original)
+++ cfe/trunk/test/Profile/gcc-flag-compatibility.c Thu Jun 13 10:25:36 2019
@@ -7,25 +7,29 @@
 // -fprofile-use=Uses the profile file /default.profdata
 // -fprofile-use=/file   Uses the profile file /file
 
-// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck 
-check-prefix=PROFILE-GEN %s
+// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate 
-fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN %s
+// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate 
-fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN %s
 // PROFILE-GEN: __llvm_profile_filename
 
 // Check that -fprofile-generate=/path/to generates /path/to/default.profraw
-// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to | 
FileCheck -check-prefix=PROFILE-GEN-EQ %s
+// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to 
-fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN-EQ %s
+// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to 
-fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN-EQ %s
 // PROFILE-GEN-EQ: constant [{{.*}} x i8] c"/path/to{{/|\\5C}}{{.*}}\00"
 
 // Check that -fprofile-use=some/path reads some/path/default.profdata
 // RUN: rm -rf %t.dir
 // RUN: mkdir -p %t.dir/some/path
 // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o 
%t.dir/some/path/default.profdata
-// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-2 %s
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path -fno-experimental-new-pass-manager | FileCheck 
-check-prefix=PROFILE-USE-2 %s
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path -fexperimental-new-pass-manager | FileCheck 
-check-prefix=PROFILE-USE-2 %s
 // PROFILE-USE-2: = !{!"branch_weights", i32 101, i32 2}
 
 // Check that -fprofile-use=some/path/file.prof reads some/path/file.prof
 // RUN: rm -rf %t.dir
 // RUN: mkdir -p %t.dir/some/path
 // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o 
%t.dir/some/path/file.prof
-// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path/file.prof | FileCheck 
-check-prefix=PROFILE-USE-3 %s
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path/file.prof -fno-experimental-new-pass-manager | 
FileCheck -check-prefix=PROFILE-USE-3 %s
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path/file.prof -fexperimental-new-pass-manager | 
FileCheck -check-prefix=PROFILE-USE-3 %s
 // PROFILE-USE-3: = !{!"branch_weights", i32 101, i32 2}
 
 int X = 0;


___
cfe-commits mailing list

r363277 - [clang][NewPM] Fix broken -O0 test from the AlwaysInliner

2019-06-13 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jun 13 09:45:29 2019
New Revision: 363277

URL: http://llvm.org/viewvc/llvm-project?rev=363277=rev
Log:
[clang][NewPM] Fix broken -O0 test from the AlwaysInliner

This contains the part of D62225 which prevents insertion of lifetime
intrinsics when creating the AlwaysInliner. This fixes the following tests
when the new PM is enabled by default:

Clang :: CodeGen/aarch64-neon-across.c
Clang :: CodeGen/aarch64-neon-fcvt-intrinsics.c
Clang :: CodeGen/aarch64-neon-fma.c
Clang :: CodeGen/aarch64-neon-perm.c
Clang :: CodeGen/aarch64-neon-tbl.c
Clang :: CodeGen/aarch64-poly128.c
Clang :: CodeGen/aarch64-v8.2a-neon-intrinsics.c
Clang :: CodeGen/arm-neon-fma.c
Clang :: CodeGen/arm-neon-numeric-maxmin.c
Clang :: CodeGen/arm-neon-vcvtX.c
Clang :: CodeGen/avx-builtins.c
Clang :: CodeGen/builtins-ppc-p9vector.c
Clang :: CodeGen/builtins-ppc-vsx.c
Clang :: CodeGen/lifetime.c
Clang :: CodeGen/sse-builtins.c
Clang :: CodeGen/sse2-builtins.c

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/lifetime.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=363277=363276=363277=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 13 09:45:29 2019
@@ -,8 +,10 @@ void EmitAssemblyHelper::EmitAssemblyWit
 MPM.addPass(InstrProfiling(*Options, false));
 
   // Build a minimal pipeline based on the semantics required by Clang,
-  // which is just that always inlining occurs.
-  MPM.addPass(AlwaysInlinerPass());
+  // which is just that always inlining occurs. Further, disable generating
+  // lifetime intrinsics to avoid enabling further optimizations during
+  // code generation.
+  MPM.addPass(AlwaysInlinerPass(/*InsertLifetimeIntrinsics=*/false));
 
   // At -O0 we directly run necessary sanitizer passes.
   if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds))

Modified: cfe/trunk/test/CodeGen/lifetime.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime.c?rev=363277=363276=363277=diff
==
--- cfe/trunk/test/CodeGen/lifetime.c (original)
+++ cfe/trunk/test/CodeGen/lifetime.c Thu Jun 13 09:45:29 2019
@@ -1,7 +1,8 @@
-// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0
+// RUN: %clang -S -emit-llvm -o - -O0 -fno-experimental-new-pass-manager %s | 
FileCheck %s -check-prefix=O0
 // RUN: %clang -S -emit-llvm -o - -O1 -fno-experimental-new-pass-manager %s | 
FileCheck %s -check-prefix=O1
 // RUN: %clang -S -emit-llvm -o - -O2 -fno-experimental-new-pass-manager %s | 
FileCheck %s -check-prefix=O2
 // RUN: %clang -S -emit-llvm -o - -O3 -fno-experimental-new-pass-manager %s | 
FileCheck %s -check-prefix=O3
+// RUN: %clang -S -emit-llvm -o - -O0 -fexperimental-new-pass-manager %s | 
FileCheck %s -check-prefix=O0
 
 extern void use(char *a);
 


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


r361302 - Remove unicode character from test

2019-05-21 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Tue May 21 13:12:00 2019
New Revision: 361302

URL: http://llvm.org/viewvc/llvm-project?rev=361302=rev
Log:
Remove unicode character from test

Modified:
cfe/trunk/test/SemaObjC/nullability_macro.m

Modified: cfe/trunk/test/SemaObjC/nullability_macro.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nullability_macro.m?rev=361302=361301=361302=diff
==
--- cfe/trunk/test/SemaObjC/nullability_macro.m (original)
+++ cfe/trunk/test/SemaObjC/nullability_macro.m Tue May 21 13:12:00 2019
@@ -1,12 +1,13 @@
 // Test that nullability attributes still get merged even though they are
 // wrapped with a MacroQualifiedType. This should just compile with no errors.
 // RUN: %clang_cc1 %s -Wno-objc-root-class -fsyntax-only -verify
+// expected-no-diagnostics
 #define UI_APPEARANCE_SELECTOR 
__attribute__((annotate("ui_appearance_selector")))
 
 @class UIColor;
 
 @interface Test
-@property(null_resettable, nonatomic, strong) UIColor *onTintColor 
UI_APPEARANCE_SELECTOR; // expected-warning{{treating Unicode character as 
whitespace}}
+@property(null_resettable, nonatomic, strong) UIColor *onTintColor 
UI_APPEARANCE_SELECTOR;
 @end
 
 @implementation Test


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


Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"

2019-05-20 Thread Leonard Chan via cfe-commits
Thanks for bringing this up! I submitted r361205 which should fix this. The
problem seemed to be that stripOuterNullability() was missing checks for
AttributedTypes that were wrapped in the MacroQualifiedType which this
patch introduces, so I just added a check for that type also. The reason
replacing UI_APPEARANCE_SELECTOR with
__attribute__((annotate("ui_appearance_selector"))) is because this type
wraps AttributedTypes for special cases when the entire attribute is
declared in a macro.

*From: *Nico Weber 
*Date: *Mon, May 20, 2019 at 11:34 AM
*To: *Leonard Chan
*Cc: *cfe-commits

Hello, it seems this broke building some iOS programs.
>
> $ cat test.m
> # define UI_APPEARANCE_SELECTOR
> __attribute__((annotate("ui_appearance_selector")))
>
> @class UIColor;
>
> @interface Test
> @property(null_resettable, nonatomic, strong)  UIColor *onTintColor
> UI_APPEARANCE_SELECTOR;
> @end
>
> @implementation Test
> - (void)setOnTintColor:(nullable UIColor *)onTintColor {
> }
>
> @end
>
> $ out/gn/bin/clang -c test.m -Wno-objc-root-class
> test.m:10:44: error: nullability specifier 'nullable' conflicts with
> existing specifier '_Null_unspecified'
> - (void)setOnTintColor:(nullable UIColor *)onTintColor {
>^
> 1 error generated.
>
>
> Before this change, that compiled fine. Surprisingly, it still builds fine
> if UI_APPEARANCE_SELECTOR is replaced by
> `__attribute__((annotate("ui_appearance_selector")))` in the source code,
> even though both lead to the same -E output.
>
> *From: *Leonard Chan via cfe-commits 
> *Date: *Mon, May 6, 2019 at 11:17 PM
> *To: * 
>
> Author: leonardchan
>> Date: Mon May  6 20:20:17 2019
>> New Revision: 360109
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=360109=rev
>> Log:
>> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an
>> attribute declaration"
>>
>> Updated with fix for read of uninitialized memory.
>>
>> Added:
>> cfe/trunk/test/Frontend/macro_defined_type.cpp
>> cfe/trunk/test/Sema/address_space_print_macro.c
>> Modified:
>> cfe/trunk/include/clang/AST/ASTContext.h
>> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>> cfe/trunk/include/clang/AST/Type.h
>> cfe/trunk/include/clang/AST/TypeLoc.h
>> cfe/trunk/include/clang/AST/TypeNodes.def
>> cfe/trunk/include/clang/Parse/Parser.h
>> cfe/trunk/include/clang/Sema/ParsedAttr.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
>> cfe/trunk/lib/AST/ASTContext.cpp
>> cfe/trunk/lib/AST/ASTDiagnostic.cpp
>> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
>> cfe/trunk/lib/AST/ItaniumMangle.cpp
>> cfe/trunk/lib/AST/Type.cpp
>> cfe/trunk/lib/AST/TypePrinter.cpp
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>> cfe/trunk/lib/Parse/ParseDecl.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaStmt.cpp
>> cfe/trunk/lib/Sema/SemaType.cpp
>> cfe/trunk/lib/Sema/TreeTransform.h
>> cfe/trunk/lib/Serialization/ASTReader.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/test/Sema/address_spaces.c
>> cfe/trunk/test/SemaObjC/externally-retained.m
>> cfe/trunk/test/SemaObjC/gc-attributes.m
>> cfe/trunk/test/SemaObjC/mrc-weak.m
>> cfe/trunk/test/SemaObjCXX/gc-attributes.mm
>> cfe/trunk/tools/libclang/CIndex.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=360109=360108=360109=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon May  6 20:20:17 2019
>> @@ -1441,6 +1441,9 @@ public:
>>
>>QualType getParenType(QualType NamedType) const;
>>
>> +  QualType getMacroQualifiedType(QualType UnderlyingTy,
>> + const IdentifierInfo *MacroII) const;
>> +
>>QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
>>   NestedNameSpecifier *NNS, QualType
>> NamedType,
>>   TagDecl *OwnedTagDecl = nullptr) const;
>>
>> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>> URL:
>> http://llvm.org/viewvc/llvm-proj

r361205 - [Sema] Fix for build on some iOS programs.

2019-05-20 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon May 20 15:42:19 2019
New Revision: 361205

URL: http://llvm.org/viewvc/llvm-project?rev=361205=rev
Log:
[Sema] Fix for build on some iOS programs.

Nullability attributes weren't being stripped for AttributedTypes that
were wrapped in a MacroQualifiedType. This fix adds a check for this
type and a test.

Added:
cfe/trunk/test/SemaObjC/nullability_macro.m
Modified:
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=361205=361204=361205=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Mon May 20 15:42:19 2019
@@ -3929,7 +3929,11 @@ AttributedType::getImmediateNullability(
 }
 
 Optional AttributedType::stripOuterNullability(QualType ) {
-  if (auto attributed = dyn_cast(T.getTypePtr())) {
+  QualType AttrTy = T;
+  if (auto MacroTy = dyn_cast(T))
+AttrTy = MacroTy->getUnderlyingType();
+
+  if (auto attributed = dyn_cast(AttrTy)) {
 if (auto nullability = attributed->getImmediateNullability()) {
   T = attributed->getModifiedType();
   return nullability;

Added: cfe/trunk/test/SemaObjC/nullability_macro.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nullability_macro.m?rev=361205=auto
==
--- cfe/trunk/test/SemaObjC/nullability_macro.m (added)
+++ cfe/trunk/test/SemaObjC/nullability_macro.m Mon May 20 15:42:19 2019
@@ -0,0 +1,16 @@
+// Test that nullability attributes still get merged even though they are
+// wrapped with a MacroQualifiedType. This should just compile with no errors.
+// RUN: %clang_cc1 %s -Wno-objc-root-class -fsyntax-only -verify
+#define UI_APPEARANCE_SELECTOR 
__attribute__((annotate("ui_appearance_selector")))
+
+@class UIColor;
+
+@interface Test
+@property(null_resettable, nonatomic, strong) UIColor *onTintColor 
UI_APPEARANCE_SELECTOR; // expected-warning{{treating Unicode character as 
whitespace}}
+@end
+
+@implementation Test
+- (void)setOnTintColor:(nullable UIColor *)onTintColor {
+}
+
+@end


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


r360720 - Fix bots by adding target triple to test.

2019-05-14 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Tue May 14 15:37:34 2019
New Revision: 360720

URL: http://llvm.org/viewvc/llvm-project?rev=360720=rev
Log:
Fix bots by adding target triple to test.

Modified:
cfe/trunk/test/CodeGen/hwasan-new-pm.c

Modified: cfe/trunk/test/CodeGen/hwasan-new-pm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/hwasan-new-pm.c?rev=360720=360719=360720=diff
==
--- cfe/trunk/test/CodeGen/hwasan-new-pm.c (original)
+++ cfe/trunk/test/CodeGen/hwasan-new-pm.c Tue May 14 15:37:34 2019
@@ -2,19 +2,19 @@
 // We run them under different optimizations and LTOs to ensure the IR is still
 // being instrumented properly.
 
-// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=hwaddress %s | FileCheck %s 
--check-prefixes=CHECK,HWASAN,HWASAN-NOOPT
-// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=hwaddress -flto %s | FileCheck %s 
--check-prefixes=CHECK,HWASAN,HWASAN-NOOPT
-// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=hwaddress -flto=thin %s | FileCheck %s 
--check-prefixes=CHECK,HWASAN,HWASAN-NOOPT
-// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager 
-fsanitize=hwaddress %s | FileCheck %s --check-prefixes=CHECK,HWASAN
-// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager 
-fsanitize=hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,HWASAN
-// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager 
-fsanitize=hwaddress -flto=thin %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - 
-fexperimental-new-pass-manager -fsanitize=hwaddress %s | FileCheck %s 
--check-prefixes=CHECK,HWASAN,HWASAN-NOOPT
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - 
-fexperimental-new-pass-manager -fsanitize=hwaddress -flto %s | FileCheck %s 
--check-prefixes=CHECK,HWASAN,HWASAN-NOOPT
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - 
-fexperimental-new-pass-manager -fsanitize=hwaddress -flto=thin %s | FileCheck 
%s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 
-fexperimental-new-pass-manager -fsanitize=hwaddress %s | FileCheck %s 
--check-prefixes=CHECK,HWASAN
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 
-fexperimental-new-pass-manager -fsanitize=hwaddress -flto %s | FileCheck %s 
--check-prefixes=CHECK,HWASAN
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 
-fexperimental-new-pass-manager -fsanitize=hwaddress -flto=thin %s | FileCheck 
%s
 
-// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=kernel-hwaddress %s | FileCheck %s 
--check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT
-// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=kernel-hwaddress -flto %s | FileCheck %s 
--check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT
-// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=kernel-hwaddress -flto=thin %s | FileCheck %s 
--check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT
-// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager 
-fsanitize=kernel-hwaddress %s | FileCheck %s --check-prefixes=CHECK,KHWASAN
-// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager 
-fsanitize=kernel-hwaddress -flto %s | FileCheck %s 
--check-prefixes=CHECK,KHWASAN
-// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager 
-fsanitize=kernel-hwaddress -flto=thin %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - 
-fexperimental-new-pass-manager -fsanitize=kernel-hwaddress %s | FileCheck %s 
--check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - 
-fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto %s | 
FileCheck %s --check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - 
-fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto=thin %s | 
FileCheck %s --check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 
-fexperimental-new-pass-manager -fsanitize=kernel-hwaddress %s | FileCheck %s 
--check-prefixes=CHECK,KHWASAN
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 
-fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto %s | 
FileCheck %s --check-prefixes=CHECK,KHWASAN
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 
-fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto=thin %s | 
FileCheck %s
 
 int foo(int *a) { return *a; }
 


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


r360707 - [NewPM] Port HWASan and Kernel HWASan

2019-05-14 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Tue May 14 14:17:21 2019
New Revision: 360707

URL: http://llvm.org/viewvc/llvm-project?rev=360707=rev
Log:
[NewPM] Port HWASan and Kernel HWASan

Port hardware assisted address sanitizer to new PM following the same 
guidelines as msan and tsan.

Changes:
- Separate HWAddressSanitizer into a pass class and a sanitizer class.
- Create new PM wrapper pass for the sanitizer class.
- Use the getOrINsert pattern for some module level initialization declarations.
- Also enable kernel-kwasan in new PM
- Update llvm tests and add clang test.

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

Added:
cfe/trunk/test/CodeGen/hwasan-new-pm.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=360707=360706=360707=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue May 14 14:17:21 2019
@@ -57,6 +57,7 @@
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
 #include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
+#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/InstrProfiling.h"
 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
@@ -265,12 +266,13 @@ static void addHWAddressSanitizerPasses(
   static_cast(Builder);
   const CodeGenOptions  = BuilderWrapper.getCGOpts();
   bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
-  PM.add(createHWAddressSanitizerPass(/*CompileKernel*/ false, Recover));
+  PM.add(
+  createHWAddressSanitizerLegacyPassPass(/*CompileKernel*/ false, 
Recover));
 }
 
 static void addKernelHWAddressSanitizerPasses(const PassManagerBuilder 
,
 legacy::PassManagerBase ) {
-  PM.add(createHWAddressSanitizerPass(
+  PM.add(createHWAddressSanitizerLegacyPassPass(
   /*CompileKernel*/ true, /*Recover*/ true));
 }
 
@@ -962,6 +964,17 @@ static void addSanitizersAtO0(ModulePass
   if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
 MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
   }
+
+  if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
+bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
+MPM.addPass(createModuleToFunctionPassAdaptor(
+HWAddressSanitizerPass(/*CompileKernel=*/false, Recover)));
+  }
+
+  if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) {
+MPM.addPass(createModuleToFunctionPassAdaptor(
+HWAddressSanitizerPass(/*CompileKernel=*/true, /*Recover=*/true)));
+  }
 }
 
 /// A clean version of `EmitAssembly` that uses the new pass manager.
@@ -1145,6 +1158,23 @@ void EmitAssemblyHelper::EmitAssemblyWit
   UseOdrIndicator));
 });
   }
+  if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
+bool Recover =
+CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
+PB.registerOptimizerLastEPCallback(
+[Recover](FunctionPassManager ,
+  PassBuilder::OptimizationLevel Level) {
+  FPM.addPass(HWAddressSanitizerPass(
+  /*CompileKernel=*/false, Recover));
+});
+  }
+  if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) {
+PB.registerOptimizerLastEPCallback(
+[](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
+  FPM.addPass(HWAddressSanitizerPass(
+  /*CompileKernel=*/true, /*Recover=*/true));
+});
+  }
   if (Optional Options = getGCOVOptions(CodeGenOpts))
 PB.registerPipelineStartEPCallback([Options](ModulePassManager ) {
   MPM.addPass(GCOVProfilerPass(*Options));

Added: cfe/trunk/test/CodeGen/hwasan-new-pm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/hwasan-new-pm.c?rev=360707=auto
==
--- cfe/trunk/test/CodeGen/hwasan-new-pm.c (added)
+++ cfe/trunk/test/CodeGen/hwasan-new-pm.c Tue May 14 14:17:21 2019
@@ -0,0 +1,34 @@
+// Test that HWASan and KHWASan runs with the new pass manager.
+// We run them under different optimizations and LTOs to ensure the IR is still
+// being instrumented properly.
+
+// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=hwaddress %s | FileCheck %s 
--check-prefixes=CHECK,HWASAN,HWASAN-NOOPT
+// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=hwaddress -flto %s | FileCheck %s 
--check-prefixes=CHECK,HWASAN,HWASAN-NOOPT
+// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 

r360548 - Fix test to use -cc1.

2019-05-12 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Sun May 12 15:44:46 2019
New Revision: 360548

URL: http://llvm.org/viewvc/llvm-project?rev=360548=rev
Log:
Fix test to use -cc1.

Added:
cfe/trunk/test/Sema/mingw-macro-qualified-type.c
Removed:
cfe/trunk/test/Driver/mingw-macro-qualified-type.c

Removed: cfe/trunk/test/Driver/mingw-macro-qualified-type.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw-macro-qualified-type.c?rev=360547=auto
==
--- cfe/trunk/test/Driver/mingw-macro-qualified-type.c (original)
+++ cfe/trunk/test/Driver/mingw-macro-qualified-type.c (removed)
@@ -1,12 +0,0 @@
-// Ensure that builtin attributes do not get treated as user defined macros to
-// be weapped in macro qualified types. This addresses P41852.
-//
-// RUN: %clang -c %s -target i686-w64-mingw32
-
-typedef int WINBOOL;
-typedef unsigned int UINT_PTR, *PUINT_PTR;
-typedef unsigned long long ULONG64, *PULONG64;
-#define WINAPI __stdcall
-#define CALLBACK __stdcall
-
-typedef WINBOOL(CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, 
ULONG64 data, ULONG64 context);

Added: cfe/trunk/test/Sema/mingw-macro-qualified-type.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/mingw-macro-qualified-type.c?rev=360548=auto
==
--- cfe/trunk/test/Sema/mingw-macro-qualified-type.c (added)
+++ cfe/trunk/test/Sema/mingw-macro-qualified-type.c Sun May 12 15:44:46 2019
@@ -0,0 +1,13 @@
+// Ensure that builtin attributes do not get treated as user defined macros to
+// be weapped in macro qualified types. This addresses P41852.
+//
+// RUN: %clang_cc1 %s -triple i686-w64-mingw32 -fsyntax-only -verify
+// expected-no-diagnostics
+
+typedef int WINBOOL;
+typedef unsigned int UINT_PTR, *PUINT_PTR;
+typedef unsigned long long ULONG64, *PULONG64;
+#define WINAPI __stdcall
+#define CALLBACK __stdcall
+
+typedef WINBOOL(CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, 
ULONG64 data, ULONG64 context);


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


r360544 - Fix for P41852 where builtin attributes were being caught by FindLocsWithCommonFileID().

2019-05-12 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Sun May 12 14:50:01 2019
New Revision: 360544

URL: http://llvm.org/viewvc/llvm-project?rev=360544=rev
Log:
Fix for P41852 where builtin attributes were being caught by 
FindLocsWithCommonFileID().

Added:
cfe/trunk/test/Driver/mingw-macro-qualified-type.c
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=360544=360543=360544=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun May 12 14:50:01 2019
@@ -224,8 +224,9 @@ void Parser::ParseGNUAttributes(ParsedAt
 
 // If this was declared in a macro, attach the macro IdentifierInfo to the
 // parsed attribute.
-if (FindLocsWithCommonFileID(PP, AttrTokLoc, Loc)) {
-  auto  = PP.getSourceManager();
+auto  = PP.getSourceManager();
+if (!SM.isWrittenInBuiltinFile(SM.getSpellingLoc(AttrTokLoc)) &&
+FindLocsWithCommonFileID(PP, AttrTokLoc, Loc)) {
   CharSourceRange ExpansionRange = SM.getExpansionRange(AttrTokLoc);
   StringRef FoundName =
   Lexer::getSourceText(ExpansionRange, SM, PP.getLangOpts());

Added: cfe/trunk/test/Driver/mingw-macro-qualified-type.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw-macro-qualified-type.c?rev=360544=auto
==
--- cfe/trunk/test/Driver/mingw-macro-qualified-type.c (added)
+++ cfe/trunk/test/Driver/mingw-macro-qualified-type.c Sun May 12 14:50:01 2019
@@ -0,0 +1,12 @@
+// Ensure that builtin attributes do not get treated as user defined macros to
+// be weapped in macro qualified types. This addresses P41852.
+//
+// RUN: %clang -c %s -target i686-w64-mingw32
+
+typedef int WINBOOL;
+typedef unsigned int UINT_PTR, *PUINT_PTR;
+typedef unsigned long long ULONG64, *PULONG64;
+#define WINAPI __stdcall
+#define CALLBACK __stdcall
+
+typedef WINBOOL(CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, 
ULONG64 data, ULONG64 context);


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


r360465 - Add target triple to test.

2019-05-10 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Fri May 10 13:07:47 2019
New Revision: 360465

URL: http://llvm.org/viewvc/llvm-project?rev=360465=rev
Log:
Add target triple to test.

Modified:
cfe/trunk/test/Frontend/macro_defined_type.cpp

Modified: cfe/trunk/test/Frontend/macro_defined_type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/macro_defined_type.cpp?rev=360465=360464=360465=diff
==
--- cfe/trunk/test/Frontend/macro_defined_type.cpp (original)
+++ cfe/trunk/test/Frontend/macro_defined_type.cpp Fri May 10 13:07:47 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-gnu %s
 
 #define NODEREF __attribute__((noderef))
 


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


r360448 - Fix and test for assertion error in P41835.

2019-05-10 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Fri May 10 11:05:15 2019
New Revision: 360448

URL: http://llvm.org/viewvc/llvm-project?rev=360448=rev
Log:
Fix and test for assertion error in P41835.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/Frontend/macro_defined_type.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=360448=360447=360448=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri May 10 11:05:15 2019
@@ -2758,6 +2758,12 @@ QualType ASTContext::getFunctionTypeWith
 return getParenType(
 getFunctionTypeWithExceptionSpec(PT->getInnerType(), ESI));
 
+  // Might be wrapped in a macro qualified type.
+  if (const auto *MQT = dyn_cast(Orig))
+return getMacroQualifiedType(
+getFunctionTypeWithExceptionSpec(MQT->getUnderlyingType(), ESI),
+MQT->getMacroIdentifier());
+
   // Might have a calling-convention attribute.
   if (const auto *AT = dyn_cast(Orig))
 return getAttributedType(

Modified: cfe/trunk/test/Frontend/macro_defined_type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/macro_defined_type.cpp?rev=360448=360447=360448=diff
==
--- cfe/trunk/test/Frontend/macro_defined_type.cpp (original)
+++ cfe/trunk/test/Frontend/macro_defined_type.cpp Fri May 10 11:05:15 2019
@@ -13,3 +13,9 @@ void Func() {
   auto NODEREF *auto_i_ptr2 = i_ptr;
   auto NODEREF auto_i2 = i; // expected-warning{{'noderef' can only be used on 
an array or pointer type}}
 }
+
+// Added test for fix for P41835
+#define _LIBCPP_FLOAT_ABI __attribute__((pcs("aapcs")))
+struct A {
+  _LIBCPP_FLOAT_ABI int operator()() throw(); // expected-warning{{'pcs' 
calling convention ignored for this target}}
+};


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


Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"

2019-05-08 Thread Leonard Chan via cfe-commits
Just wanted to update. My latest revision (r360225) seems to have fixed the
bots. 

On Tue, May 7, 2019 at 3:50 PM Jonas Devlieghere 
wrote:

> Hi Leonard,
>
> My personal rule of thumb is that if I can fix it in something like 30
> minutes or less, I'll leave the bot red and commit a fix. Otherwise I'll
> revert my change. The problem with leaving the bot red is that if something
> else breaks, that person doesn't get a signal, and issue start to pile up.
>
> When I see a bot is red and it's blocking me, I will usually send an
> e-mail and wait about the same time for a reply, before reverting the
> change myself.
>
> Cheers,
> Jonas
>
> On Tue, May 7, 2019 at 11:20 AM Leonard Chan 
> wrote:
>
>> Thanks! It turns out that we weren't running debuginfo-tests. Trying to
>> find a mac I can ssh into to reproduce this.
>>
>> Another side question: is there usually an etiquette for how long a
>> greendragon bot is allowed to stay broken? I don't want to leave it that
>> way for too long while working on my fix if it bothers others too much.
>>
>> Thanks,
>> Leonard
>>
>> On Tue, May 7, 2019 at 10:13 AM Jonas Devlieghere 
>> wrote:
>>
>>> Hi Leonard,
>>>
>>> The test that is asserting is part of the debuginfo test. (
>>> https://github.com/llvm-project/debuginfo-tests)
>>> The reason that it's only failing on the non-incremental bot is because
>>> the incremental one isn't running those, I believe.
>>>
>>> RA stands for Release/Asserts.
>>>
>>> Hope that helps!
>>>
>>> Cheers,
>>> Jonas
>>>
>>> On Tue, May 7, 2019 at 9:44 AM Leonard Chan 
>>> wrote:
>>>
>>>> Yup, sorry for the delay. I submitted it overnight thinking it would be
>>>> fixed this time. I have one more way that I think should fix it, but before
>>>> trying it out, do you know any tips on how I can try to reproduce this
>>>> locally? I see that you're running these on an x64 mac, but I can't seem to
>>>> trigger this on our own mac builders. Also as a side question, do you what
>>>> RA stands for in "Clang Stage 1: cmake, incremental RA, using system
>>>> compiler
>>>> <http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/>"?
>>>> It seems that I'm only breaking the non-incremental RA jobs, bit the
>>>> incremental one still works fine with my change.
>>>>
>>>> Thanks,
>>>> Leonard
>>>>
>>>> On Tue, May 7, 2019, 09:26 Jonas Devlieghere 
>>>> wrote:
>>>>
>>>>> Hi Leonard,
>>>>>
>>>>> It appears that your patch is still triggering an assertion on
>>>>> GreenDragon:
>>>>> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/56255/consoleFull#312501878d489585b-5106-414a-ac11-3ff90657619c
>>>>>
>>>>> Can you please have a look?
>>>>>
>>>>> Thanks,
>>>>> Jonas
>>>>>
>>>>>
>>>>> On Mon, May 6, 2019 at 8:17 PM Leonard Chan via cfe-commits <
>>>>> cfe-commits@lists.llvm.org> wrote:
>>>>>
>>>>>> Author: leonardchan
>>>>>> Date: Mon May  6 20:20:17 2019
>>>>>> New Revision: 360109
>>>>>>
>>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=360109=rev
>>>>>> Log:
>>>>>> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition
>>>>>> is an attribute declaration"
>>>>>>
>>>>>> Updated with fix for read of uninitialized memory.
>>>>>>
>>>>>> Added:
>>>>>> cfe/trunk/test/Frontend/macro_defined_type.cpp
>>>>>> cfe/trunk/test/Sema/address_space_print_macro.c
>>>>>> Modified:
>>>>>> cfe/trunk/include/clang/AST/ASTContext.h
>>>>>> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>>>>>> cfe/trunk/include/clang/AST/Type.h
>>>>>> cfe/trunk/include/clang/AST/TypeLoc.h
>>>>>> cfe/trunk/include/clang/AST/TypeNodes.def
>>>>>> cfe/trunk/include/clang/Parse/Parser.h
>>>>>> cfe/trunk/include/clang/Sema/ParsedAttr.h
>>>>>> cfe/trunk/include/clang/Sema/Sema.h
>>>>>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>>>>>> 

r360225 - Fix for the greendragon bots.

2019-05-07 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Tue May  7 22:59:25 2019
New Revision: 360225

URL: http://llvm.org/viewvc/llvm-project?rev=360225=rev
Log:
Fix for the greendragon bots.

Adds extra checks for ObjC GC and Ownership.

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjC/mrc-weak.m

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=360225=360224=360225=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue May  7 22:59:25 2019
@@ -7612,7 +7612,9 @@ static void processTypeAttrs(TypeProcess
 // applied to ObjC builtin attributes.
 if (isa(type) && attr.hasMacroIdentifier() &&
 !type.getQualifiers().hasObjCLifetime() &&
-!type.getQualifiers().hasObjCGCAttr()) {
+!type.getQualifiers().hasObjCGCAttr() &&
+attr.getKind() != ParsedAttr::AT_ObjCGC &&
+attr.getKind() != ParsedAttr::AT_ObjCOwnership) {
   const IdentifierInfo *MacroII = attr.getMacroIdentifier();
   type = state.getSema().Context.getMacroQualifiedType(type, MacroII);
   state.setExpansionLocForMacroQualifiedType(

Modified: cfe/trunk/test/SemaObjC/mrc-weak.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/mrc-weak.m?rev=360225=360224=360225=diff
==
--- cfe/trunk/test/SemaObjC/mrc-weak.m (original)
+++ cfe/trunk/test/SemaObjC/mrc-weak.m Tue May  7 22:59:25 2019
@@ -62,6 +62,6 @@ void test_unsafe_unretained_cast(id *val
 
 void test_cast_qualifier_inference(__weak id *value) {
   __weak id *a = (id*) value;
-  __unsafe_unretained id *b = (id *)value; // expected-error {{initializing 
'__unsafe_unretained id *' with an expression of type '__weak id *' changes 
retain/release properties of pointer}}
+  __unsafe_unretained id *b = (id *)value; // expected-error {{initializing 
'id *' with an expression of type '__weak id *' changes retain/release 
properties of pointer}}
 }
 


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


Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"

2019-05-07 Thread Leonard Chan via cfe-commits
Thanks! It turns out that we weren't running debuginfo-tests. Trying to
find a mac I can ssh into to reproduce this.

Another side question: is there usually an etiquette for how long a
greendragon bot is allowed to stay broken? I don't want to leave it that
way for too long while working on my fix if it bothers others too much.

Thanks,
Leonard

On Tue, May 7, 2019 at 10:13 AM Jonas Devlieghere 
wrote:

> Hi Leonard,
>
> The test that is asserting is part of the debuginfo test. (
> https://github.com/llvm-project/debuginfo-tests)
> The reason that it's only failing on the non-incremental bot is because
> the incremental one isn't running those, I believe.
>
> RA stands for Release/Asserts.
>
> Hope that helps!
>
> Cheers,
> Jonas
>
> On Tue, May 7, 2019 at 9:44 AM Leonard Chan 
> wrote:
>
>> Yup, sorry for the delay. I submitted it overnight thinking it would be
>> fixed this time. I have one more way that I think should fix it, but before
>> trying it out, do you know any tips on how I can try to reproduce this
>> locally? I see that you're running these on an x64 mac, but I can't seem to
>> trigger this on our own mac builders. Also as a side question, do you what
>> RA stands for in "Clang Stage 1: cmake, incremental RA, using system
>> compiler
>> <http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/>"?
>> It seems that I'm only breaking the non-incremental RA jobs, bit the
>> incremental one still works fine with my change.
>>
>> Thanks,
>> Leonard
>>
>> On Tue, May 7, 2019, 09:26 Jonas Devlieghere 
>> wrote:
>>
>>> Hi Leonard,
>>>
>>> It appears that your patch is still triggering an assertion on
>>> GreenDragon:
>>> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/56255/consoleFull#312501878d489585b-5106-414a-ac11-3ff90657619c
>>>
>>> Can you please have a look?
>>>
>>> Thanks,
>>> Jonas
>>>
>>>
>>> On Mon, May 6, 2019 at 8:17 PM Leonard Chan via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>> Author: leonardchan
>>>> Date: Mon May  6 20:20:17 2019
>>>> New Revision: 360109
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=360109=rev
>>>> Log:
>>>> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is
>>>> an attribute declaration"
>>>>
>>>> Updated with fix for read of uninitialized memory.
>>>>
>>>> Added:
>>>> cfe/trunk/test/Frontend/macro_defined_type.cpp
>>>> cfe/trunk/test/Sema/address_space_print_macro.c
>>>> Modified:
>>>> cfe/trunk/include/clang/AST/ASTContext.h
>>>> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>>>> cfe/trunk/include/clang/AST/Type.h
>>>> cfe/trunk/include/clang/AST/TypeLoc.h
>>>> cfe/trunk/include/clang/AST/TypeNodes.def
>>>> cfe/trunk/include/clang/Parse/Parser.h
>>>> cfe/trunk/include/clang/Sema/ParsedAttr.h
>>>> cfe/trunk/include/clang/Sema/Sema.h
>>>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>>>> cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
>>>> cfe/trunk/lib/AST/ASTContext.cpp
>>>> cfe/trunk/lib/AST/ASTDiagnostic.cpp
>>>> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
>>>> cfe/trunk/lib/AST/ItaniumMangle.cpp
>>>> cfe/trunk/lib/AST/Type.cpp
>>>> cfe/trunk/lib/AST/TypePrinter.cpp
>>>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>>>> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>>> cfe/trunk/lib/Parse/ParseDecl.cpp
>>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>>> cfe/trunk/lib/Sema/SemaStmt.cpp
>>>> cfe/trunk/lib/Sema/SemaType.cpp
>>>> cfe/trunk/lib/Sema/TreeTransform.h
>>>> cfe/trunk/lib/Serialization/ASTReader.cpp
>>>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>>>> cfe/trunk/test/Sema/address_spaces.c
>>>> cfe/trunk/test/SemaObjC/externally-retained.m
>>>> cfe/trunk/test/SemaObjC/gc-attributes.m
>>>> cfe/trunk/test/SemaObjC/mrc-weak.m
>>>> cfe/trunk/test/SemaObjCXX/gc-attributes.mm
>>>> cfe/trunk/tools/libclang/CIndex.cpp
>>>>
>>>> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.

Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"

2019-05-07 Thread Leonard Chan via cfe-commits
Yup, sorry for the delay. I submitted it overnight thinking it would be
fixed this time. I have one more way that I think should fix it, but before
trying it out, do you know any tips on how I can try to reproduce this
locally? I see that you're running these on an x64 mac, but I can't seem to
trigger this on our own mac builders. Also as a side question, do you what
RA stands for in "Clang Stage 1: cmake, incremental RA, using system
compiler
<http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/>"?
It seems that I'm only breaking the non-incremental RA jobs, bit the
incremental one still works fine with my change.

Thanks,
Leonard

On Tue, May 7, 2019, 09:26 Jonas Devlieghere  wrote:

> Hi Leonard,
>
> It appears that your patch is still triggering an assertion on
> GreenDragon:
> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/56255/consoleFull#312501878d489585b-5106-414a-ac11-3ff90657619c
>
> Can you please have a look?
>
> Thanks,
> Jonas
>
>
> On Mon, May 6, 2019 at 8:17 PM Leonard Chan via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: leonardchan
>> Date: Mon May  6 20:20:17 2019
>> New Revision: 360109
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=360109=rev
>> Log:
>> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an
>> attribute declaration"
>>
>> Updated with fix for read of uninitialized memory.
>>
>> Added:
>> cfe/trunk/test/Frontend/macro_defined_type.cpp
>> cfe/trunk/test/Sema/address_space_print_macro.c
>> Modified:
>> cfe/trunk/include/clang/AST/ASTContext.h
>> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>> cfe/trunk/include/clang/AST/Type.h
>> cfe/trunk/include/clang/AST/TypeLoc.h
>> cfe/trunk/include/clang/AST/TypeNodes.def
>> cfe/trunk/include/clang/Parse/Parser.h
>> cfe/trunk/include/clang/Sema/ParsedAttr.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
>> cfe/trunk/lib/AST/ASTContext.cpp
>> cfe/trunk/lib/AST/ASTDiagnostic.cpp
>> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
>> cfe/trunk/lib/AST/ItaniumMangle.cpp
>> cfe/trunk/lib/AST/Type.cpp
>> cfe/trunk/lib/AST/TypePrinter.cpp
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>> cfe/trunk/lib/Parse/ParseDecl.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaStmt.cpp
>> cfe/trunk/lib/Sema/SemaType.cpp
>> cfe/trunk/lib/Sema/TreeTransform.h
>> cfe/trunk/lib/Serialization/ASTReader.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/test/Sema/address_spaces.c
>> cfe/trunk/test/SemaObjC/externally-retained.m
>> cfe/trunk/test/SemaObjC/gc-attributes.m
>> cfe/trunk/test/SemaObjC/mrc-weak.m
>> cfe/trunk/test/SemaObjCXX/gc-attributes.mm
>> cfe/trunk/tools/libclang/CIndex.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=360109=360108=360109=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon May  6 20:20:17 2019
>> @@ -1441,6 +1441,9 @@ public:
>>
>>QualType getParenType(QualType NamedType) const;
>>
>> +  QualType getMacroQualifiedType(QualType UnderlyingTy,
>> + const IdentifierInfo *MacroII) const;
>> +
>>QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
>>   NestedNameSpecifier *NNS, QualType
>> NamedType,
>>   TagDecl *OwnedTagDecl = nullptr) const;
>>
>> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=360109=360108=360109=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
>> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon May  6 20:20:17
>> 2019
>> @@ -1065,6 +1065,9 @@ DEF_TRAVERSE_TYPE(AttributedType,
>>
>>  DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType()));
>> })
>>
>> +DEF_TRAVERSE_TYPE(MacroQualifiedType,
>> 

r360120 - [Sema] Add missing VisitMacroQualifiedTypeLoc to TypeSpecLocFiller

2019-05-07 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Tue May  7 01:12:28 2019
New Revision: 360120

URL: http://llvm.org/viewvc/llvm-project?rev=360120=rev
Log:
[Sema] Add missing VisitMacroQualifiedTypeLoc to TypeSpecLocFiller

To hopefully fix greenbot failures

Modified:
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=360120=360119=360120=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue May  7 01:12:28 2019
@@ -5388,6 +5388,11 @@ namespace {
   Visit(TL.getModifiedLoc());
   fillAttributedTypeLoc(TL, State);
 }
+void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
+  Visit(TL.getInnerLoc());
+  TL.setExpansionLoc(
+  State.getExpansionLocForMacroQualifiedType(TL.getTypePtr()));
+}
 void VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
   Visit(TL.getUnqualifiedLoc());
 }


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


r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"

2019-05-06 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon May  6 20:20:17 2019
New Revision: 360109

URL: http://llvm.org/viewvc/llvm-project?rev=360109=rev
Log:
Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an 
attribute declaration"

Updated with fix for read of uninitialized memory.

Added:
cfe/trunk/test/Frontend/macro_defined_type.cpp
cfe/trunk/test/Sema/address_space_print_macro.c
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/AST/TypeNodes.def
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/ParsedAttr.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTDiagnostic.cpp
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Sema/address_spaces.c
cfe/trunk/test/SemaObjC/externally-retained.m
cfe/trunk/test/SemaObjC/gc-attributes.m
cfe/trunk/test/SemaObjC/mrc-weak.m
cfe/trunk/test/SemaObjCXX/gc-attributes.mm
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=360109=360108=360109=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon May  6 20:20:17 2019
@@ -1441,6 +1441,9 @@ public:
 
   QualType getParenType(QualType NamedType) const;
 
+  QualType getMacroQualifiedType(QualType UnderlyingTy,
+ const IdentifierInfo *MacroII) const;
+
   QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
  NestedNameSpecifier *NNS, QualType NamedType,
  TagDecl *OwnedTagDecl = nullptr) const;

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=360109=360108=360109=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon May  6 20:20:17 2019
@@ -1065,6 +1065,9 @@ DEF_TRAVERSE_TYPE(AttributedType,
 
 DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })
 
+DEF_TRAVERSE_TYPE(MacroQualifiedType,
+  { TRY_TO(TraverseType(T->getUnderlyingType())); })
+
 DEF_TRAVERSE_TYPE(ElaboratedType, {
   if (T->getQualifier()) {
 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
@@ -1308,6 +1311,9 @@ DEF_TRAVERSE_TYPELOC(InjectedClassNameTy
 
 DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
 
+DEF_TRAVERSE_TYPELOC(MacroQualifiedType,
+ { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
+
 DEF_TRAVERSE_TYPELOC(AttributedType,
  { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
 

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=360109=360108=360109=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon May  6 20:20:17 2019
@@ -4184,6 +4184,41 @@ public:
   static bool classof(const Type *T) { return T->getTypeClass() == Typedef; }
 };
 
+/// Sugar type that represents a type that was qualified by a qualifier written
+/// as a macro invocation.
+class MacroQualifiedType : public Type {
+  friend class ASTContext; // ASTContext creates these.
+
+  QualType UnderlyingTy;
+  const IdentifierInfo *MacroII;
+
+  MacroQualifiedType(QualType UnderlyingTy, QualType CanonTy,
+ const IdentifierInfo *MacroII)
+  : Type(MacroQualified, CanonTy, UnderlyingTy->isDependentType(),
+ UnderlyingTy->isInstantiationDependentType(),
+ UnderlyingTy->isVariablyModifiedType(),
+ UnderlyingTy->containsUnexpandedParameterPack()),
+UnderlyingTy(UnderlyingTy), MacroII(MacroII) {
+assert(isa(UnderlyingTy) &&
+   "Expected a macro qualified type to only wrap attributed types.");
+  }
+
+public:
+  const IdentifierInfo 

  1   2   >