]> granicus.if.org Git - clang/commitdiff
Revert r264998 and r265035.
authorAkira Hatanaka <ahatanaka@apple.com>
Thu, 27 Jul 2017 18:52:44 +0000 (18:52 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Thu, 27 Jul 2017 18:52:44 +0000 (18:52 +0000)
r303175 made changes to have __cxa_allocate_exception return a 16-byte
aligned pointer, so it's no longer necessary to specify a lower
alignment (8-bytes) for exception objects on Darwin.

rdar://problem/32363695

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309308 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/TargetInfo.h
lib/Basic/Targets/OSTargets.h
lib/CodeGen/ItaniumCXXABI.cpp
test/CodeGenCXX/eh.cpp

index 7bb910f2669b654ff73eb074eea17e9ccb303196..5e3cf0b3159dc1062f3a0cc87f6124de39c6ca0b 100644 (file)
@@ -464,21 +464,6 @@ public:
   /// types for the given target.
   unsigned getSimdDefaultAlign() const { return SimdDefaultAlign; }
 
-  /// Return the alignment (in bits) of the thrown exception object. This is
-  /// only meaningful for targets that allocate C++ exceptions in a system
-  /// runtime, such as those using the Itanium C++ ABI.
-  virtual unsigned getExnObjectAlignment() const {
-    // Itanium says that an _Unwind_Exception has to be "double-word"
-    // aligned (and thus the end of it is also so-aligned), meaning 16
-    // bytes.  Of course, that was written for the actual Itanium,
-    // which is a 64-bit platform.  Classically, the ABI doesn't really
-    // specify the alignment on other platforms, but in practice
-    // libUnwind declares the struct with __attribute__((aligned)), so
-    // we assume that alignment here.  (It's generally 16 bytes, but
-    // some targets overwrite it.)
-    return getDefaultAlignForAttributeAligned();
-  }
-
   /// \brief Return the size of intmax_t and uintmax_t for this target, in bits.
   unsigned getIntMaxTWidth() const {
     return getTypeWidth(IntMaxType);
index 867810456b3f2ee37810842c27d7ba025965b8dd..3919164bf9abcab8df37b719db5b5380c506e739 100644 (file)
@@ -127,13 +127,6 @@ public:
   /// is very similar to ELF's "protected";  Darwin requires a "weak"
   /// attribute on declarations that can be dynamically replaced.
   bool hasProtectedVisibility() const override { return false; }
-
-  unsigned getExnObjectAlignment() const override {
-    // The alignment of an exception object is 8-bytes for darwin since
-    // libc++abi doesn't declare _Unwind_Exception with __attribute__((aligned))
-    // and therefore doesn't guarantee 16-byte alignment.
-    return 64;
-  }
 };
 
 // DragonFlyBSD Target
index de9fd042a9e4501574527f29dc5327a1a21547eb..c1f892a3173344fc0478e132e58129c1860b00ed 100644 (file)
@@ -157,9 +157,17 @@ public:
                                Address Ptr, QualType ElementType,
                                const CXXDestructorDecl *Dtor) override;
 
+  /// Itanium says that an _Unwind_Exception has to be "double-word"
+  /// aligned (and thus the end of it is also so-aligned), meaning 16
+  /// bytes.  Of course, that was written for the actual Itanium,
+  /// which is a 64-bit platform.  Classically, the ABI doesn't really
+  /// specify the alignment on other platforms, but in practice
+  /// libUnwind declares the struct with __attribute__((aligned)), so
+  /// we assume that alignment here.  (It's generally 16 bytes, but
+  /// some targets overwrite it.)
   CharUnits getAlignmentOfExnObject() {
-    unsigned Align = CGM.getContext().getTargetInfo().getExnObjectAlignment();
-    return CGM.getContext().toCharUnitsFromBits(Align);
+    auto align = CGM.getContext().getTargetDefaultAlignForAttributeAligned();
+    return CGM.getContext().toCharUnitsFromBits(align);
   }
 
   void emitRethrow(CodeGenFunction &CGF, bool isNoReturn) override;
index db0576a1baeb5286d85b5095f298f18de36c1d42..cf021b8f4cdec229756e300c445f99b6c7d2c878 100644 (file)
@@ -466,7 +466,7 @@ int foo() {
   // CHECK: [[T0:%.*]] = call i8* @__cxa_allocate_exception(i64 16)
   // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to %"class.test17::DerivedException"*
   // CHECK-NEXT: [[T2:%.*]] = bitcast %"class.test17::DerivedException"* [[T1]] to i8*
-  // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T2]], i8 0, i64 16, i32 8, i1 false)
+  // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T2]], i8 0, i64 16, i32 16, i1 false)
 }
 }