Skip to content

Commit a083faa

Browse files
thurstondgithub-actions[bot]
authored andcommitted
Automerge: Revert "[Clang][CodeGen] Emit !alloc_token for new expressions" (#162412)
Reverts llvm/llvm-project#162099 Reason: this commit depends on #162098, which I am reverting due to build breakage (see llvm/llvm-project#162098 (comment)).
2 parents 4250206 + 34fda63 commit a083faa

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,23 +1272,6 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr *E, llvm::Value *Bound,
12721272
EmitCheck(std::make_pair(Check, CheckKind), CheckHandler, StaticData, Index);
12731273
}
12741274

1275-
void CodeGenFunction::EmitAllocToken(llvm::CallBase *CB, QualType AllocType) {
1276-
assert(SanOpts.has(SanitizerKind::AllocToken) &&
1277-
"Only needed with -fsanitize=alloc-token");
1278-
1279-
PrintingPolicy Policy(CGM.getContext().getLangOpts());
1280-
Policy.SuppressTagKeyword = true;
1281-
Policy.FullyQualifiedName = true;
1282-
SmallString<64> TypeName;
1283-
llvm::raw_svector_ostream TypeNameOS(TypeName);
1284-
AllocType.getCanonicalType().print(TypeNameOS, Policy);
1285-
auto *TypeMDS = llvm::MDString::get(CGM.getLLVMContext(), TypeNameOS.str());
1286-
1287-
// Format: !{<type-name>}
1288-
auto *MDN = llvm::MDNode::get(CGM.getLLVMContext(), {TypeMDS});
1289-
CB->setMetadata(llvm::LLVMContext::MD_alloc_token, MDN);
1290-
}
1291-
12921275
CodeGenFunction::ComplexPairTy CodeGenFunction::
12931276
EmitComplexPrePostIncDec(const UnaryOperator *E, LValue LV,
12941277
bool isInc, bool isPre) {

clang/lib/CodeGen/CGExprCXX.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,16 +1655,11 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
16551655
RValue RV =
16561656
EmitNewDeleteCall(*this, allocator, allocatorType, allocatorArgs);
16571657

1658-
if (auto *newCall = dyn_cast<llvm::CallBase>(RV.getScalarVal())) {
1659-
if (auto *CGDI = getDebugInfo()) {
1660-
// Set !heapallocsite metadata on the call to operator new.
1661-
CGDI->addHeapAllocSiteMetadata(newCall, allocType, E->getExprLoc());
1662-
}
1663-
if (SanOpts.has(SanitizerKind::AllocToken)) {
1664-
// Set !alloc_token metadata.
1665-
EmitAllocToken(newCall, allocType);
1666-
}
1667-
}
1658+
// Set !heapallocsite metadata on the call to operator new.
1659+
if (getDebugInfo())
1660+
if (auto *newCall = dyn_cast<llvm::CallBase>(RV.getScalarVal()))
1661+
getDebugInfo()->addHeapAllocSiteMetadata(newCall, allocType,
1662+
E->getExprLoc());
16681663

16691664
// If this was a call to a global replaceable allocation function that does
16701665
// not take an alignment argument, the allocator is known to produce

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3348,9 +3348,6 @@ class CodeGenFunction : public CodeGenTypeCache {
33483348
SanitizerAnnotateDebugInfo(ArrayRef<SanitizerKind::SanitizerOrdinal> Ordinals,
33493349
SanitizerHandler Handler);
33503350

3351-
/// Emit additional metadata used by the AllocToken instrumentation.
3352-
void EmitAllocToken(llvm::CallBase *CB, QualType AllocType);
3353-
33543351
llvm::Value *GetCountedByFieldExprGEP(const Expr *Base, const FieldDecl *FD,
33553352
const FieldDecl *CountDecl);
33563353

0 commit comments

Comments
 (0)