Apply a patch from Mahadevan R, with minor formatting changes, to
authorDan Gohman <gohman@apple.com>
Fri, 25 Jul 2008 00:36:05 +0000 (00:36 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 25 Jul 2008 00:36:05 +0000 (00:36 +0000)
workaround a GCC 3.3 bug observed on OpenBSD.

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

include/llvm/CodeGen/MachineFunction.h

index 2fbe9b803eec13b837d180bc3f4ff842f0cb87be..98f3a948394e86b00d6ece4d5444a2988122e6ec 100644 (file)
@@ -136,7 +136,13 @@ public:
   ///
   template<typename Ty>
   Ty *getInfo() {
-    if (!MFInfo) MFInfo = new (Allocator.Allocate<Ty>()) Ty(*this);
+    if (!MFInfo) {
+        // This should be just `new (Allocator.Allocate<Ty>()) Ty(*this)', but
+        // that apparently breaks GCC 3.3.
+        Ty *Loc = static_cast<Ty*>(Allocator.Allocate(sizeof(Ty),
+                                                      AlignOf<Ty>::Alignment));
+        MFInfo = new (Loc) Ty(*this);
+    }
 
     assert((void*)dynamic_cast<Ty*>(MFInfo) == (void*)MFInfo &&
            "Invalid concrete type or multiple inheritence for getInfo");