diff --git a/lib/Transforms/IPO/InferFunctionAttrs.cpp b/lib/Transforms/IPO/InferFunctionAttrs.cpp index 30402f109f3..c32e09875a1 100644 --- a/lib/Transforms/IPO/InferFunctionAttrs.cpp +++ b/lib/Transforms/IPO/InferFunctionAttrs.cpp @@ -31,7 +31,8 @@ static bool inferAllPrototypeAttributes( // attribute logic on all calls to declarations (as declarations aren't // explicitly visited by CGSCC passes in the new pass manager.) if (F.isDeclaration() && !F.hasOptNone()) { - Changed |= inferLibFuncAttributes(F, GetTLI(F)); + if (!F.hasFnAttribute(Attribute::NoBuiltin)) + Changed |= inferLibFuncAttributes(F, GetTLI(F)); Changed |= inferAttributesFromOthers(F); } diff --git a/test/Transforms/InferFunctionAttrs/nobuiltin.ll b/test/Transforms/InferFunctionAttrs/nobuiltin.ll new file mode 100644 index 00000000000..1239a22a3a0 --- /dev/null +++ b/test/Transforms/InferFunctionAttrs/nobuiltin.ll @@ -0,0 +1,5 @@ +; RUN: opt -S -inferattrs < %s | FileCheck %s + +; CHECK: Function Attrs: nobuiltin allocsize(0) +; CHECK: declare i8* @_Znwm(i32) +declare i8* @_Znwm(i32) nobuiltin allocsize(0)