From 2511abf6e79d36f679bd5ed5af94208cde579e74 Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Fri, 6 Mar 2009 00:42:50 +0000 Subject: [PATCH] Tweak the check for promotable alloca's to handle debug intrinsics correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66225 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index cc626ae71f5..e3dd72daf70 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -81,9 +81,15 @@ bool llvm::isAllocaPromotable(const AllocaInst *AI) { if (SI->isVolatile()) return false; } else if (const BitCastInst *BC = dyn_cast(*UI)) { - // Uses by dbg info shouldn't inhibit promotion. + // A bitcast that does not feed into debug info inhibits promotion. if (!BC->hasOneUse() || !isa(*BC->use_begin())) return false; + // If the only use is by debug info, this alloca will not exist in + // non-debug code, so don't try to promote; this ensures the same + // codegen with debug info. Otherwise, debug info should not + // inhibit promotion (but we must examine other uses). + if (AI->hasOneUse()) + return false; } else { return false; }