[LLVMdev] patch for DragonEgg 3.3 (amended)

Richard Gorton rcgorton at cognitive-electronics.com
Sat Sep 13 02:23:09 PDT 2014


> On 9/12/2014 8:41 AM, Richard Gorton wrote:
>> Ohmy. Thank you for spotting that. Attached is a diff for the 
>> correction.
>>
>>     Regards,
>>         Richard Gorton
>>         Cognitive Electronics
>>         rcgorton at cog-e.com
>>
>
>
>
>>
>> On 9/11/2014 3:06 PM, Isaac Dupree wrote:
>>> The src/Debug.cpp patch lines under "@@ -1115,13 +1121,33 @@" look like
>>> they have a mistake.  In both "#if" branches, there is an "if ()" that
>>> has three return statements below it, one of which is unreachable.
>>>
>>> -Isaac
>>>
>>> On 09/11/2014 02:34 PM, Richard Gorton wrote:
>>>> Hi - attached is a patch to enable building DragonEgg (x86_64) for 
>>>> LLVM3.3 and LLVM3.4.  That is, add these changes to the 3.3 
>>>> release, and it becomes possible to build DragonEgg against a 
>>>> llvm3.4 compiler.
>>>>
>>>> Regards,
>>>>     Richard Gorton
>>>>     Cognitive Electronics
>>>>     rcgorton at cog-e.com
>>>>
>>>> ----------
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> LLVM Developers mailing list
>>>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>>>
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>

-------------- next part --------------
Index: include/x86/dragonegg/Target.h
===================================================================
--- include/x86/dragonegg/Target.h	(revision 552)
+++ include/x86/dragonegg/Target.h	(working copy)
@@ -338,6 +338,7 @@
       argvec.push_back("-force-align-stack");                                  \
   } while (0)
 
+#if (LLVM_MINOR == 3)
 #define LLVM_SET_TARGET_MACHINE_OPTIONS(O)                                     \
   do {                                                                         \
     if (TARGET_OMIT_LEAF_FRAME_POINTER) {                                      \
@@ -345,5 +346,13 @@
       O.NoFramePointerElimNonLeaf = true;                                      \
     }                                                                          \
   } while (0)
+#else
+#define LLVM_SET_TARGET_MACHINE_OPTIONS(O)                                     \
+  do {                                                                         \
+    if (TARGET_OMIT_LEAF_FRAME_POINTER) {                                      \
+      O.NoFramePointerElim = false;                                            \
+    }                                                                          \
+  } while (0)
+#endif
 
 #endif /* DRAGONEGG_TARGET_H */
Index: src/Debug.cpp
===================================================================
--- src/Debug.cpp	(revision 552)
+++ src/Debug.cpp	(working copy)
@@ -1089,9 +1089,15 @@
     return Builder.createArrayType(SizeInBits, AlignInBits, DerivedFrom,
                                    Elements);
   case dwarf::DW_TAG_structure_type:
+#if (LLVM_MINOR == 3)
     return Builder.createStructType(Context, Name, F, LineNumber, SizeInBits,
                                     AlignInBits, Flags, DerivedFrom, Elements,
                                     0, ContainingType);
+#else
+    return Builder.createStructType(Context, Name, F, LineNumber, SizeInBits,
+                                    AlignInBits, Flags, DerivedFrom, Elements,
+                                    0, DIType(ContainingType));
+#endif
   case dwarf::DW_TAG_union_type:
     return Builder.createUnionType(Context, Name, F, LineNumber, SizeInBits,
                                    AlignInBits, Flags, Elements, RuntimeLang);
@@ -1115,6 +1121,8 @@
     StringRef LinkageName, DIFile F, unsigned LineNo, DIType Ty,
     bool isLocalToUnit, bool isDefinition, unsigned VK, unsigned VIndex,
     DIType ContainingType, unsigned Flags, bool isOptimized, Function *Fn) {
+
+#if (LLVM_MINOR == 3)
   if (ContainingType.isValid() || VK || VIndex)
     return Builder.createMethod(Context, Name, LinkageName, F, LineNo, Ty,
                                 isLocalToUnit, isDefinition, VK, VIndex, NULL,
@@ -1122,6 +1130,17 @@
   return Builder.createFunction(Context, Name, LinkageName, F, LineNo, Ty,
                                 isLocalToUnit, isDefinition, LineNo, Flags,
                                 isOptimized, Fn, NULL, NULL);
+#else
+  DICompositeType CTy = getDICompositeType(Ty);
+  assert(CTy.Verify() && "Expected a composite type!");
+  if (ContainingType.isValid() || VK || VIndex)
+    return Builder.createMethod(Context, Name, LinkageName, F, LineNo, CTy,
+                                isLocalToUnit, isDefinition, VK, VIndex, DIType(),
+                                Flags, isOptimized, Fn, NULL);
+  return Builder.createFunction(Context, Name, LinkageName, F, LineNo, CTy,
+                                isLocalToUnit, isDefinition, LineNo, Flags,
+                                isOptimized, Fn, NULL, NULL);
+#endif
 }
 
 /// CreateSubprogramDefinition - Create new subprogram descriptor for the
Index: src/Backend.cpp
===================================================================
--- src/Backend.cpp	(revision 552)
+++ src/Backend.cpp	(working copy)
@@ -482,11 +482,15 @@
   if (flag_omit_frame_pointer) {
     // Eliminate frame pointers everywhere.
     Options.NoFramePointerElim = false;
+#if (LLVM_MINOR == 3)
     Options.NoFramePointerElimNonLeaf = false;
+#endif
   } else {
     // Keep frame pointers everywhere.
     Options.NoFramePointerElim = true;
+#if (LLVM_MINOR == 3)
     Options.NoFramePointerElimNonLeaf = true;
+#endif
   }
   // If a target has an option to eliminate frame pointers in leaf functions
   // only then it should set
@@ -511,7 +515,9 @@
 #else
   Options.UseInitArray = false;
 #endif
+#if (LLVM_MINOR == 3)
   Options.SSPBufferSize = PARAM_VALUE(PARAM_SSP_BUFFER_SIZE);
+#endif
 #ifdef LLVM_SET_TARGET_MACHINE_OPTIONS
   LLVM_SET_TARGET_MACHINE_OPTIONS(Options);
 #endif
@@ -642,7 +648,9 @@
 
   // Configure the pass builder.
   PassBuilder.SizeLevel = optimize_size;
+#if (LLVM_MINOR == 3)
   PassBuilder.DisableSimplifyLibCalls = flag_no_simplify_libcalls;
+#endif
   PassBuilder.DisableUnitAtATime = !flag_unit_at_a_time;
   PassBuilder.DisableUnrollLoops = !flag_unroll_loops;
 //  Don't turn on the SLP vectorizer by default at -O3 for the moment.
@@ -662,8 +670,13 @@
   assert(!OutStream && "Output stream already initialized!");
   std::string Error;
 
+#if (LLVM_MINOR == 3)
   OutStream = new raw_fd_ostream(llvm_asm_file_name, Error,
                                  Binary ? raw_fd_ostream::F_Binary : 0);
+#else
+  OutStream = new raw_fd_ostream(llvm_asm_file_name, Error,
+                                 Binary ? sys::fs::F_Binary : sys::fs::F_None);
+#endif
 
   if (!Error.empty())
     report_fatal_error(Error);
Index: Makefile
===================================================================
--- Makefile	(revision 552)
+++ Makefile	(working copy)
@@ -61,7 +61,10 @@
 GCC_MICRO=$(word 3, $(subst ., ,$(GCC_VERSION)))
 TARGET_TRIPLE=$(shell $(GCC) -dumpmachine)
 
-LLVM_VERSION=$(shell $(LLVM_CONFIG) --version)
+LLVM_VERSION=$(shell $(LLVM_CONFIG) --version).0
+LLVM_MAJOR=$(word 1, $(subst ., ,$(LLVM_VERSION)))
+LLVM_MINOR=$(word 2, $(subst ., ,$(LLVM_VERSION)))
+LLVM_MICRO=$(word 3, $(subst ., ,$(LLVM_VERSION)))
 
 PLUGIN=dragonegg.so
 PLUGIN_OBJECTS=Aliasing.o Backend.o Cache.o ConstantConversion.o Convert.o \
@@ -80,8 +83,8 @@
 	     -MD -MP \
 	     -DIN_GCC -DLLVM_VERSION=\"$(LLVM_VERSION)\" \
 	     -DTARGET_TRIPLE=\"$(TARGET_TRIPLE)\" \
-	     -DGCC_MAJOR=$(GCC_MAJOR) -DGCC_MINOR=$(GCC_MINOR) \
-	     -DGCC_MICRO=$(GCC_MICRO) \
+	     -DGCC_MAJOR=$(GCC_MAJOR) -DGCC_MINOR=$(GCC_MINOR) -DGCC_MICRO=$(GCC_MICRO) \
+	     -DLLVM_MAJOR=$(LLVM_MAJOR) -DLLVM_MINOR=$(LLVM_MINOR) -DLLVM_MICRO=$(LLVM_MICRO) \
 	     -I$(INCLUDE_DIR) -isystem$(GCC_PLUGIN_DIR)/include
 ifdef DISABLE_VERSION_CHECK
 CPP_OPTIONS+=-DDISABLE_VERSION_CHECK


More information about the llvm-dev mailing list