r296234 - Revert "[profiling] Fix profile counter increment when emitting selects (PR32019)"
Vedant Kumar via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 24 18:59:47 PST 2017
Author: vedantk
Date: Fri Feb 24 20:59:47 2017
New Revision: 296234
URL: http://llvm.org/viewvc/llvm-project?rev=296234&view=rev
Log:
Revert "[profiling] Fix profile counter increment when emitting selects (PR32019)"
This reverts commit r296231. It causes an assertion failure on 32-bit
machines
clang: /export/users/atombot/llvm/clang-atom-d525-fedora-rel/llvm/lib/IR/Instructions.cpp:263: void llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, const llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1c5fbfa)
llvm::sys::RunSignalHandlers() (/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1c5dc7e)
SignalHandler(int) (/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1c5dde2)
__restore_rt (/lib64/libpthread.so.0+0x3f1d00efa0)
__GI_raise /home/glibctest/rpmbuild/BUILD/glibc-2.17-c758a686/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
__GI_abort /home/glibctest/rpmbuild/BUILD/glibc-2.17-c758a686/stdlib/abort.c:92:0
__assert_fail_base /home/glibctest/rpmbuild/BUILD/glibc-2.17-c758a686/assert/assert.c:92:0
(/lib64/libc.so.6+0x3f1c82e622)
llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&) (/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1804e3a)
clang::CodeGen::CodeGenPGO::emitCounterIncrement(clang::CodeGen::CGBuilderTy&, clang::Stmt const*, llvm::Value*) (/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1ec7891)
Removed:
cfe/trunk/test/Profile/c-ternary.c
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
cfe/trunk/lib/CodeGen/CodeGenPGO.h
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=296234&r1=296233&r2=296234&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Feb 24 20:59:47 2017
@@ -3414,11 +3414,9 @@ VisitAbstractConditionalOperator(const A
// safe to evaluate the LHS and RHS unconditionally.
if (isCheapEnoughToEvaluateUnconditionally(lhsExpr, CGF) &&
isCheapEnoughToEvaluateUnconditionally(rhsExpr, CGF)) {
- llvm::Value *CondV = CGF.EvaluateExprAsBool(condExpr);
- llvm::Value *StepV = Builder.CreateZExtOrBitCast(CondV, CGF.Int64Ty);
-
- CGF.incrementProfileCounter(E, StepV);
+ CGF.incrementProfileCounter(E);
+ llvm::Value *CondV = CGF.EvaluateExprAsBool(condExpr);
llvm::Value *LHS = Visit(lhsExpr);
llvm::Value *RHS = Visit(rhsExpr);
if (!LHS) {
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=296234&r1=296233&r2=296234&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Feb 24 20:59:47 2017
@@ -1127,11 +1127,10 @@ private:
uint64_t LoopCount);
public:
- /// Increment the profiler's counter for the given statement by \p StepV.
- /// If \p StepV is null, the default increment is 1.
- void incrementProfileCounter(const Stmt *S, llvm::Value *StepV = nullptr) {
+ /// Increment the profiler's counter for the given statement.
+ void incrementProfileCounter(const Stmt *S) {
if (CGM.getCodeGenOpts().hasProfileClangInstr())
- PGO.emitCounterIncrement(Builder, S, StepV);
+ PGO.emitCounterIncrement(Builder, S);
PGO.setCurrentStmt(S);
}
Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=296234&r1=296233&r2=296234&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Feb 24 20:59:47 2017
@@ -739,8 +739,7 @@ CodeGenPGO::applyFunctionAttributes(llvm
Fn->setEntryCount(FunctionCount);
}
-void CodeGenPGO::emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S,
- llvm::Value *StepV) {
+void CodeGenPGO::emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S) {
if (!CGM.getCodeGenOpts().hasProfileClangInstr() || !RegionCounterMap)
return;
if (!Builder.GetInsertBlock())
@@ -748,17 +747,11 @@ void CodeGenPGO::emitCounterIncrement(CG
unsigned Counter = (*RegionCounterMap)[S];
auto *I8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
-
- ArrayRef<llvm::Value *> Args = {
- llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
- Builder.getInt64(FunctionHash), Builder.getInt32(NumRegionCounters),
- Builder.getInt32(Counter), StepV};
- if (!StepV)
- Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment),
- Args.drop_back(1));
- else
- Builder.CreateCall(
- CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment_step), Args);
+ Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment),
+ {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
+ Builder.getInt64(FunctionHash),
+ Builder.getInt32(NumRegionCounters),
+ Builder.getInt32(Counter)});
}
// This method either inserts a call to the profile run-time during
Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.h?rev=296234&r1=296233&r2=296234&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenPGO.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.h Fri Feb 24 20:59:47 2017
@@ -105,8 +105,7 @@ private:
void emitCounterRegionMapping(const Decl *D);
public:
- void emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S,
- llvm::Value *StepV);
+ void emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S);
/// Return the region count for the counter at the given index.
uint64_t getRegionCount(const Stmt *S) {
Removed: cfe/trunk/test/Profile/c-ternary.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-ternary.c?rev=296233&view=auto
==============================================================================
--- cfe/trunk/test/Profile/c-ternary.c (original)
+++ cfe/trunk/test/Profile/c-ternary.c (removed)
@@ -1,15 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s
-
-// PR32019: Clang can lower some ternary operator expressions to select
-// instructions. Make sure we only increment the profile counter for the
-// condition when the condition evaluates to true.
-// CHECK-LABEL: define i32 @f1
-int f1(int x) {
-// CHECK: [[TOBOOL:%.*]] = icmp ne i32 %1, 0
-// CHECK-NEXT: [[STEP:%.*]] = zext i1 [[TOBOOL]] to i64
-// CHECK-NEXT: [[COUNTER:%.*]] = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_f1, i64 0, i64 1)
-// CHECK-NEXT: add i64 [[COUNTER]], [[STEP]]
-// CHECK: [[COND:%.*]] = select i1 [[TOBOOL]], i32 0, i32 1
- return x ? 0 : 1;
-// CHECK: ret i32 [[COND]]
-}
More information about the cfe-commits
mailing list