Patch up omissions in DebugLoc propagation.
[oota-llvm.git] / lib / Target / TargetAsmInfo.cpp
index c9a525a506edecc76bc010fe110e7238213c85ea..d687e2f44cfd7787a2b541d66fe0ade02550f762 100644 (file)
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Constants.h"
+#include "llvm/DerivedTypes.h"
 #include "llvm/GlobalVariable.h"
 #include "llvm/Function.h"
 #include "llvm/Module.h"
@@ -99,7 +100,7 @@ void TargetAsmInfo::fillDefaultValues() {
   SupportsDebugInformation = false;
   SupportsExceptionHandling = false;
   DwarfRequiresFrameSection = true;
-  FDEEncodingRequiresSData4 = true;
+  SupportsMacInfoSection = true;
   NonLocalEHFrameLabel = false;
   GlobalEHDirective = 0;
   SupportsWeakOmittedEHFrame = true;
@@ -170,6 +171,25 @@ static bool isSuitableForBSS(const GlobalVariable *GV) {
   return (C->isNullValue() && !GV->isConstant() && !NoZerosInBSS);
 }
 
+static bool isConstantString(const Constant *C) {
+  // First check: is we have constant array of i8 terminated with zero
+  const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
+  // Check, if initializer is a null-terminated string
+  if (CVA && CVA->isCString())
+    return true;
+
+  // Another possibility: [1 x i8] zeroinitializer
+  if (isa<ConstantAggregateZero>(C)) {
+    if (const ArrayType *Ty = dyn_cast<ArrayType>(C->getType())) {
+      return (Ty->getElementType() == Type::Int8Ty &&
+              Ty->getNumElements() == 1);
+    }
+  }
+
+  return false;
+}
+
+
 SectionKind::Kind
 TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
   // Early exit - functions should be always in text sections.
@@ -191,9 +211,8 @@ TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
     if (C->ContainsRelocations())
       return SectionKind::ROData;
     else {
-      const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
       // Check, if initializer is a null-terminated string
-      if (CVA && CVA->isCString())
+      if (isConstantString(C))
         return SectionKind::RODataMergeStr;
       else
         return SectionKind::RODataMergeConst;
@@ -341,6 +360,7 @@ TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
    default:
     assert(0 && "Unknown section kind");
   }
+  return NULL;
 }
 
 const Section*