aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGCall.cpp18
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp12
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp4
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h7
4 files changed, 30 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 056caf6..a67b0d8 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3929,9 +3929,9 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src,
return R;
}
-void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
- bool EmitRetDbgLoc,
- SourceLocation EndLoc) {
+void CodeGenFunction::EmitFunctionEpilog(
+ const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc,
+ uint64_t RetKeyInstructionsSourceAtom) {
if (FI.isNoReturn()) {
// Noreturn functions don't return.
EmitUnreachable(EndLoc);
@@ -3946,7 +3946,11 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
// Functions with no result always return void.
if (!ReturnValue.isValid()) {
- Builder.CreateRetVoid();
+ auto *I = Builder.CreateRetVoid();
+ if (RetKeyInstructionsSourceAtom)
+ addInstToSpecificSourceAtom(I, nullptr, RetKeyInstructionsSourceAtom);
+ else
+ addInstToNewSourceAtom(I, nullptr);
return;
}
@@ -4126,6 +4130,12 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
if (RetDbgLoc)
Ret->setDebugLoc(std::move(RetDbgLoc));
+
+ llvm::Value *Backup = RV ? Ret->getOperand(0) : nullptr;
+ if (RetKeyInstructionsSourceAtom)
+ addInstToSpecificSourceAtom(Ret, Backup, RetKeyInstructionsSourceAtom);
+ else
+ addInstToNewSourceAtom(Ret, Backup);
}
void CodeGenFunction::EmitReturnValueCheck(llvm::Value *RV) {
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index dc92493..8742f8e 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1605,6 +1605,7 @@ static bool isSwiftAsyncCallee(const CallExpr *CE) {
/// if the function returns void, or may be missing one if the function returns
/// non-void. Fun stuff :).
void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
+ ApplyAtomGroup Grp(getDebugInfo());
if (requiresReturnValueCheck()) {
llvm::Constant *SLoc = EmitCheckSourceLocation(S.getBeginLoc());
auto *SLocPtr =
@@ -1680,16 +1681,19 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
// If this function returns a reference, take the address of the expression
// rather than the value.
RValue Result = EmitReferenceBindingToExpr(RV);
- Builder.CreateStore(Result.getScalarVal(), ReturnValue);
+ auto *I = Builder.CreateStore(Result.getScalarVal(), ReturnValue);
+ addInstToCurrentSourceAtom(I, I->getValueOperand());
} else {
switch (getEvaluationKind(RV->getType())) {
case TEK_Scalar: {
llvm::Value *Ret = EmitScalarExpr(RV);
- if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect)
+ if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect) {
EmitStoreOfScalar(Ret, MakeAddrLValue(ReturnValue, RV->getType()),
/*isInit*/ true);
- else
- Builder.CreateStore(Ret, ReturnValue);
+ } else {
+ auto *I = Builder.CreateStore(Ret, ReturnValue);
+ addInstToCurrentSourceAtom(I, I->getValueOperand());
+ }
break;
}
case TEK_Complex:
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 0388c67..2ac7e9d 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -444,8 +444,10 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
// Reset the debug location to that of the simple 'return' expression, if any
// rather than that of the end of the function's scope '}'.
+ uint64_t RetKeyInstructionsAtomGroup = Loc ? Loc->getAtomGroup() : 0;
ApplyDebugLocation AL(*this, Loc);
- EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc);
+ EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc,
+ RetKeyInstructionsAtomGroup);
EmitEndEHSpec(CurCodeDecl);
assert(EHStack.empty() &&
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index f0f051a..cecc8c0 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -2551,9 +2551,12 @@ public:
const FunctionArgList &Args);
/// EmitFunctionEpilog - Emit the target specific LLVM code to return the
- /// given temporary.
+ /// given temporary. Specify the source location atom group (Key Instructions
+ /// debug info feature) for the `ret` using \p RetKeyInstructionsSourceAtom.
+ /// If it's 0, the `ret` will get added to a new source atom group.
void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc,
- SourceLocation EndLoc);
+ SourceLocation EndLoc,
+ uint64_t RetKeyInstructionsSourceAtom);
/// Emit a test that checks if the return value \p RV is nonnull.
void EmitReturnValueCheck(llvm::Value *RV);