Rename these methods to match the style guide.
[oota-llvm.git] / lib / Transforms / Instrumentation / DebugIR.cpp
index 0c85496713c441e1e28c843a24585a57c2092b42..9ad6c472b9bac4f173ed9a31b5976a3026a378d9 100644 (file)
 #define DEBUG_TYPE "debug-ir"
 
 #include "llvm/ADT/ValueMap.h"
-#include "llvm/Assembly/AssemblyAnnotationWriter.h"
-#include "llvm/DebugInfo.h"
+#include "DebugIR.h"
 #include "llvm/DIBuilder.h"
-#include "llvm/InstVisitor.h"
+#include "llvm/DebugInfo.h"
+#include "llvm/IR/AssemblyAnnotationWriter.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Instruction.h"
+#include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
-#include "llvm/Transforms/Instrumentation.h"
-#include "llvm/Transforms/Utils/Cloning.h"
+#include "llvm/InstVisitor.h"
 #include "llvm/Support/Debug.h"
-#include "llvm/Support/ToolOutputFile.h"
-#include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/Path.h"
-
-#include "DebugIR.h"
-
+#include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Utils/Cloning.h"
 #include <string>
 
 #define STR_HELPER(x) #x
@@ -216,11 +215,11 @@ public:
 
     int FuncFlags = llvm::DIDescriptor::FlagPrototyped;
     assert(CUNode && FileNode);
-    MDNode *Sub = Builder.createFunction(
+    DISubprogram Sub = Builder.createFunction(
         DICompileUnit(CUNode), F.getName(), MangledName, DIFile(FileNode), Line,
         Sig, Local, IsDefinition, ScopeLine, FuncFlags, IsOptimized, &F);
-    assert(DISubprogram(Sub).Verify());
-    DEBUG(dbgs() << "create subprogram mdnode " << Sub << ": "
+    assert(Sub.isSubprogram());
+    DEBUG(dbgs() << "create subprogram mdnode " << *Sub << ": "
                  << "\n");
 
     SubprogramDescriptors.insert(std::make_pair(&F, Sub));
@@ -289,9 +288,9 @@ private:
           "LLVM Version " STR(LLVM_VERSION_MAJOR) "." STR(LLVM_VERSION_MINOR);
     }
 
-    Builder.createCompileUnit(dwarf::DW_LANG_C99, Filename, Directory, Producer,
-                              IsOptimized, Flags, RuntimeVersion);
-    CUNode = Builder.getCU();
+    CUNode =
+        Builder.createCompileUnit(dwarf::DW_LANG_C99, Filename, Directory,
+                                  Producer, IsOptimized, Flags, RuntimeVersion);
 
     if (CUToReplace)
       CUToReplace->replaceAllUsesWith(const_cast<MDNode *>(CUNode));
@@ -401,7 +400,7 @@ private:
       Type *PointeeTy = T->getPointerElementType();
       if (!(N = getType(PointeeTy)))
         N = Builder.createPointerType(
-            getOrCreateType(PointeeTy), Layout.getPointerSizeInBits(),
+            getOrCreateType(PointeeTy), Layout.getPointerTypeSizeInBits(T),
             Layout.getPrefTypeAlignment(T), getTypeName(T));
     } else if (T->isArrayTy()) {
       SmallVector<Value *, 1> Subrange;
@@ -504,10 +503,9 @@ bool DebugIR::updateExtension(StringRef NewExtension) {
 }
 
 void DebugIR::generateFilename(OwningPtr<int> &fd) {
-  StringRef FileModel("debug-ir-%s%s%s%s.ll");
   SmallVector<char, 16> PathVec;
   fd.reset(new int);
-  sys::fs::unique_file(FileModel, *fd, PathVec);
+  sys::fs::createTemporaryFile("debug-ir", "ll", *fd, PathVec);
   StringRef Path(PathVec.data(), PathVec.size());
   Filename = sys::path::filename(Path);
   sys::path::remove_filename(PathVec);