forked from OSchip/llvm-project
Replace Sema-level implementation of -fassume-sane-operator-new with a
CodeGen-level implementation. Instead of adding an attribute to clang's FunctionDecl, add the IR attribute directly. This means a module built with this flag is now compatible with code built without it and vice versa. This change also results in the 'noalias' attribute no longer being added to calls to operator new in the IR; it's now only added to the declaration. It also fixes a bug where we failed to add the attribute to the 'nothrow' versions (because we didn't implicitly declare them, there was no good time to inject a fake attribute). llvm-svn: 265728
This commit is contained in:
parent
aac71a4a0e
commit
351241c83e
|
@ -30,8 +30,9 @@ CODEGENOPT(Name, Bits, Default)
|
|||
|
||||
CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
|
||||
CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections
|
||||
CODEGENOPT(Autolink , 1, 1) ///< -fno-autolink
|
||||
CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm.
|
||||
CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new
|
||||
CODEGENOPT(Autolink , 1, 1) ///< -fno-autolink
|
||||
CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe.
|
||||
CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum for functions in GCNO files.
|
||||
CODEGENOPT(CoverageNoFunctionNamesInData, 1, 0) ///< Do not include function names in GCDA files.
|
||||
|
|
|
@ -189,7 +189,6 @@ LANGOPT(CUDAAllowVariadicFunctions, 1, 0, "allowing variadic functions in CUDA d
|
|||
LANGOPT(CUDAHostDeviceConstexpr, 1, 1, "treating unattributed constexpr functions as __host__ __device__")
|
||||
LANGOPT(CUDADeviceFlushDenormalsToZero, 1, 0, "flushing denormals to zero")
|
||||
|
||||
LANGOPT(AssumeSaneOperatorNew , 1, 1, "implicit __attribute__((malloc)) for C++'s new operators")
|
||||
LANGOPT(SizedDeallocation , 1, 0, "enable sized deallocation functions")
|
||||
LANGOPT(ConceptsTS , 1, 0, "enable C++ Extensions for Concepts")
|
||||
BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
|
||||
|
|
|
@ -4710,8 +4710,7 @@ public:
|
|||
void DeclareGlobalNewDelete();
|
||||
void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return,
|
||||
QualType Param1,
|
||||
QualType Param2 = QualType(),
|
||||
bool addRestrictAttr = false);
|
||||
QualType Param2 = QualType());
|
||||
|
||||
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
|
||||
DeclarationName Name, FunctionDecl* &Operator,
|
||||
|
|
|
@ -1076,12 +1076,22 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
|
|||
if (const SectionAttr *SA = FD->getAttr<SectionAttr>())
|
||||
F->setSection(SA->getName());
|
||||
|
||||
// A replaceable global allocation function does not act like a builtin by
|
||||
// default, only if it is invoked by a new-expression or delete-expression.
|
||||
if (FD->isReplaceableGlobalAllocationFunction())
|
||||
if (FD->isReplaceableGlobalAllocationFunction()) {
|
||||
// A replaceable global allocation function does not act like a builtin by
|
||||
// default, only if it is invoked by a new-expression or delete-expression.
|
||||
F->addAttribute(llvm::AttributeSet::FunctionIndex,
|
||||
llvm::Attribute::NoBuiltin);
|
||||
|
||||
// A sane operator new returns a non-aliasing pointer.
|
||||
// FIXME: Also add NonNull attribute to the return value
|
||||
// for the non-nothrow forms?
|
||||
auto Kind = FD->getDeclName().getCXXOverloadedOperator();
|
||||
if (getCodeGenOpts().AssumeSaneOperatorNew &&
|
||||
(Kind == OO_New || Kind == OO_Array_New))
|
||||
F->addAttribute(llvm::AttributeSet::ReturnIndex,
|
||||
llvm::Attribute::NoAlias);
|
||||
}
|
||||
|
||||
if (isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD))
|
||||
F->setUnnamedAddr(true);
|
||||
else if (const auto *MD = dyn_cast<CXXMethodDecl>(FD))
|
||||
|
|
|
@ -533,6 +533,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|||
Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
|
||||
Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
|
||||
Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
|
||||
Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
|
||||
Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
|
||||
Opts.CXAAtExit = !Args.hasArg(OPT_fno_use_cxa_atexit);
|
||||
Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
|
||||
|
@ -1739,7 +1740,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
|
|||
if (!Opts.NoBuiltin)
|
||||
getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
|
||||
Opts.NoMathBuiltin = Args.hasArg(OPT_fno_math_builtin);
|
||||
Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
|
||||
Opts.SizedDeallocation = Args.hasArg(OPT_fsized_deallocation);
|
||||
Opts.ConceptsTS = Args.hasArg(OPT_fconcepts_ts);
|
||||
Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
|
||||
|
|
|
@ -2245,14 +2245,13 @@ void Sema::DeclareGlobalNewDelete() {
|
|||
|
||||
QualType VoidPtr = Context.getPointerType(Context.VoidTy);
|
||||
QualType SizeT = Context.getSizeType();
|
||||
bool AssumeSaneOperatorNew = getLangOpts().AssumeSaneOperatorNew;
|
||||
|
||||
DeclareGlobalAllocationFunction(
|
||||
Context.DeclarationNames.getCXXOperatorName(OO_New),
|
||||
VoidPtr, SizeT, QualType(), AssumeSaneOperatorNew);
|
||||
VoidPtr, SizeT, QualType());
|
||||
DeclareGlobalAllocationFunction(
|
||||
Context.DeclarationNames.getCXXOperatorName(OO_Array_New),
|
||||
VoidPtr, SizeT, QualType(), AssumeSaneOperatorNew);
|
||||
VoidPtr, SizeT, QualType());
|
||||
DeclareGlobalAllocationFunction(
|
||||
Context.DeclarationNames.getCXXOperatorName(OO_Delete),
|
||||
Context.VoidTy, VoidPtr);
|
||||
|
@ -2273,8 +2272,7 @@ void Sema::DeclareGlobalNewDelete() {
|
|||
/// allocation function if it doesn't already exist.
|
||||
void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
|
||||
QualType Return,
|
||||
QualType Param1, QualType Param2,
|
||||
bool AddRestrictAttr) {
|
||||
QualType Param1, QualType Param2) {
|
||||
DeclContext *GlobalCtx = Context.getTranslationUnitDecl();
|
||||
unsigned NumParams = Param2.isNull() ? 1 : 2;
|
||||
|
||||
|
@ -2297,9 +2295,6 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
|
|||
// FIXME: Do we need to check for default arguments here?
|
||||
if (InitialParam1Type == Param1 &&
|
||||
(NumParams == 1 || InitialParam2Type == Param2)) {
|
||||
if (AddRestrictAttr && !Func->hasAttr<RestrictAttr>())
|
||||
Func->addAttr(RestrictAttr::CreateImplicit(
|
||||
Context, RestrictAttr::GNU_malloc));
|
||||
// Make the function visible to name lookup, even if we found it in
|
||||
// an unimported module. It either is an implicitly-declared global
|
||||
// allocation function, or is suppressing that function.
|
||||
|
@ -2342,10 +2337,6 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
|
|||
Alloc->addAttr(VisibilityAttr::CreateImplicit(Context,
|
||||
VisibilityAttr::Default));
|
||||
|
||||
if (AddRestrictAttr)
|
||||
Alloc->addAttr(
|
||||
RestrictAttr::CreateImplicit(Context, RestrictAttr::GNU_malloc));
|
||||
|
||||
ParmVarDecl *ParamDecls[2];
|
||||
for (unsigned I = 0; I != NumParams; ++I) {
|
||||
ParamDecls[I] = ParmVarDecl::Create(Context, Alloc, SourceLocation(),
|
||||
|
|
|
@ -13,7 +13,7 @@ volatile float TestAlign(void)
|
|||
}
|
||||
|
||||
// CHECK: [[R:%.*]] = alloca <8 x float>, align 32
|
||||
// CHECK-NEXT: [[CALL:%.*]] = call noalias i8* @_Znwm(i64 32)
|
||||
// CHECK-NEXT: [[CALL:%.*]] = call i8* @_Znwm(i64 32)
|
||||
// CHECK-NEXT: [[ZERO:%.*]] = bitcast i8* [[CALL]] to <8 x float>*
|
||||
// CHECK-NEXT: store <8 x float>* [[ZERO]], <8 x float>** [[P:%.*]], align 8
|
||||
// CHECK-NEXT: [[ONE:%.*]] = load <8 x float>*, <8 x float>** [[P]], align 8
|
||||
|
@ -42,7 +42,7 @@ volatile float TestAlign2(void)
|
|||
}
|
||||
|
||||
// CHECK: [[R:%.*]] = alloca <8 x float>, align 32
|
||||
// CHECK-NEXT: [[CALL:%.*]] = call noalias i8* @_Znwm(i64 32)
|
||||
// CHECK-NEXT: [[CALL:%.*]] = call i8* @_Znwm(i64 32)
|
||||
// CHECK-NEXT: [[ZERO:%.*]] = bitcast i8* [[CALL]] to <8 x float>*
|
||||
// CHECK-NEXT: store <8 x float>* [[ZERO]], <8 x float>** [[P:%.*]], align 8
|
||||
// CHECK-NEXT: [[ONE:%.*]] = load <8 x float>*, <8 x float>** [[P]], align 8
|
||||
|
|
|
@ -109,7 +109,7 @@ namespace test3 {
|
|||
|
||||
void a() {
|
||||
// CHECK-LABEL: define void @_ZN5test31aEv()
|
||||
// CHECK: call noalias i8* @_Znam(i32 48)
|
||||
// CHECK: call i8* @_Znam(i32 48)
|
||||
// CHECK: store i32 4
|
||||
// CHECK: store i32 10
|
||||
A *x = new A[10];
|
||||
|
@ -122,7 +122,7 @@ namespace test3 {
|
|||
// CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8)
|
||||
// CHECK: [[OR:%.*]] = or i1
|
||||
// CHECK: [[SZ:%.*]] = select i1 [[OR]]
|
||||
// CHECK: call noalias i8* @_Znam(i32 [[SZ]])
|
||||
// CHECK: call i8* @_Znam(i32 [[SZ]])
|
||||
// CHECK: store i32 4
|
||||
// CHECK: store i32 [[N]]
|
||||
A *x = new A[n];
|
||||
|
@ -130,7 +130,7 @@ namespace test3 {
|
|||
|
||||
void c() {
|
||||
// CHECK-LABEL: define void @_ZN5test31cEv()
|
||||
// CHECK: call noalias i8* @_Znam(i32 808)
|
||||
// CHECK: call i8* @_Znam(i32 808)
|
||||
// CHECK: store i32 4
|
||||
// CHECK: store i32 200
|
||||
A (*x)[20] = new A[10][20];
|
||||
|
@ -143,7 +143,7 @@ namespace test3 {
|
|||
// CHECK: [[NE:%.*]] = mul i32 [[N]], 20
|
||||
// CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8)
|
||||
// CHECK: [[SZ:%.*]] = select
|
||||
// CHECK: call noalias i8* @_Znam(i32 [[SZ]])
|
||||
// CHECK: call i8* @_Znam(i32 [[SZ]])
|
||||
// CHECK: store i32 4
|
||||
// CHECK: store i32 [[NE]]
|
||||
A (*x)[20] = new A[n][20];
|
||||
|
@ -182,7 +182,7 @@ namespace test4 {
|
|||
|
||||
void a() {
|
||||
// CHECK-LABEL: define void @_ZN5test41aEv()
|
||||
// CHECK: call noalias i8* @_Znam(i32 48)
|
||||
// CHECK: call i8* @_Znam(i32 48)
|
||||
// CHECK: store i32 4
|
||||
// CHECK: store i32 10
|
||||
A *x = new A[10];
|
||||
|
@ -194,7 +194,7 @@ namespace test4 {
|
|||
// CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 4)
|
||||
// CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8)
|
||||
// CHECK: [[SZ:%.*]] = select
|
||||
// CHECK: call noalias i8* @_Znam(i32 [[SZ]])
|
||||
// CHECK: call i8* @_Znam(i32 [[SZ]])
|
||||
// CHECK: store i32 4
|
||||
// CHECK: store i32 [[N]]
|
||||
A *x = new A[n];
|
||||
|
@ -202,7 +202,7 @@ namespace test4 {
|
|||
|
||||
void c() {
|
||||
// CHECK-LABEL: define void @_ZN5test41cEv()
|
||||
// CHECK: call noalias i8* @_Znam(i32 808)
|
||||
// CHECK: call i8* @_Znam(i32 808)
|
||||
// CHECK: store i32 4
|
||||
// CHECK: store i32 200
|
||||
A (*x)[20] = new A[10][20];
|
||||
|
@ -215,7 +215,7 @@ namespace test4 {
|
|||
// CHECK: [[NE:%.*]] = mul i32 [[N]], 20
|
||||
// CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8)
|
||||
// CHECK: [[SZ:%.*]] = select
|
||||
// CHECK: call noalias i8* @_Znam(i32 [[SZ]])
|
||||
// CHECK: call i8* @_Znam(i32 [[SZ]])
|
||||
// CHECK: store i32 4
|
||||
// CHECK: store i32 [[NE]]
|
||||
A (*x)[20] = new A[n][20];
|
||||
|
@ -383,7 +383,7 @@ namespace test9 {
|
|||
// CHECK-NEXT: [[OVERFLOW:%.*]] = or i1 [[O0]], [[O1]]
|
||||
// CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0
|
||||
// CHECK-NEXT: [[T4:%.*]] = select i1 [[OVERFLOW]], i32 -1, i32 [[T3]]
|
||||
// CHECK-NEXT: [[ALLOC:%.*]] = call noalias i8* @_Znam(i32 [[T4]])
|
||||
// CHECK-NEXT: [[ALLOC:%.*]] = call i8* @_Znam(i32 [[T4]])
|
||||
// CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[ALLOC]] to i32*
|
||||
// CHECK-NEXT: store i32 16, i32* [[T0]]
|
||||
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i32, i32* [[T0]], i32 1
|
||||
|
|
|
@ -249,7 +249,7 @@ haslist2::haslist2()
|
|||
void fn10(int i) {
|
||||
// CHECK-LABEL: define void @_Z4fn10i
|
||||
// CHECK: alloca [3 x i32]
|
||||
// CHECK: call noalias i8* @_Znw{{[jm]}}
|
||||
// CHECK: call i8* @_Znw{{[jm]}}
|
||||
// CHECK: store i32 %
|
||||
// CHECK: store i32 2
|
||||
// CHECK: store i32 3
|
||||
|
|
|
@ -7,7 +7,7 @@ struct S { S(); S(int); ~S(); int n; };
|
|||
void *p = new S[2][3]{ { 1, 2, 3 }, { 4, 5, 6 } };
|
||||
|
||||
// CHECK-LABEL: define
|
||||
// CHECK: %[[ALLOC:.*]] = call noalias i8* @_Znam(i64 32)
|
||||
// CHECK: %[[ALLOC:.*]] = call i8* @_Znam(i64 32)
|
||||
// CHECK: %[[COOKIE:.*]] = bitcast i8* %[[ALLOC]] to i64*
|
||||
// CHECK: store i64 6, i64* %[[COOKIE]]
|
||||
// CHECK: %[[START_AS_i8:.*]] = getelementptr inbounds i8, i8* %[[ALLOC]], i64 8
|
||||
|
@ -50,7 +50,7 @@ void *q = new S[n][3]{ { 1, 2, 3 }, { 4, 5, 6 } };
|
|||
// CHECK: call {{.*}} @llvm.umul.with.overflow.i64(i64 %[[N:.*]], i64 12)
|
||||
// CHECK: %[[ELTS:.*]] = mul i64 %[[N]], 3
|
||||
// CHECK: call {{.*}} @llvm.uadd.with.overflow.i64(i64 %{{.*}}, i64 8)
|
||||
// CHECK: %[[ALLOC:.*]] = call noalias i8* @_Znam(i64 %{{.*}})
|
||||
// CHECK: %[[ALLOC:.*]] = call i8* @_Znam(i64 %{{.*}})
|
||||
//
|
||||
// CHECK: %[[COOKIE:.*]] = bitcast i8* %[[ALLOC]] to i64*
|
||||
// CHECK: store i64 %[[ELTS]], i64* %[[COOKIE]]
|
||||
|
@ -113,7 +113,7 @@ void *r = new T[n][3]{ { 1, 2, 3 }, { 4, 5, 6 } };
|
|||
// No cookie.
|
||||
// CHECK-NOT: @llvm.uadd.with.overflow
|
||||
//
|
||||
// CHECK: %[[ALLOC:.*]] = call noalias i8* @_Znam(i64 %{{.*}})
|
||||
// CHECK: %[[ALLOC:.*]] = call i8* @_Znam(i64 %{{.*}})
|
||||
//
|
||||
// CHECK: %[[START_AS_T:.*]] = bitcast i8* %[[ALLOC]] to %[[T:.*]]*
|
||||
//
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace test2 {
|
|||
|
||||
// CHECK: define [[A:%.*]]* @_ZN5test24testEv()
|
||||
A *test() {
|
||||
// CHECK: [[NEW:%.*]] = call noalias i8* @_Znaj(i32 44)
|
||||
// CHECK: [[NEW:%.*]] = call i8* @_Znaj(i32 44)
|
||||
// CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[NEW]] to i32*
|
||||
// CHECK-NEXT: store i32 10, i32* [[T0]]
|
||||
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[NEW]], i32 4
|
||||
|
@ -63,7 +63,7 @@ namespace test3 {
|
|||
|
||||
// CHECK-LABEL: define void @_ZN5test34testEv()
|
||||
void test() {
|
||||
// CHECK: call noalias i8* @_Znaj(i32 24)
|
||||
// CHECK: call i8* @_Znaj(i32 24)
|
||||
// CHECK-NEXT: bitcast
|
||||
// CHECK-NEXT: store i32 5
|
||||
(void) new B[5];
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace test1 {
|
|||
|
||||
A *a() {
|
||||
// CHECK: define [[A:%.*]]* @_ZN5test11aEv()
|
||||
// CHECK: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
|
||||
// CHECK: [[NEW:%.*]] = call i8* @_Znwm(i64 8)
|
||||
// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
|
||||
// CHECK-NEXT: invoke void @_ZN5test11AC1Ei([[A]]* [[CAST]], i32 5)
|
||||
// CHECK: ret [[A]]* [[CAST]]
|
||||
|
@ -40,7 +40,7 @@ namespace test1 {
|
|||
|
||||
A *b() {
|
||||
// CHECK: define [[A:%.*]]* @_ZN5test11bEv()
|
||||
// CHECK: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
|
||||
// CHECK: [[NEW:%.*]] = call i8* @_Znwm(i64 8)
|
||||
// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
|
||||
// CHECK-NEXT: [[FOO:%.*]] = invoke i32 @_ZN5test13fooEv()
|
||||
// CHECK: invoke void @_ZN5test11AC1Ei([[A]]* [[CAST]], i32 [[FOO]])
|
||||
|
@ -56,7 +56,7 @@ namespace test1 {
|
|||
A *c() {
|
||||
// CHECK: define [[A:%.*]]* @_ZN5test11cEv()
|
||||
// CHECK: [[ACTIVE:%.*]] = alloca i1
|
||||
// CHECK-NEXT: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
|
||||
// CHECK-NEXT: [[NEW:%.*]] = call i8* @_Znwm(i64 8)
|
||||
// CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
|
||||
// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
|
||||
// CHECK-NEXT: invoke void @_ZN5test11BC1Ev([[B:%.*]]* [[T0:%.*]])
|
||||
|
@ -82,7 +82,7 @@ namespace test1 {
|
|||
A *d() {
|
||||
// CHECK: define [[A:%.*]]* @_ZN5test11dEv()
|
||||
// CHECK: [[ACTIVE:%.*]] = alloca i1
|
||||
// CHECK-NEXT: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
|
||||
// CHECK-NEXT: [[NEW:%.*]] = call i8* @_Znwm(i64 8)
|
||||
// CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
|
||||
// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
|
||||
// CHECK-NEXT: invoke void @_ZN5test11BC1Ev([[B:%.*]]* [[T0:%.*]])
|
||||
|
@ -100,7 +100,7 @@ namespace test1 {
|
|||
A *e() {
|
||||
// CHECK: define [[A:%.*]]* @_ZN5test11eEv()
|
||||
// CHECK: [[ACTIVE:%.*]] = alloca i1
|
||||
// CHECK-NEXT: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
|
||||
// CHECK-NEXT: [[NEW:%.*]] = call i8* @_Znwm(i64 8)
|
||||
// CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
|
||||
// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
|
||||
// CHECK-NEXT: invoke void @_ZN5test11BC1Ev([[B:%.*]]* [[T0:%.*]])
|
||||
|
@ -131,7 +131,7 @@ namespace test1 {
|
|||
// CHECK: define [[A:%.*]]* @_ZN5test11iEv()
|
||||
// CHECK: [[X:%.*]] = alloca [[A]]*, align 8
|
||||
// CHECK: [[ACTIVE:%.*]] = alloca i1
|
||||
// CHECK: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
|
||||
// CHECK: [[NEW:%.*]] = call i8* @_Znwm(i64 8)
|
||||
// CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
|
||||
// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
|
||||
// CHECK-NEXT: invoke void @_ZN5test15makeBEv([[B:%.*]]* sret [[T0:%.*]])
|
||||
|
@ -422,7 +422,7 @@ namespace test9 {
|
|||
return new A[10];
|
||||
}
|
||||
// CHECK: define {{%.*}}* @_ZN5test94testEv
|
||||
// CHECK: [[TEST9_NEW:%.*]] = call noalias i8* @_Znam
|
||||
// CHECK: [[TEST9_NEW:%.*]] = call i8* @_Znam
|
||||
// CHECK: call void @_ZdaPv(i8* [[TEST9_NEW]])
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace test0 {
|
|||
// CHECK-NEXT: [[CLEANUPACTIVE:%.*]] = alloca i1
|
||||
// CHECK: call void @_ZN5test01AC1Ev([[A]]* [[Y]])
|
||||
// CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[Z]])
|
||||
// CHECK: [[NEW:%.*]] = invoke noalias i8* @_Znwm(i64 1)
|
||||
// CHECK: [[NEW:%.*]] = invoke i8* @_Znwm(i64 1)
|
||||
// CHECK: store i1 true, i1* [[CLEANUPACTIVE]]
|
||||
// CHECK: [[NEWCAST:%.*]] = bitcast i8* [[NEW]] to [[V]]*
|
||||
// CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[TMP]])
|
||||
|
|
|
@ -7,7 +7,7 @@ struct ClassWithoutDtor {
|
|||
void check_array_no_cookies() {
|
||||
// CHECK: define void @"\01?check_array_no_cookies@@YAXXZ"() [[NUW:#[0-9]+]]
|
||||
|
||||
// CHECK: call noalias i8* @"\01??_U@YAPAXI@Z"(i32 42)
|
||||
// CHECK: call i8* @"\01??_U@YAPAXI@Z"(i32 42)
|
||||
ClassWithoutDtor *array = new ClassWithoutDtor[42];
|
||||
|
||||
// CHECK: call void @"\01??_V@YAXPAX@Z"(
|
||||
|
@ -24,7 +24,7 @@ void check_array_cookies_simple() {
|
|||
// CHECK: define {{.*}} @"\01?check_array_cookies_simple@@YAXXZ"()
|
||||
|
||||
ClassWithDtor *array = new ClassWithDtor[42];
|
||||
// CHECK: [[ALLOCATED:%.*]] = call noalias i8* @"\01??_U@YAPAXI@Z"(i32 46)
|
||||
// CHECK: [[ALLOCATED:%.*]] = call i8* @"\01??_U@YAPAXI@Z"(i32 46)
|
||||
// 46 = 42 + size of cookie (4)
|
||||
// CHECK: [[COOKIE:%.*]] = bitcast i8* [[ALLOCATED]] to i32*
|
||||
// CHECK: store i32 42, i32* [[COOKIE]]
|
||||
|
@ -46,7 +46,7 @@ struct __attribute__((aligned(8))) ClassWithAlignment {
|
|||
void check_array_cookies_aligned() {
|
||||
// CHECK: define {{.*}} @"\01?check_array_cookies_aligned@@YAXXZ"()
|
||||
ClassWithAlignment *array = new ClassWithAlignment[42];
|
||||
// CHECK: [[ALLOCATED:%.*]] = call noalias i8* @"\01??_U@YAPAXI@Z"(i32 344)
|
||||
// CHECK: [[ALLOCATED:%.*]] = call i8* @"\01??_U@YAPAXI@Z"(i32 344)
|
||||
// 344 = 42*8 + size of cookie (8, due to alignment)
|
||||
// CHECK: [[COOKIE:%.*]] = bitcast i8* [[ALLOCATED]] to i32*
|
||||
// CHECK: store i32 42, i32* [[COOKIE]]
|
||||
|
|
|
@ -10,13 +10,13 @@ long *alloc_long() {
|
|||
return rv;
|
||||
}
|
||||
// O32-LABEL: define i32* @_Z10alloc_longv()
|
||||
// O32: call noalias i8* @_Znwj(i32 signext 4)
|
||||
// O32: call i8* @_Znwj(i32 signext 4)
|
||||
|
||||
// N32-LABEL: define i32* @_Z10alloc_longv()
|
||||
// N32: call noalias i8* @_Znwj(i32 signext 4)
|
||||
// N32: call i8* @_Znwj(i32 signext 4)
|
||||
|
||||
// N64-LABEL: define i64* @_Z10alloc_longv()
|
||||
// N64: call noalias i8* @_Znwm(i64 zeroext 8)
|
||||
// N64: call i8* @_Znwm(i64 zeroext 8)
|
||||
|
||||
long *alloc_long_array() {
|
||||
long *rv = new long[2];
|
||||
|
@ -24,13 +24,13 @@ long *alloc_long_array() {
|
|||
}
|
||||
|
||||
// O32-LABEL: define i32* @_Z16alloc_long_arrayv()
|
||||
// O32: call noalias i8* @_Znaj(i32 signext 8)
|
||||
// O32: call i8* @_Znaj(i32 signext 8)
|
||||
|
||||
// N32-LABEL: define i32* @_Z16alloc_long_arrayv()
|
||||
// N32: call noalias i8* @_Znaj(i32 signext 8)
|
||||
// N32: call i8* @_Znaj(i32 signext 8)
|
||||
|
||||
// N64-LABEL: define i64* @_Z16alloc_long_arrayv()
|
||||
// N64: call noalias i8* @_Znam(i64 zeroext 16)
|
||||
// N64: call i8* @_Znam(i64 zeroext 16)
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ int main() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// CHECK: call noalias i8* @_Znam
|
||||
// CHECK: call noalias i8* @_Znam
|
||||
// CHECK: call noalias i8* @_Znam
|
||||
// CHECK: call i8* @_Znam
|
||||
// CHECK: call i8* @_Znam
|
||||
// CHECK: call i8* @_Znam
|
||||
|
||||
|
|
|
@ -9,5 +9,5 @@ extern "C" char *something(long long x) {
|
|||
void *operator new(size_t) __attribute__((alias("something")));
|
||||
|
||||
// PR16715: don't assert here.
|
||||
// CHECK: call noalias i8* @_Znwm(i64 4){{$}}
|
||||
// CHECK: call i8* @_Znwm(i64 4){{$}}
|
||||
int *pr16715 = new int;
|
||||
|
|
|
@ -14,7 +14,7 @@ void fn(int n) {
|
|||
// CHECK-LABEL: define void @_Z15const_underflowv
|
||||
void const_underflow() {
|
||||
// CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
|
||||
// CHECK: call noalias i8* @_Zna{{.}}(i{{32|64}} -1)
|
||||
// CHECK: call i8* @_Zna{{.}}(i{{32|64}} -1)
|
||||
new int[2] { 1, 2, 3 };
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ void check_array_value_init() {
|
|||
struct S;
|
||||
new (int S::*[3][4][5]) ();
|
||||
|
||||
// CHECK: call noalias i8* @_Zna{{.}}(i{{32 240|64 480}})
|
||||
// CHECK: call i8* @_Zna{{.}}(i{{32 240|64 480}})
|
||||
// CHECK: getelementptr inbounds i{{32|64}}, i{{32|64}}* {{.*}}, i{{32|64}} 60
|
||||
|
||||
// CHECK: phi
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace test0 {
|
|||
// CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 1
|
||||
// CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
|
||||
// CHECK-NEXT: [[T3:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
|
||||
// CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T3]])
|
||||
// CHECK-NEXT: call i8* @_Znaj(i32 [[T3]])
|
||||
// CHECK: getelementptr inbounds {{.*}}, i32 [[N]]
|
||||
elt *test(short s) {
|
||||
return new elt[s];
|
||||
|
@ -40,7 +40,7 @@ namespace test1 {
|
|||
// CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
|
||||
// CHECK-NEXT: [[T3:%.*]] = mul i32 [[N]], 100
|
||||
// CHECK-NEXT: [[T4:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
|
||||
// CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T4]])
|
||||
// CHECK-NEXT: call i8* @_Znaj(i32 [[T4]])
|
||||
// CHECK: getelementptr inbounds {{.*}}, i32 [[T3]]
|
||||
elt *test(short s) {
|
||||
return new elt[s];
|
||||
|
@ -68,7 +68,7 @@ namespace test2 {
|
|||
// CHECK-NEXT: [[T6:%.*]] = or i1 [[T1]], [[T5]]
|
||||
// CHECK-NEXT: [[T7:%.*]] = extractvalue { i32, i1 } [[T4]], 0
|
||||
// CHECK-NEXT: [[T8:%.*]] = select i1 [[T6]], i32 -1, i32 [[T7]]
|
||||
// CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T8]])
|
||||
// CHECK-NEXT: call i8* @_Znaj(i32 [[T8]])
|
||||
// CHECK: getelementptr inbounds {{.*}}, i32 [[T3]]
|
||||
elt *test(short s) {
|
||||
return new elt[s];
|
||||
|
@ -87,7 +87,7 @@ namespace test4 {
|
|||
// CHECK: [[N:%.*]] = sext i16 {{%.*}} to i32
|
||||
// CHECK-NEXT: [[T0:%.*]] = icmp slt i32 [[N]], 0
|
||||
// CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i32 -1, i32 [[N]]
|
||||
// CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T1]])
|
||||
// CHECK-NEXT: call i8* @_Znaj(i32 [[T1]])
|
||||
// CHECK: getelementptr inbounds {{.*}}, i32 [[N]]
|
||||
elt *test(short s) {
|
||||
return new elt[s];
|
||||
|
@ -106,7 +106,7 @@ namespace test5 {
|
|||
// CHECK: [[N:%.*]] = load i32, i32*
|
||||
// CHECK-NEXT: [[T0:%.*]] = icmp slt i32 [[N]], 0
|
||||
// CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i32 -1, i32 [[N]]
|
||||
// CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T1]])
|
||||
// CHECK-NEXT: call i8* @_Znaj(i32 [[T1]])
|
||||
// CHECK: getelementptr inbounds {{.*}}, i32 [[N]]
|
||||
elt *test(int s) {
|
||||
return new elt[s];
|
||||
|
@ -128,7 +128,7 @@ namespace test6 {
|
|||
// CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 1
|
||||
// CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
|
||||
// CHECK-NEXT: [[T3:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
|
||||
// CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T3]])
|
||||
// CHECK-NEXT: call i8* @_Znaj(i32 [[T3]])
|
||||
// CHECK: getelementptr inbounds {{.*}}, i32 [[N]]
|
||||
elt *test(unsigned short s) {
|
||||
return new elt[s];
|
||||
|
@ -151,7 +151,7 @@ namespace test7 {
|
|||
// CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
|
||||
// CHECK-NEXT: [[T3:%.*]] = mul i32 [[N]], 100
|
||||
// CHECK-NEXT: [[T4:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
|
||||
// CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T4]])
|
||||
// CHECK-NEXT: call i8* @_Znaj(i32 [[T4]])
|
||||
// CHECK: getelementptr inbounds {{.*}}, i32 [[T3]]
|
||||
elt *test(unsigned short s) {
|
||||
return new elt[s];
|
||||
|
@ -176,7 +176,7 @@ namespace test8 {
|
|||
// CHECK-NEXT: [[T4:%.*]] = or i1 [[T0]], [[T3]]
|
||||
// CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T2]], 0
|
||||
// CHECK-NEXT: [[T6:%.*]] = select i1 [[T4]], i32 -1, i32 [[T5]]
|
||||
// CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T6]])
|
||||
// CHECK-NEXT: call i8* @_Znaj(i32 [[T6]])
|
||||
// CHECK: getelementptr inbounds {{.*}}, i32 [[T1]]
|
||||
elt *test(long long s) {
|
||||
return new elt[s];
|
||||
|
@ -201,7 +201,7 @@ namespace test9 {
|
|||
// CHECK-NEXT: [[T4:%.*]] = or i1 [[T0]], [[T3]]
|
||||
// CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T2]], 0
|
||||
// CHECK-NEXT: [[T6:%.*]] = select i1 [[T4]], i32 -1, i32 [[T5]]
|
||||
// CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T6]])
|
||||
// CHECK-NEXT: call i8* @_Znaj(i32 [[T6]])
|
||||
// CHECK: getelementptr inbounds {{.*}}, i32 [[T1]]
|
||||
elt *test(unsigned long long s) {
|
||||
return new elt[s];
|
||||
|
|
|
@ -127,15 +127,15 @@ struct B { int a; };
|
|||
struct Bmemptr { int Bmemptr::* memptr; int a; };
|
||||
|
||||
void t11(int n) {
|
||||
// CHECK: call noalias i8* @_Znwm
|
||||
// CHECK: call i8* @_Znwm
|
||||
// CHECK: call void @llvm.memset.p0i8.i64(
|
||||
B* b = new B();
|
||||
|
||||
// CHECK: call noalias i8* @_Znam
|
||||
// CHECK: call i8* @_Znam
|
||||
// CHECK: {{call void.*llvm.memset.p0i8.i64.*i8 0, i64 %}}
|
||||
B *b2 = new B[n]();
|
||||
|
||||
// CHECK: call noalias i8* @_Znam
|
||||
// CHECK: call i8* @_Znam
|
||||
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
|
||||
// CHECK: br
|
||||
Bmemptr *b_memptr = new Bmemptr[n]();
|
||||
|
@ -148,11 +148,11 @@ struct Empty { };
|
|||
// We don't need to initialize an empty class.
|
||||
// CHECK-LABEL: define void @_Z3t12v
|
||||
void t12() {
|
||||
// CHECK: call noalias i8* @_Znam
|
||||
// CHECK: call i8* @_Znam
|
||||
// CHECK-NOT: br
|
||||
(void)new Empty[10];
|
||||
|
||||
// CHECK: call noalias i8* @_Znam
|
||||
// CHECK: call i8* @_Znam
|
||||
// CHECK-NOT: br
|
||||
(void)new Empty[10]();
|
||||
|
||||
|
@ -162,11 +162,11 @@ void t12() {
|
|||
// Zero-initialization
|
||||
// CHECK-LABEL: define void @_Z3t13i
|
||||
void t13(int n) {
|
||||
// CHECK: call noalias i8* @_Znwm
|
||||
// CHECK: call i8* @_Znwm
|
||||
// CHECK: store i32 0, i32*
|
||||
(void)new int();
|
||||
|
||||
// CHECK: call noalias i8* @_Znam
|
||||
// CHECK: call i8* @_Znam
|
||||
// CHECK: {{call void.*llvm.memset.p0i8.i64.*i8 0, i64 %}}
|
||||
(void)new int[n]();
|
||||
|
||||
|
@ -186,7 +186,7 @@ void f() {
|
|||
// CHECK: call void @_ZN5AllocD1Ev(
|
||||
// CHECK: call void @_ZN5AllocdaEPv(i8*
|
||||
delete[] new Alloc[10][20];
|
||||
// CHECK: call noalias i8* @_Znwm
|
||||
// CHECK: call i8* @_Znwm
|
||||
// CHECK: call void @_ZdlPv(i8*
|
||||
delete new bool;
|
||||
// CHECK: ret void
|
||||
|
@ -274,7 +274,7 @@ namespace PR10197 {
|
|||
// CHECK-LABEL: define weak_odr void @_ZN7PR101971fIiEEvv()
|
||||
template<typename T>
|
||||
void f() {
|
||||
// CHECK: [[CALL:%.*]] = call noalias i8* @_Znwm
|
||||
// CHECK: [[CALL:%.*]] = call i8* @_Znwm
|
||||
// CHECK-NEXT: [[CASTED:%.*]] = bitcast i8* [[CALL]] to
|
||||
new T;
|
||||
// CHECK-NEXT: ret void
|
||||
|
@ -296,7 +296,7 @@ namespace PR11757 {
|
|||
struct X { X(); X(const X&); };
|
||||
X* a(X* x) { return new X(X()); }
|
||||
// CHECK: define {{.*}} @_ZN7PR117571aEPNS_1XE
|
||||
// CHECK: [[CALL:%.*]] = call noalias i8* @_Znwm
|
||||
// CHECK: [[CALL:%.*]] = call i8* @_Znwm
|
||||
// CHECK-NEXT: [[CASTED:%.*]] = bitcast i8* [[CALL]] to
|
||||
// CHECK-NEXT: call void @_ZN7PR117571XC1Ev({{.*}}* [[CASTED]])
|
||||
// CHECK-NEXT: ret {{.*}} [[CASTED]]
|
||||
|
@ -306,7 +306,7 @@ namespace PR13380 {
|
|||
struct A { A() {} };
|
||||
struct B : public A { int x; };
|
||||
// CHECK-LABEL: define i8* @_ZN7PR133801fEv
|
||||
// CHECK: call noalias i8* @_Znam(
|
||||
// CHECK: call i8* @_Znam(
|
||||
// CHECK: call void @llvm.memset.p0i8
|
||||
// CHECK-NEXT: call void @_ZN7PR133801BC1Ev
|
||||
void* f() { return new B[2](); }
|
||||
|
@ -320,12 +320,12 @@ namespace N3664 {
|
|||
|
||||
// CHECK-LABEL: define void @_ZN5N36641fEv
|
||||
void f() {
|
||||
// CHECK: call noalias i8* @_Znwm(i64 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
|
||||
// CHECK: call i8* @_Znwm(i64 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
|
||||
int *p = new int; // expected-note {{allocated with 'new' here}}
|
||||
// CHECK: call void @_ZdlPv({{.*}}) [[ATTR_BUILTIN_DELETE:#[^ ]*]]
|
||||
delete p;
|
||||
|
||||
// CHECK: call noalias i8* @_Znam(i64 12) [[ATTR_BUILTIN_NEW]]
|
||||
// CHECK: call i8* @_Znam(i64 12) [[ATTR_BUILTIN_NEW]]
|
||||
int *q = new int[3];
|
||||
// CHECK: call void @_ZdaPv({{.*}}) [[ATTR_BUILTIN_DELETE]]
|
||||
delete[] p; // expected-warning {{'delete[]' applied to a pointer that was allocated with 'new'; did you mean 'delete'?}}
|
||||
|
@ -337,19 +337,18 @@ namespace N3664 {
|
|||
(void) new (mpt) int;
|
||||
}
|
||||
|
||||
// FIXME: Can we mark this noalias?
|
||||
// CHECK: declare i8* @_ZnamRKSt9nothrow_t(i64, {{.*}}) [[ATTR_NOBUILTIN_NOUNWIND]]
|
||||
// CHECK: declare noalias i8* @_ZnamRKSt9nothrow_t(i64, {{.*}}) [[ATTR_NOBUILTIN_NOUNWIND]]
|
||||
|
||||
// CHECK-LABEL: define void @_ZN5N36641gEv
|
||||
void g() {
|
||||
// It's OK for there to be attributes here, so long as we don't have a
|
||||
// 'builtin' attribute.
|
||||
// CHECK: call noalias i8* @_Znwm(i64 4){{$}}
|
||||
// CHECK: call i8* @_Znwm(i64 4){{$}}
|
||||
int *p = (int*)operator new(4);
|
||||
// CHECK: call void @_ZdlPv({{.*}}) [[ATTR_NOUNWIND:#[^ ]*]]
|
||||
operator delete(p);
|
||||
|
||||
// CHECK: call noalias i8* @_Znam(i64 12){{$}}
|
||||
// CHECK: call i8* @_Znam(i64 12){{$}}
|
||||
int *q = (int*)operator new[](12);
|
||||
// CHECK: call void @_ZdaPv({{.*}}) [[ATTR_NOUNWIND]]
|
||||
operator delete [](p);
|
||||
|
@ -362,7 +361,7 @@ namespace N3664 {
|
|||
namespace builtins {
|
||||
// CHECK-LABEL: define void @_ZN8builtins1fEv
|
||||
void f() {
|
||||
// CHECK: call noalias i8* @_Znwm(i64 4) [[ATTR_BUILTIN_NEW]]
|
||||
// CHECK: call i8* @_Znwm(i64 4) [[ATTR_BUILTIN_NEW]]
|
||||
// CHECK: call void @_ZdlPv({{.*}}) [[ATTR_BUILTIN_DELETE]]
|
||||
__builtin_operator_delete(__builtin_operator_new(4));
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ void f1() {
|
|||
new teste();
|
||||
}
|
||||
|
||||
|
||||
// rdar://5739832 - operator new should check for overflow in multiply.
|
||||
void *f2(long N) {
|
||||
return new int[N];
|
||||
|
@ -25,5 +24,8 @@ void *f2(long N) {
|
|||
// SANE-NEXT: [[OVER:%.*]] = extractvalue {{.*}} [[UWO]], 1
|
||||
// SANE-NEXT: [[SUM:%.*]] = extractvalue {{.*}} [[UWO]], 0
|
||||
// SANE-NEXT: [[RESULT:%.*]] = select i1 [[OVER]], i32 -1, i32 [[SUM]]
|
||||
// SANE-NEXT: call noalias i8* @_Znaj(i32 [[RESULT]])
|
||||
// SANE-NEXT: call i8* @_Znaj(i32 [[RESULT]])
|
||||
}
|
||||
|
||||
// SANE: declare noalias i8* @_Znaj(
|
||||
// SANENOT: declare i8* @_Znaj(
|
||||
|
|
|
@ -26,7 +26,7 @@ void f() {
|
|||
}
|
||||
|
||||
void g() {
|
||||
// CHECK: call noalias i8* @_Znwm(i64 1)
|
||||
// CHECK: call i8* @_Znwm(i64 1)
|
||||
// CHECK: call void @_ZN1AC1Ev(
|
||||
static A& a = *new A;
|
||||
}
|
||||
|
|
|
@ -12,32 +12,32 @@ void test_new(id invalue) {
|
|||
// OPT-NEXT: [[T0:%.*]] = call i8* @objc_retain(i8* [[INVALUE:%.*]])
|
||||
// OPT-NEXT: store i8* [[T0]], i8** [[INVALUEADDR]]
|
||||
|
||||
// CHECK: call noalias i8* @_Znwm
|
||||
// CHECK: call i8* @_Znwm
|
||||
// CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
|
||||
// CHECK-NEXT: store i8* null, i8**
|
||||
new strong_id;
|
||||
// CHECK: call noalias i8* @_Znwm
|
||||
// CHECK: call i8* @_Znwm
|
||||
// CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
|
||||
// UNOPT-NEXT: store i8* null, i8**
|
||||
// OPT-NEXT: call i8* @objc_initWeak(i8** {{.*}}, i8* null)
|
||||
new weak_id;
|
||||
|
||||
// CHECK: call noalias i8* @_Znwm
|
||||
// CHECK: call i8* @_Znwm
|
||||
// CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
|
||||
// CHECK-NEXT: store i8* null, i8**
|
||||
new __strong id;
|
||||
// CHECK: call noalias i8* @_Znwm
|
||||
// CHECK: call i8* @_Znwm
|
||||
// CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
|
||||
// UNOPT-NEXT: store i8* null, i8**
|
||||
// OPT-NEXT: call i8* @objc_initWeak(i8** {{.*}}, i8* null)
|
||||
new __weak id;
|
||||
|
||||
// CHECK: call noalias i8* @_Znwm
|
||||
// CHECK: call i8* @_Znwm
|
||||
// CHECK: call i8* @objc_retain
|
||||
// CHECK: store i8*
|
||||
new __strong id(invalue);
|
||||
|
||||
// CHECK: call noalias i8* @_Znwm
|
||||
// CHECK: call i8* @_Znwm
|
||||
// CHECK: call i8* @objc_initWeak
|
||||
new __weak id(invalue);
|
||||
|
||||
|
@ -48,12 +48,12 @@ void test_new(id invalue) {
|
|||
|
||||
// CHECK-LABEL: define void @_Z14test_array_new
|
||||
void test_array_new() {
|
||||
// CHECK: call noalias i8* @_Znam
|
||||
// CHECK: call i8* @_Znam
|
||||
// CHECK: store i64 17, i64*
|
||||
// CHECK: call void @llvm.memset.p0i8.i64
|
||||
new strong_id[17];
|
||||
|
||||
// CHECK: call noalias i8* @_Znam
|
||||
// CHECK: call i8* @_Znam
|
||||
// CHECK: store i64 17, i64*
|
||||
// CHECK: call void @llvm.memset.p0i8.i64
|
||||
new weak_id[17];
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace test0 {
|
|||
// CHECK: alloca
|
||||
// CHECK-NEXT: getelementptr
|
||||
// CHECK-NEXT: store
|
||||
// CHECK-NEXT: call noalias i8* @_Znwm(
|
||||
// CHECK-NEXT: call i8* @_Znwm(
|
||||
// CHECK-NEXT: bitcast
|
||||
// CHECK-NEXT: bitcast
|
||||
// CHECK-NEXT: bitcast
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
// RUN: %clang_cc1 -fmodules -DFOO=1 -fsanitize=address -x c++ -fmodule-name=tmp %t/map -emit-module -o %t/tmp-san.pcm
|
||||
// RUN: %clang_cc1 -fmodules -DBAR=2 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp-san.pcm -verify -I%t %s
|
||||
|
||||
// -fno-assume-sane-operator-new is implied by the driver -fsanitize=address flag.
|
||||
// RUN: %clang_cc1 -fmodules -DBAR=2 -fno-assume-sane-operator-new -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
|
||||
|
||||
// Can use the module if -O flags change.
|
||||
// RUN: %clang_cc1 -fmodules -DBAR=2 -Os -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue