From d7d0ebb65c646a62d8a32fc15e097ab545e99512 Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Wed, 27 Nov 2013 22:43:59 +0100 Subject: [PATCH 1/2] Add new version identifiers if a sanitizer is specified. --- driver/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/driver/main.cpp b/driver/main.cpp index 50c4563f..4646d433 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -636,6 +636,21 @@ static void registerPredefinedVersions() { registerPredefinedTargetVersions(); +#if LDC_LLVM_VER >= 303 + // Pass sanitizer arguments to linker. Requires clang. + if (opts::sanitize == opts::AddressSanitizer) { + VersionCondition::addPredefinedGlobalIdent("LDC_AddressSanitizer"); + } + + if (opts::sanitize == opts::MemorySanitizer) { + VersionCondition::addPredefinedGlobalIdent("LDC_MemorySanitizer"); + } + + if (opts::sanitize == opts::ThreadSanitizer) { + VersionCondition::addPredefinedGlobalIdent("LDC_ThreadSanitizer"); + } +#endif + // Expose LLVM version to runtime #define STR(x) #x #define XSTR(x) STR(x) From 37ee9962fdd948a0696156958ccaab2e601f2809 Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Wed, 27 Nov 2013 22:44:49 +0100 Subject: [PATCH 2/2] Changes for LLVM 3.5 --- gen/passes/GarbageCollect2Stack.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gen/passes/GarbageCollect2Stack.cpp b/gen/passes/GarbageCollect2Stack.cpp index 901f1dc2..f498ffa2 100644 --- a/gen/passes/GarbageCollect2Stack.cpp +++ b/gen/passes/GarbageCollect2Stack.cpp @@ -397,7 +397,11 @@ namespace { #endif AU.addRequired(); +#if LDC_LLVM_VER >= 305 + AU.addPreserved(); +#else AU.addPreserved(); +#endif } }; char GarbageCollect2Stack::ID = 0; @@ -460,7 +464,11 @@ bool GarbageCollect2Stack::runOnFunction(Function &F) { TargetData& TD = getAnalysis(); #endif DominatorTree& DT = getAnalysis(); +#if LDC_LLVM_VER >= 305 + CallGraph* CG = &getAnalysisIfAvailable()->getCallGraph(); +#else CallGraph* CG = getAnalysisIfAvailable(); +#endif CallGraphNode* CGNode = CG ? (*CG)[&F] : NULL; Analysis A = { TD, *M, CG, CGNode };