From: Eric Fiselier Date: Fri, 2 Feb 2018 19:58:34 +0000 (+0000) Subject: Emit label names according to -discard-value-names. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2677f53fc4c46113b631344f1cdab3b16e5201fd;p=clang Emit label names according to -discard-value-names. Summary: Previously, Clang only emitted label names in assert builds. However there is a CC1 option -discard-value-names that should have been used to control emission instead. This patch removes the NDEBUG preprocessor block and instead allows LLVM to handle removing the names in accordance with the option. Reviewers: erichkeane, aaron.ballman, majnemer Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42829 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324127 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 75071a8e32..844ccf0094 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -1849,11 +1849,7 @@ public: llvm::BasicBlock *createBasicBlock(const Twine &name = "", llvm::Function *parent = nullptr, llvm::BasicBlock *before = nullptr) { -#ifdef NDEBUG - return llvm::BasicBlock::Create(getLLVMContext(), "", parent, before); -#else return llvm::BasicBlock::Create(getLLVMContext(), name, parent, before); -#endif } /// getBasicBlockForLabel - Return the LLVM basicblock that the specified diff --git a/test/CodeGenCXX/discard-name-values.cpp b/test/CodeGenCXX/discard-name-values.cpp index 49cb7d2fc0..d4d7527c28 100644 --- a/test/CodeGenCXX/discard-name-values.cpp +++ b/test/CodeGenCXX/discard-name-values.cpp @@ -1,10 +1,29 @@ -// RUN: %clang_cc1 -emit-llvm -triple=armv7-apple-darwin -emit-llvm -std=c++11 %s -o - -O1 | FileCheck %s -// RUN: %clang_cc1 -emit-llvm -triple=armv7-apple-darwin -emit-llvm -std=c++11 %s -o - -O1 -discard-value-names | FileCheck %s --check-prefix=DISCARDVALUE +// RUN: %clang_cc1 -emit-llvm -triple=armv7-apple-darwin -std=c++11 %s -o - -O1 \ +// RUN: | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -triple=armv7-apple-darwin -std=c++11 %s -o - -O1 \ +// RUN: -discard-value-names | FileCheck %s --check-prefix=DISCARDVALUE -int foo(int bar) { - return bar; -} +extern "C" void branch(); + +bool test(bool pred) { + // DISCARDVALUE: br i1 %0, label %2, label %3 + // CHECK: br i1 %pred, label %if.then, label %if.end + + if (pred) { + // DISCARDVALUE: ;